Atul Singh

Opening all files in folder

Discussion created by Atul Singh on Jun 10, 2020

Hello,

 

I have parameterized 20 or so CAD models, and want to import them to space claim for generating the pmdb format of ansys. This is required for the linux version of 2019R2.

 

Now, I have found that if I open Solidworks, and then import sldpart in spaceclaim, my named selection(from the ansys plugin in SW), remains intact.

But if that sldpart is not opened in solidworks , then my named selection are not read in space claim. This is very difficult to find a work around to.

 

Also, I wanted to know if there is a way to update a "open SLDPART , exit" command updated for each directory that I have different cad models in.

 

 

So, I basically want to declare some variable case, that would be present in place of 1\1.SLDPRT in the set Part line below, any thoughts on how can I update this with another script, open each CAD model, after updating a case variable?

Or perhaps another way to do it?

 

Sub main()

Set swApp = Application.SldWorks

Dim COSMOSWORKSObj As Object
Dim CWAddinCallBackObj As Object
Set CWAddinCallBackObj = swApp.GetAddInObject("CosmosWorks.CosmosWorks")
Set COSMOSWORKSObj = CWAddinCallBackObj.COSMOSWORKS

 

' Open
Set Part = swApp.OpenDoc6("C:\Local\SW-tests\analysis\1\1.SLDPRT", 1, 0, "", longstatus, longwarnings)
swApp.ActivateDoc2 "0.SLDPRT", False, longstatus
Set Part = swApp.ActiveDoc
Set Part = swApp.ActiveDoc
Dim myModelView As Object
Set myModelView = Part.ActiveView
myModelView.FrameLeft = 0
myModelView.FrameTop = 0
Set myModelView = Part.ActiveView
myModelView.FrameState = swWindowState_e.swWindowMaximized
Set myModelView = Part.ActiveView
myModelView.FrameState = swWindowState_e.swWindowMaximized

 

' Redraw
Part.GraphicsRedraw2
StudyManagerObj = Nothing
ActiveDocObj = Nothing
Set CWAddinCallBackObj = Nothing
Set COSMOSWORKSObj = Nothing
End Sub

Outcomes