我有针对不同面/位置的力的 Excel 表格数据。我想在 Ansys 工作台中创建压力选项卡并应用从 excel 读取单元格的力数据,但它显示以下错误。无效数量字符串:CC1[MPa]
以下代码我用来读取数据:-
import clr
clr.AddReference("Microsoft.Office.Interop.Excel")
import Microsoft.Office.Interop.Excel as Excel
ex = Excel.ApplicationClass()
ex.Visible = True
workbook = ex.Workbooks.Open(r"D:\Work\Extra_Work_IMP\1_TMF_macro\Input.xlsx")
worksheet=workbook.worksheets("LC1")
#Define Key ranges in the Workbook
#C1 is location and CC1 is force value
C1 = worksheet.Range["A4"].Text
CC1 = worksheet.Range["B4"].Value
NS= ExtAPI.DataModel.Project.Model.AddNamedSelection()
NS.Name= C1
named_selection=DataModel.GetObjectsByName(C1)
Pressure=DataModel.AnalysisList[0]
my_pressure_1=Pressure.AddPressure ()
my_pressure_1.Location=named_selection[0]
my_pressure_1.Magnitude.Output.DiscreteValues=[Quantity('CC1' '[MPa]')]