Hi all,
I have been provided with an assembly, containing sub-assemblies, by a sub-contractor. This assembly was originally created using Solidworks and then converted for use with Inventor (I don't know how and cannot request original files). As such the assembly is unconstrained and not grounded. I want to ground everything before having to alter the location of some valves.
Is there a way of grounding all parts, including those in sub-assemblies, from the top level assembly? Or do I have to open each sub-assembly and ground the associated parts from there?
Thanks in advance.
Solved! Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
Solved by Jakub.Szymanik. Go to Solution.
Solved by Telson.HADDEN4HGWS. Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
Hi!
You have to go to each one to ground the components (parts and sub-assemblys).
The good news is, the parts within the subassemblys only move when you're inside the sub-assembly not in the main assembly (Unless this sub-assembly has "Flexible" Status ON), so you can ground the sub-assembly's parts in the same time you need to edit them.
Did you find this reply helpful ? If so, use the Accept as Solution or Kudos - Thank you!
Window select all the components, assemblies, sub-assemblies, etc.. Right Click and select Grounded. You may have to repeat this twice.
Thanks for the response. I thought this might be the case but was hoping for a quicker way to ground everything at once. Oh well.
Regards
Lloyd
Hi LloydBrewer,
I use a simple iLogic rule to do this. You can find this rule at this link:
http://inventortrenches.blogspot.com/2012/05/working-with-unconstrained-imported.html
If you've not used iLogic before, here are a couple of links to get you started:
http://inventortrenches.blogspot.com/2012/01/creating-basic-ilogic-rule-with-event.html
http://autodeskmfg.typepad.com/blog/2012/01/working-with-external-ilogic-rules.html
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Hi Curtis_Waguespack,
Thanks for the links. The iLogic rule worked perfectly. I've been meaning to read up on iLogic for a while, maybe this will be the prod I need!
Many thanks
Lloyd
Necro post - but here's a routine that will recursively loop through ALL subassemblies and ground EVERYTHING
Sub main
userResponse = MsgBox("This will ground ALL parts & subassemblies in ALL" & vbCrLf & _
"parts and subassemblies in this assembly, are you sure you want to continue?" & vbCrLf & _
"ALL FILES MUST BE CHECKED OUT", vbYesNo, "Ground Everything")
If userResponse = 1 Or userResponse = 6 Then 'Ok, or Yes
'ground parts in this file, begin recursion
sDefLoop(ThisDoc.Document)
RuleParametersOutput()
iLogicVb.UpdateWhenDone = True
ThisDoc.Document.Update
End If
End Sub
Sub sDefLoop(oCurrentDoc As Document)
Dim oAsmDoc As AssemblyDocument
Dim oOcc As ComponentOccurrence
'Select based on file type, this exists to cast to the correct object type before calling the appropriate sub program
Select Case oCurrentDoc.DocumentType
Case DocumentTypeEnum.kAssemblyDocumentObject 'it's an assembly file
oAsmDoc = oCurrentDoc
oAsmDoc.ComponentDefinition.RepresentationsManager.LevelOfDetailRepresentations.Item("Master").activate 'activate master LoD
For Each oOcc In oAsmDoc.ComponentDefinition.Occurrences 'loop through all of occurrences in this assembly file
If Not TypeOf oOcc.Definition Is VirtualComponentDefinition Then oOcc.Grounded = True 'if it's a real part, ground it
Next
For Each oDoc In oAsmDoc.AllReferencedDocuments 'loop through all of the sub-assemblies, this is recursive
sDefLoop(oDoc)
Next
Case Else
Exit Sub 'if it's not an assembly, what are you even going to do?
End Select
End Sub
I use this kind of short formula for foreign STEP models and it works fine:
Sub Main() oDoc = ThisDoc.Document For Each oOcc In oDoc.ComponentDefinition.Occurrences SubGroundedOn(oOcc) Next End Sub Sub SubGroundedOn(oToGrounded) oToGrounded.Grounded = True For Each oOccSub In oToGrounded.SubOccurrences SubGroundedOn(oOccSub) Next End Sub
If have virtual components or something I guess you will just have to use Catch Try between the SubGroundedOn(oOccSub)?
Could you edit the iLogic rule so it can Un-block all existing components?
Appreciate your help.
Radu
@RStancescu, I'm not sure I understand the request.
Can you provide a bit more detail about how you'd like it to work?
If so I can likely update it to your needs.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Thank you for answering.
After I open an assembly, would like to run a rule or click a button that will un-ground all the grounded parts in the iam; eventually telling me that there are 200 grounded parts. (like a warning)
Or, after running the rule, to automatically select all the grounded components; and then I can manually right click and un-ground them.
Appreciate your support.
Radu
Thank you for answering, @Curtis_Waguespack
After I open an assembly, would like to run a rule or click a button that will un-ground all the grounded parts in the iam; eventually telling me that there are 200 grounded parts. (like a warning)
Or, after running the rule, to automatically select all the grounded components; and then I can manually right click and un-ground them.
Appreciate your support.
Radu
Hi @RStancescu ,
See this example.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Sub Main oOccs = ThisDoc.Document.ComponentDefinition.Occurrences count = oOccs.count If count > 100 Then sMsg = "Whoa there cowboy!" & vbLf _ & "There are " & count & " components in this here assembly." & vbLf _ & "This could take a little while, are you sure you want to pull that trigger? ." oInput = MessageBox.Show(sMsg, "iLogic", MessageBoxButtons.YesNo) If oInput = vbNo Then Exit Sub End If End If Call TraverseAssembly(ThisDoc.Document.ComponentDefinition.Occurrences) End Sub Function TraverseAssembly(oOccs As ComponentOccurrences) Dim oOcc As ComponentOccurrence For Each oOcc In oOccs oOcc.Grounded = False If oOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then Call TraverseAssembly(oOcc.Definition.Document.ComponentDefinition.Occurrences) End If Next End Function
Thank you for your code. @Curtis_Waguespack
It works fine if there is no pattern in the assembly.
With a pattern, I get the attached notification when running the rule. Could you please look at it?
After closing the error, everything is good, no grounded components.
Thank you.
Radu
@RStancescu wrote:
It works fine if there is no pattern in the assembly.
doh! 😬
It's always the patterns that are the trouble makers. 🙄
Give this version a try. It will catch the error when a pattern is encountered, and move on.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Sub Main oOccs = ThisDoc.Document.ComponentDefinition.Occurrences count = oOccs.count If count > 100 Then sMsg = "Whoa there cowboy!" & vbLf _ & "There are " & count & " components in this here assembly." & vbLf _ & "This could take a little while, are you sure you want to pull that trigger? ." oInput = MessageBox.Show(sMsg, "iLogic", MessageBoxButtons.YesNo) If oInput = vbNo Then Exit Sub End If End If Call TraverseAssembly(ThisDoc.Document.ComponentDefinition.Occurrences) End Sub Function TraverseAssembly(oOccs As ComponentOccurrences) Dim oOcc As ComponentOccurrence For Each oOcc In oOccs Try : oOcc.Grounded = False: Catch : End Try If oOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then Call TraverseAssembly(oOcc.Definition.Document.ComponentDefinition.Occurrences) End If Next End Function
Thank you @Curtis_Waguespack
That works great! I copied the other rule two so now my users have all the choices.
Appreciate your support and let me know if you need any help.
Radu
Hi @RStancescu
If you want to give your users an option to ground or unground, you could use this version.
Note too that this version grounds/ungrounds the components in subassemblies too.
Sub Main oOccs = ThisDoc.Document.ComponentDefinition.Occurrences oInput = InputRadioBox("Select one", "Ground All", "Unground All", True,"iLogic") Call TraverseAssembly(ThisDoc.Document.ComponentDefinition.Occurrences, oInput) End Sub Function TraverseAssembly(oOccs As ComponentOccurrences, oInput As Boolean) Dim oOcc As ComponentOccurrence For Each oOcc In oOccs Try : oOcc.Grounded = oInput : Catch : End Try If oOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then Call TraverseAssembly(oOcc.SubOccurrences, oInput) End If Next End Function
That is cool!
I was ready to present to my users two rules but this last one is better.
Great work and appreciate your work!
Radu
Thanks. This code works.
How many levels will it go down to?
Will it reach all sub-levels?
Regards
Parag
Can't find what you're looking for? Ask the community or share your knowledge.