-
-
October 29, 2018 at 10:48 pm
frussold
SubscriberHi @ all.
I´m new in SpaceClaim but i saw, its support scripting.
I tryed some scripts and it works well.
But I´d like to include some python modules like openpyxl, numpy. After I copyed it to ...ANSYS Studentv192scdmLibraryIronPythonLib
I got a strange error like
German: Das Objekt des Typs "Microsoft.Scripting.Runtime.Uninitialized" kann nicht in Typ "System.Exception" umgewandelt werden.
English:
Unable to cast object of type 'Microsoft.Scripting.Runtime.Uninitialized'
to type 'System.Exception'
Has anyone some ideas?
Thanks
Florian
-
October 30, 2018 at 4:48 am
Naresh Patre
Ansys EmployeeHello frussold,
External python modules cannot be currently added to the scripting database.
Regards,
Naresh Patre
-
October 30, 2018 at 5:17 am
Keyur Kanade
Ansys EmployeeHi,
As you are new to SpaceClaim, request you to explore various tools in SpaceClaim like creating groups for parameters etc. Correct usage of different tools can avoid need of scripting. You can find many videos on SpaceClaim at following link
http://www.spaceclaim.com/en/default.aspx
Regards,
Keyur
-
November 1, 2018 at 2:58 pm
frussold
SubscriberI´ve googled but i can´t find a way to load parameters via excel. It just works with groups and groups can´t be import in the script file.
Or someone has an idea. .csv is not a solution for me.
Thanks,
Florian
-
November 2, 2018 at 1:10 am
frussold
SubscriberI´ve found a solution...it´s not perfect but i can work with it.
import clr
import sys
clr.AddReference("Microsoft.Office.Interop.Excel")
import Microsoft.Office.Interop.Excel as Excel
from System.Runtime.InteropServices import Marshal
class DoImport:
def __init__(self):
self.excel = Excel.ApplicationClass()
self.workbook,self.worksheet = ""
def open(self):
self.excel.Visible = True
self.FileName = self.excel.GetOpenFilename(
FileFilter = "Excel Files,*.xlsx",
FilterIndex = 1,
Title = "Open Import File",
MultiSelect = False)
if self.FileName != False:
self.workbook = self.excel.Workbooks.Open(self.FileName)
self.excel.Visible = False
else:
self.excel.DisplayAlerts = False
Marshal.ReleaseComObject(self.excel)
MessageBox.Show("Script abort - please restart")
sys.exit()
def get_xlsx_data(self):
a = []
for i in range(self.workbook.Worksheets.Count):
i = i + 1
a.append(self.workbook.Worksheets.Name)
if a == "ScriptData":
self.worksheet = self.workbook.Worksheets
data = {}
for row in range(self.worksheet.UsedRange.Rows.Count):
datalist = []
for columns in range(self.worksheet.UsedRange.Columns.Count):
datalist.append(self.worksheet.Cells[row + 1, columns + 1].Text)
f = self.worksheet.Cells[row + 1, 1].Value2
data[f] = datalist
self.workbook.Close()
self.excel.Quit()
Marshal.ReleaseComObject(self.workbook)
Marshal.ReleaseComObject(self.worksheet)
Marshal.ReleaseComObject(self.excel)
return data
if __name__ == "__main__":
x = DoImport()
x.open()
data = x.get_xlsx_data()
print data
-
November 2, 2018 at 1:16 am
frussold
Subscribercopy the *.py file into ..scdmLibraryIronPythonLib
in SpaceClaim you can do this
import import_xlsx
load = import_xlsx.DoImport()
load.open()
import_data = load.get_xlsx_data() -
November 2, 2018 at 9:35 am
frussold
Subscriberplease add...i found some errors, sry
clr.AddReference("System.Windows.Forms")
from System.Windows.Forms import MessageBox -
May 2, 2020 at 9:18 pm
prabhukumar
SubscriberHi all,
I am trying to automate a process in spaceclaim. My goal is to import an STL file, extrude it and save it as STEP file. I could record the script in the spaceclaim software and it works perfectly fine. I would like to run the script directly from the command terminal without manually opening the software. Any help would be appreciated. Thank you very much.
Regards,
Prabhu. -
May 4, 2020 at 12:05 pm
Aniket
Ansys Employeeprabhukumar, Answered here:
https://forum.ansys.com/forums/topic/spaceclaim-scripting-3/
Locking this thread now.
-
- You must be logged in to reply to this topic.

Earth Rescue – An Ansys Online Series
The climate crisis is here. But so is the human ingenuity to fight it. Earth Rescue reveals what visionary companies are doing today to engineer radical new ideas in the fight against climate change. Click here to watch the first episode.

Ansys Blog
Subscribe to the Ansys Blog to get great new content about the power of simulation delivered right to your email on a weekly basis. With content from Ansys experts, partners and customers you will learn about product development advances, thought leadership and trends and tips to better use Ansys tools. Sign up here.
- How to work with STL file?
- Using Symmetry in DesignModeler and Expanding the Results
- Rotate tool in ANSYS Design Modeler
- drawing a geometry by importing a table of points
- section plane
- material properties
- ANSYS FLUENT – Operation would result in non manifold bodies
- Geometry scaling
- Parameters not imported into Workbench 18.2 from Solidworks/Inventor
- Convert Surface body to solid
-
2564
-
2078
-
1293
-
1106
-
459
© 2023 Copyright ANSYS, Inc. All rights reserved.