Model state declaration in inventor 2024

Model state declaration in inventor 2024

Ahmed.shawkyXTZHN
Enthusiast Enthusiast
241 Views
1 Reply
Message 1 of 2

Model state declaration in inventor 2024

Ahmed.shawkyXTZHN
Enthusiast
Enthusiast

Hi everyone , recently we upgrade inventor from 2020 to 2024 so there was some programs using the below code line , which  "ilogic" now is coming under the model state not under representations and that's affecting on the BOM it gives QTY from Primary , can we update the below code.

AhmedshawkyXTZHN_1-1709192319885.png

 

"

Dim doc As AssemblyDocument = ThisDoc.Document  
Dim oLOD As LevelOfDetailRepresentation  
Dim oAsmCompDef As ComponentDefinition  
oAsmCompDef = doc.ComponentDefinition 
Try 
oLOD = oAsmCompDef.RepresentationsManager.LevelOfDetailRepresentations.Item("iLogic").Activate(True)
Catch
Dim nLOD As LevelOfDetailRepresentation
nLOD = oAsmCompDef.RepresentationsManager.LevelOfDetailRepresentations.Add("iLogic")
oLOD = nLOD
Finally
oLOD = oAsmCompDef.RepresentationsManager.LevelOfDetailRepresentations.Item("iLogic").Activate(True)
End Try
"

 

0 Likes
242 Views
1 Reply
Reply (1)
Message 2 of 2

Jacob__with__a__k
Enthusiast
Enthusiast

Hi! 

 

I recommend to not use LevelOfDetailRepresentations anymore, since the level of details are removed from Inventor, we only have Model States and View Representations

 

you can use following code to activate a view representation or add one:

Try
	oDoc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations.Item("Default").Activate
Catch
	oDoc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations.Add("Default")
End Try

 

and following to activate a model state or add one

Try
	oDoc.ComponentDefinition.ModelStates.ActiveModelState = "Default"
Catch
	oDoc.ComponentDefinition.ModelStates.Add("Default")
End Try

 

just replacing "LevelOfDetailRepresentation" with "DesignViewRepresentations" should also be enough to fix your code

 

Happy coding!

0 Likes