is it possible to export in STEP all model state starting from .idw Drawind using Ilogic?

is it possible to export in STEP all model state starting from .idw Drawind using Ilogic?

lukieg66
Participant Participant
162 Views
2 Replies
Message 1 of 3

is it possible to export in STEP all model state starting from .idw Drawind using Ilogic?

lukieg66
Participant
Participant

Here is actally a code but I can't find a way to access to a ModelState from a Drawing document.

	    ' Export STEP
	    oSTEPData.FileName = oPDFFolder & "\" & oFileName & oRevString & ".stp"
	    oSTEPAddIn.SaveCopyAs(oDocument, oSTEPContext, oSTEPOptions, oSTEPData)		

I would like to cycle throug the sheet and export the referenced modelstate in step format using the SaveCopyAs metod.

 Thank you so much 

0 Likes
Accepted solutions (1)
163 Views
2 Replies
Replies (2)
Message 2 of 3

ryan.rittenhouse
Advocate
Advocate
Accepted solution

Accessing model states from the print can get a little wonky - I've found it works better if you open the document in the background when you're trying to change them. Here's some basic code that'll open it in the background and loop through the model states for you.

 

'Open document in the background
Dim modelDocument As AssemblyDocument = ThisServer.Documents.Open(fileName, False)
'Get the name of the current model state
Dim currentModelStateName As String = modelDocument.ModelStateName

'Loop through all the model staets in the model
For Each mState As ModelState In modelDocument.ComponentDefinition.ModelStates
	Try
		mState.Activate()
		
		'Export file here
		
	Catch ex As Exception
		Logger.Error("Error on model state " & mState.Name)
		Logger.Error(ex.Message)
	End Try
Next mState

'activate the original model state
modelDocument.ComponentDefinition.ModelStates(modelStateName).Activate
'close the model document
modelDocument.Close()
If this solved your problem, or answered your question, please click Accept Solution.
Message 3 of 3

lukieg66
Participant
Participant

Thank you very much for your help, it was usefull...

LG

0 Likes