-
-
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
Forum Moderator
-
- The topic ‘SpaceClaim – Scripting – add some Modules’ is closed to new replies.
- FSAE CFD – Lesson 1 Preparation question (Using Discovery)
- Project lines/edges into a face with the direction normal to the face
- Script for subtracting models
- Multiple Instances of SpaceClaim taking multiple licenses
- No preview in explorer with scdox file
- Spaceclaim file reference error
- Issues after installing new service pack 2024R1 (sp5)
- Add-in Error Excel
- Problems with loading my Discovery Mesh into Fluent
- Missing SubDivWrapper.dll
-
3892
-
1414
-
1241
-
1118
-
1015
© 2025 Copyright ANSYS, Inc. All rights reserved.