Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Ground all parts in an assembly

19 REPLIES 19
SOLVED
Reply
Message 1 of 20
LloydBrewer
5163 Views, 19 Replies

Ground all parts in an assembly

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.

Tags (2)
19 REPLIES 19
Message 2 of 20
CCarreiras
in reply to: LloydBrewer

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  Mark Solutions!  Accept as Solution or Give Kudos!Kudos - Thank you!

 

 

CCarreiras

EESignature

Message 3 of 20
GSE_Dan_A
in reply to: LloydBrewer

Window select all the components, assemblies, sub-assemblies, etc.. Right Click and select Grounded.  You may have to repeat this twice.

GSE Consultants Inc.
Windsor, ON. Canada
Message 4 of 20
LloydBrewer
in reply to: CCarreiras

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

Message 5 of 20
blair
in reply to: LloydBrewer

In the Brower Window, you can select the first items, then hold down the "Shift" key and then select the last item. This will select all the items between the two selected items.

Inventor 2020, In-Cad, Simulation Mechanical

Just insert the picture rather than attaching it as a file
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
Delta Tau Chi ΔΤΧ

Message 6 of 20

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

Message 7 of 20

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

Message 8 of 20

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
Message 9 of 20

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)?

Message 10 of 20

Hi @Curtis_Waguespack 

 

Could you edit the iLogic rule so it can Un-block all existing components?

Appreciate your help.

Radu

Message 11 of 20

@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

 

Message 12 of 20

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

Message 13 of 20

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

Message 14 of 20

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 

 

Message 15 of 20

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

 

Message 16 of 20


@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 

 

Message 17 of 20

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

Message 18 of 20

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 

 

Message 19 of 20

@Curtis_Waguespack 

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

Message 20 of 20
P_Korgaonkar
in reply to: LloydBrewer

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.

Post to forums  

Autodesk Design & Make Report