September 1, 2016

Posted on September 1, 2016 by Synergis Manufacturing Applications Consultant, Dave Breiner

Because of the nature of my work, I often have the need to search for already built 3D components to add to a model or assembly. I usually go to GrabCAD to help with this search. If I find something that will help it is often in a format other than ipt or iam. With the adoption of Autodesk Inventor AnyCAD importer, this is no longer the headache it once was. When you open a STEP, Catia, Solidworks or one of the several other formats, AnyCAD performs the automatic conversion to Inventor parts and assemblies. While this is all great and wonderful, it is not the focus of this article.
Once you have the file converted to an Inventor format, you still have issues. The biggest is that the model is totally unconstrained.Ucon 1Uncon 2
You can move any part by clicking on a part and dragging across the screen.
This really doesn’t work for me! I use to try to apply constraints to hold the parts in place or ground them one at a time but this was very time-consuming and counterproductive. I started looking for an alternative and found one on Curtis Waguespack’s website. Curtis does some amazing work, especially with iLogic. I use many of his solutions for a wide range of issues.
Curtis developed an iLogic rule that will ground all parts in place. This works well for me since I usually do not have moving parts in my assembly. For the example above, I would run the rule and ground all parts, then unground any to which I would like to apply any specific constraints or joints.
Below and linked is the iLogic code developed by Curtis Waguespack. In the model above, I created a rule and pasted the code into that rule. It worked the first time and as described.
If you work with imported models, this can be a real time saver for you.
‘start of ilogic code
 ‘get user input
 qGround = InputRadioBox(“Select one:”, “Ground”, “Un-Ground”, True, “ilogic”)
‘get the active assembly
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
‘set the Master LOD active
Dim oLODRep As LevelofDetailRepresentation
oLODRep = oAsmCompDef.RepresentationsManager.LevelOfDetailRepresentations.Item(“Master”)
‘Iterate through all of the top level occurrences
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences
If oOccurrence.DefinitionDocumentType = _
DocumentTypeEnum.kAssemblyDocumentObject Then
                             ‘Iterate through all of the 2nd level occurrences
                                    Dim oSub1Occ As ComponentOccurrence
For Each oSub1Occ In oOccurrence.SubOccurrences
‘ground everything in the 2nd level   
                                    oSub1Occ.Grounded = qGround
If oSub1Occ.DefinitionDocumentType = _
DocumentTypeEnum.kAssemblyDocumentObject Then
                                                  ‘Iterate through all of the 3nd level occurrences
                                                Dim oSub2Occ As ComponentOccurrence
For Each oSub2Occ In oSub1Occ.SubOccurrences
‘ground everything in the 3rd level    
                                                oSub2Occ.Grounded = qGround
                                      End If
                   End If
          ‘ground everything in the top level    
            oOccurrence.Grounded = qGround
‘ end of ilogic code