I'm trying to use iLogic while making a conveyor rail. If the rail is under 60in, I don't need supports. I keep getting "End of statement expected" as an error. What am I doing wrong or how should this be phrased other than how I have it?
Solved! Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
Hi ASchlaack,
I think you'll need a space between 60 and in:
60 in
rather than:
60in
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Thanks, I did that which cleared line one's error BUT still have the ones on line 9. Any other ideas?
Hi ASchlaack,
I think you need an Else If on that line. Try something like this example:
If Parameter("Rail_Length") < 60 in Then MessageBox.Show("not quite 60", "iLogic") Else If Parameter("Rail_Length") >= 60 in Then MessageBox.Show("60 or more", "iLogic") Else 'this Else is optional End If
Here is a better example of an Else (without If) in use, in case it helps:
If Parameter("Rail_Length") < 60 in Then MessageBox.Show("not quite 60", "iLogic") Else If Parameter("Rail_Length") > 60 in Then MessageBox.Show("over 60", "iLogic") Else MessageBox.Show("I guess it must be 60!", "iLogic") End If
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Thank you, I ended up getting it with this (Rule posted below) I also added two other pieces to supress.
I am now getting this error though:
Error in rule: Rule0, in document: Assembly2
Component.IsActive: Cannot change the suppression state of component TEST-Horizontal-FlangeAngleL:3.
The active Level of Detail in Assembly2 is not a custom Level of Detail.
Rule that worked:
If Parameter("TEST8-Horizontal-Rail1201:1", "d19") < 60 in Then
Component.IsActive("TEST-Horizontal-FlangeAngleL:3")=False
Component.IsActive("TEST-Horizontal-FlangeAngleL:4")=False
Component.IsActive("TEST-Horizontal-FlangeAngleR:4")=False
Component.IsActive("TEST-Horizontal-FlangeAngleR:3")=False
Else
Component.IsActive("TEST-Horizontal-FlangeAngleL:3")=True
Component.IsActive("TEST-Horizontal-FlangeAngleL:4")=True
Component.IsActive("TEST-Horizontal-FlangeAngleR:4")=True
Component.IsActive("TEST-Horizontal-FlangeAngleR:3")=True
EndIf
Hi ASchlaack,
So in order to suppress something in Inventor using iLogic you must have a Level of Detail that can be edited, set active in the assembly. Most often we use a snippet of code to look for an existing "iLogicLOD", and then create it, should it not be found. Once the "iLogicLOD" is set active, you can have your rule suppress parts as needed.
Here's a quick example:
'define the document
Dim oDoc as AssemblyDocument
oDoc = ThisDoc.Document
'define the LOD
Dim oLOD As LevelOfDetailRepresentation
'define the assembly component definition
Dim oACDef As ComponentDefinition
oACDef = oDoc.ComponentDefinition
Try
'try to activate the iLogic LOD
oLOD = oACDef.RepresentationsManager. _
LevelOfDetailRepresentations.Item("iLogicLOD").Activate(True)
Catch
'catch error when iLogic LOD doesn't exist
'and then create it
oLOD = oACDef.RepresentationsManager. _
LevelOfDetailRepresentations.Add("iLogicLOD")
'activate the newly created iLogic LOD
oLOD = oACDef.RepresentationsManager. _
LevelOfDetailRepresentations.Item("iLogicLOD").Activate(True)
End Try 'look at parameter and suppress components 'if the parameter is less than 60 inches If Parameter("TEST8-Horizontal-Rail1201:1", "d19") < 60 in Then Component.IsActive("TEST-Horizontal-FlangeAngleL:3")=False Component.IsActive("TEST-Horizontal-FlangeAngleL:4")=False Component.IsActive("TEST-Horizontal-FlangeAngleR:4")=False Component.IsActive("TEST-Horizontal-FlangeAngleR:3")=False Else Component.IsActive("TEST-Horizontal-FlangeAngleL:3")=True Component.IsActive("TEST-Horizontal-FlangeAngleL:4")=True Component.IsActive("TEST-Horizontal-FlangeAngleR:4")=True Component.IsActive("TEST-Horizontal-FlangeAngleR:3")=True End If
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Thank you Curtis!
Hi @Curtis_Waguespack ,
How would I do the exact same for a DesignViewRepresentation?
I tried to just replace LOD with ViewRep, but get this error. "Public member 'Activate' on type 'DesignViewRepresentation' not found."
'define the document Dim oDoc As AssemblyDocument oDoc = ThisDoc.Document 'define the VIEW Dim oVIEW As DesignViewRepresentation 'define the assembly component definition Dim oACDef As ComponentDefinition oACDef = oDoc.ComponentDefinition Try 'try to activate the iLogic VIEW oVIEW = oACDef.RepresentationsManager. _ DesignViewRepresentations.Item("iLogicVIEW").Activate(True) Catch 'catch error when iLogicVIEW doesn't exist 'and then create it oVIEW = oACDef.RepresentationsManager. _ DesignViewRepresentations.Add("iLogicVIEW") 'activate the newly created iLogicVIEW oVIEW = oACDef.RepresentationsManager. _ DesignViewRepresentations.Item("iLogicVIEW").Activate(True) End Try
This creates a ViewRep, but does so every time the rule runs, then gives the error.
Regards
Theo
Hi @tjvz85 ,
I didn't look to see what the differences between the LOD and VReps were but here is an example that works:
'define the document Dim oDoc As AssemblyDocument oDoc = ThisDoc.Document 'define the VIEW Dim oVIEW As DesignViewRepresentation 'define the assembly component definition Dim oACDef As ComponentDefinition oACDef = oDoc.ComponentDefinition Try 'try to activate the iLogic VIEW oVIEW = oACDef.RepresentationsManager. _ DesignViewRepresentations.Item("iLogicVIEW").Activate Catch 'catch error when iLogicVIEW doesn't exist 'and then create it oVIEW = oACDef.RepresentationsManager. _ DesignViewRepresentations.Add("iLogicVIEW") End Try
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
hanks @Curtis_Waguespack , always appreciate your input.
I have a product that I would like to show various configs via a form in the main assembly. I find it works faster if I rather set ViewReps instead of LOD's.
I have a rule in the main sub assembly that works fine when that file is opened explicitly. Then the rule in the top assemblies has a line that runs the rule in the sub assembly, but nothing happens.
Rule in Sub Assy:
'define the document Dim oDoc As AssemblyDocument oDoc = ThisDoc.Document 'define the VIEW Dim oVIEW As DesignViewRepresentation 'define the assembly component definition Dim oACDef As ComponentDefinition oACDef = oDoc.ComponentDefinition 'look at parameter and set VReps 'Klappe/Standard options Select Case Parameter("OPTIONEN") Case ("1. STANDARD") oVIEW = oACDef.RepresentationsManager. _ DesignViewRepresentations.Item("1. STANDARD").Activate Case ("2. KLAPPE") oVIEW = oACDef.RepresentationsManager. _ DesignViewRepresentations.Item("2. KLAPPE").Activate End Select
Rule in Top Assy
'Parameter from Assembly to Sub Components Parameter("EA2314.010000 ZBG Mäher Grundgehäuse:1", "OPTIONEN") = OPTIONEN iLogicVb.RunRule("EA2314.010000 ZBG Mäher Grundgehäuse:1", "Konfigurationen") 'Optionen: Standard/Klappe Select Case Parameter("OPTIONEN") Case ("1. STANDARD") Component.Visible("EA2314.080000 ZBG Klappe:1") = False Case ("2. KLAPPE") Component.Visible("EA2314.080000 ZBG Klappe:1") = True End Select 'define the document Dim oDoc As AssemblyDocument oDoc = ThisDoc.Document 'define the VIEW Dim oVIEW As DesignViewRepresentation 'define the assembly component definition Dim oACDef As ComponentDefinition oACDef = oDoc.ComponentDefinition 'look at parameter and toggle visibility components 'Befestigung Options Select Case Parameter("BEFESTIGUNG") Case "1. STARR" 'set VRep oVIEW = oACDef.RepresentationsManager. _ DesignViewRepresentations.Item("1. STARR").Activate Case "2. PRLG" 'set VRep oVIEW = oACDef.RepresentationsManager. _ DesignViewRepresentations.Item("2. PRLG").Activate Case "3. 3-PUNKT" 'set Vrep oVIEW = oACDef.RepresentationsManager. _ DesignViewRepresentations.Item("3. 3-PUNKT").Activate Case "4. A-RAHM" 'set Vrep oVIEW = oACDef.RepresentationsManager. _ DesignViewRepresentations.Item("4. A-RAHM").Activate End Select
It there a way to rather set the sub assy VRep from the top assy rule, instead of having a second rule? Or what is wrong that the sub assy does not adjust when its rule is run from top assy rule?
Any assistance appreciated.
Theo
Hi @tjvz85
I think this will answer your questions, post back if not.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
oViewName = "iLogicVIEW" Dim oVIEW As DesignViewRepresentation 'get the subassembly component occurence Dim oOcc = Component.InventorComponent("Test1:1") 'define the assembly component definition Dim oACDef As ComponentDefinition oACDef = oOcc.Definition.Document.ComponentDefinition Try 'Try To get the iLogic View oVIEW = oACDef.RepresentationsManager. _ DesignViewRepresentations.Item(oViewName) Catch 'catch error when iLogicVIEW doesn't exist 'and then create it oVIEW = oACDef.RepresentationsManager. _ DesignViewRepresentations.Add(oViewName) End Try 'activate it oOcc.SetDesignViewRepresentation(oViewName,, True)
Works like a charm
Dim oVIEW As DesignViewRepresentation
'get the subassembly component occurence
Dim oOcc = Component.InventorComponent("EA2314.010000 ZBG Mäher Grundgehäuse:1")
'define the assembly component definition
Dim oOCDef As ComponentDefinition
oOCDef = oOcc.Definition.Document.ComponentDefinition
'Parameter in top level, chain or klappe
Select Case Parameter("OPTIONEN")
Case ("1. STANDARD")
'activate vrep in sub assembly
oOcc.SetDesignViewRepresentation("1. STANDARD", , True)
Case ("2. KLAPPE")
'activate vrep in sub assembly
oOcc.SetDesignViewRepresentation("2. KLAPPE", , True)
End Select