Updating Mass Properties with iLogic and Custom LOD - Suppress dialog box

Updating Mass Properties with iLogic and Custom LOD - Suppress dialog box

llorden4
Collaborator Collaborator
633 Views
0 Replies
Message 1 of 1

Updating Mass Properties with iLogic and Custom LOD - Suppress dialog box

llorden4
Collaborator
Collaborator

In creating assemblies that are pre-built and customized using suppression states for various components for a final assembly, I'm trying to correctly update the mass properties and have almost worked through all the issues, and I think only one remains.

 

My iLogic will first activate the Master LOD to and identify each component and assign it's name to a variable so that the suppression state can be called later in the routines, if a part is currently suppressed then the component cannot be found so switching to the Master LOD solves this issue for me since everything is unsuppressed in this LOD.

 

Calling for a mass properties update prior to restoring a different LOD that has suppressed items will result in a (Exception from HRESULT: 0x80004005 (E_FAIL)) error.

 

Restoring the the custom LOD and then calling for the mass property update eliminates my error but then "sometimes" provides and additional pop-up dialog box asking whether to update to the Master LOD or to the active LOD.  Obviously I want the active LOD but since this box appears randomly (or at least I haven't identified the conditions which force its appearance), handling it is a challenge.

LOD Dialog boxLOD Dialog box

 

Since I won't know the various dialog presentation states stored on each station that will use these assemblies, any ideas on how to force the active LOD to be used always and prevent this dialog box outright?

 

A sample of my iLogic code is currently....

Sub Main
Dim oDoc As AssemblyDocument = ThisDoc.Document
oDoc.DisplayName = iProperties.Value("Project", "Part Number")
Dim oAsmCompDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Item("Master").Activate
oAsmCompDef.RepresentationsManager.LevelOfDetailRepresentations.Item("Master").Activate(True)

Dim tComps As ComponentOccurrences = oDoc.ComponentDefinition.Occurrences
Dim Shaft As String = nil
Dim Shaft2Many As Boolean = False

For Each tComp As ComponentOccurrence In tComps																		'assumes shaft tubes are not suppressed
	Try
	If Left(iProperties.Value(tComp.Name,"Custom","Smart Number"),4) = "SH01" And Shaft <> nil Then Shaft2Many = True	'flag as more than one shaft is present if more than one found
	If Left(iProperties.Value(tComp.Name,"Custom","Smart Number"),4) = "SH01" And Shaft = nil Then Shaft = tComp.Name	'store part filename of first found shaft component
	Catch
	End Try
Next

Try
	If Not Shaft2Many And Shaft <> nil Then
		NoSides = Parameter(Shaft,"NoSides")
		TopDia = Parameter(Shaft,"TopDia")
		BotDia = Parameter(Shaft,"BotDia")
		ShaftLength = Parameter(Shaft,"ShaftLength")
	End If
Catch
End Try

'<mass update here creates error>
'Set desired Rep & LOD Try oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Item("View1").Activate Catch oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Add("View1") End Try Try oDoc.ComponentDefinition.RepresentationsManager.LevelOfDetailRepresentations("LevelofDetail1").Activate(True) Catch oDoc.ComponentDefinition.RepresentationsManager.LevelOfDetailRepresentations.Add("LevelofDetail1") End Try 'Mass properties update ThisApplication.CommandManager.ControlDefinitions.Item("AppUpdateMassPropertiesCmd").Execute
'
'
'
End Sub

 

Autodesk Inventor Certified Professional
0 Likes
634 Views
0 Replies
Replies (0)