Let me know if I am not going about this the right way.
I have an assembly and using ilogic to control the wide of the machine.
The wider machine has some different brackets which I am turning on and off by using "component . IsActive" in ilogic.
I had to make a new level of detail for it to work, and this is all fine except everytime I open this assembly it defaults back to master level of detail, so I always get this error.
Question
How do I control level of detail with ilogic or how am i suppose to turn parts on and off.
I have seen some impressive assemblies controlled with ilogic how do they do it.
Inventor 2012
Outside of iLogic, when you open the assembly, if you click the “Options” button in the open dialog you’ll have the opportunity to pick the LOD you want to have active when it opens the assembly file.
Please mark as a solution if this resolves this or let us know if you need more help. Thank you.
i Assume u have three different LOD's
Master, Cover & Base
and u have user parameter(Multi Value)
Lod = Master , cover & Base
u can this rule
Format:HTML Format
Version:1.0
StartHTML: 165
EndHTML: 6376
StartFragment: 314
EndFragment: 6344
StartSelection: 314
EndSelection: 314
IfLOD="Master"Then
ThisApplication.ActiveDocument.ComponentDefinition.RepresentationsManager.LevelofDetailRepresentations("Master").Activate
iLogicVb.UpdateWhenDone=True
ThisApplication.ActiveView.Fit
ElseIfLOD="Cover"Then
ThisApplication.ActiveDocument.ComponentDefinition.RepresentationsManager.LevelofDetailRepresentations("Cover").Activate
iLogicVb.UpdateWhenDone=True
ThisApplication.ActiveView.Fit
ElseIfLOD="Base"Then
ThisApplication.ActiveDocument.ComponentDefinition.RepresentationsManager.LevelofDetailRepresentations("Base").Activate
iLogicVb.UpdateWhenDone=True
ThisApplication.ActiveView.Fit
EndIf
This is an Example u can download and u can test it
open top level assy
in ilogic assy Browser on Forms tab click on Trigger button
http://www.mediafire.com/?5gtz12msdkddwhi
I tried to put your code into my assembly But I get this error which I don't know how to fix.
see attached
Never mind. I got it figuered out. There was one more spot I had to change your code which I missed.
Thanks for your help I would never have got it on my own.
Always keep reference of Inventor object module
Which saves lot of time for debugging
most of the code works here
http://usa.autodesk.com/adsk/servlet/index?id=1079044&siteID=123112
Hello!!
I have got the same problem as you do, but i can not manage how to solve it. What am I doing wrong?
Thanks in advance
I do it a little different, not to say that it’s the correct way but it works for me. I do not like to use the level of detail that much because I’m use to using different cad software. I use iLogic to turn off the visibility of the parts I don’t want then using iLogic make all invisible parts reference so they will not show up on my parts list. this way i don't make a level of detail. Here is some small code below:
'Making Ribs or Lug Visible - Non Visible
Rib = iProperties.Value("Custom", "Number Of Middle Ribs")
If Rib = "0" Then
Component.Visible("Middle Rib 1:1")=False
Component.Visible("Middle Rib 2:1")=False
Component.Visible("Middle Rib 3:1")=False
Component.Visible("Middle Rib 2:2")=False
Component.Visible("Middle Rib 3:2")=False
End If
If Rib = "1" Then
Component.Visible("Middle Rib 1:1")=True
Component.Visible("Middle Rib 2:1")=False
Component.Visible("Middle Rib 3:1")=False
Component.Visible("Middle Rib 2:2")=False
Component.Visible("Middle Rib 3:2")=False
End If
If Rib = "2" Then
Component.Visible("Middle Rib 1:1")=False
Component.Visible("Middle Rib 2:1")=True
Component.Visible("Middle Rib 3:1")=False
Component.Visible("Middle Rib 2:2")=True
Component.Visible("Middle Rib 3:2")=False
End If
' set a reference to the assembly component definintion.
' This assumes an assembly document is open.
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
'Iterate through all of the occurrences
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences
'check for and skip virtual components
If Not TypeOf oOccurrence.Definition Is VirtualComponentDefinition Then
'set BOM as default if the component is visible
If Component.Visible(oOccurrence.Name) = True Then
Component.InventorComponent(oOccurrence.Name).BOMStructure = _
BOMStructureEnum.kDefaultBOMStructure
'set BOM as reference if the component is not visible
ElseIf Component.Visible(oOccurrence.Name) = False Then
Component.InventorComponent(oOccurrence.Name).BOMStructure = _
BOMStructureEnum.kReferenceBOMStructure
End If
Else
End If
Next
I hope this helps in some kind of way.
Thanks
JD
I use this (attached) as an external rule. JD's method is completely valid as well, although I think I would code it a bit differently.
Thanks everyone for your fast answers!! It worked perfectly as an external rule.
I am new to this software, and this is the first time that I use an External Rule. I know iLogic it's not the best way to do it (with iAssemblies for example it would have much easier), but in this case it was compulsory.
Greetings,
CARLOS
Hello Ravi. I want to know where did you learn this code?
ThisApplication.ActiveDocument.ComponentDefinition.RepresentationsManager.LevelofDetailRepresentations("Master").Activate
It looks like object oriented programming since you are using member access.
Many thanks