Sheet metal rule changed from Top level assembly

Sheet metal rule changed from Top level assembly

esaldana
Enthusiast Enthusiast
324 Views
2 Replies
Message 1 of 3

Sheet metal rule changed from Top level assembly

esaldana
Enthusiast
Enthusiast

Can any of you point me to a rule that could do a change sheet metal rule from a top-level assembly?

 

I have several components with a sheet metal rule called: "16GA 304-5WL"

I need to change those to a new sheet metal rule called: "16GA 304-4"

 

The rule would give me the option to select/indicate the old sheet metal rule name and place/write down the new rule name wanted, the rule will have to go to the top and sub-assemblies, find the parts with the old sheet metal rule, and change their metal rule with the new selected one.

It sounds complicated but I'm sure for some of you this is a piece of cake.

 

I would appreciate any help into this,

 

Thanks,


Eric

0 Likes
Accepted solutions (1)
325 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor
Accepted solution

Hi @esaldana.  Here is some iLogic code to get you started with that project.  It is relatively basic right now, but can be developed further, as needed.

Sub Main
	Dim oADoc As AssemblyDocument = TryCast(ThisDoc.Document, Inventor.AssemblyDocument)
	If oADoc Is Nothing Then Return
	Dim oRefDocs As DocumentsEnumerator = oADoc.AllReferencedDocuments
	If oRefDocs.Count = 0 Then Return
	'<<< EDIT THESE NAMES AS REQUIRED >>>
	Const sOldSheetMetalStyleName As String = "16GA 304-5WL"
	Const sNewSheetMetalStyleName As String = "16GA 304-4"
	For Each oRefDoc As Inventor.Document In oRefDocs
		'check if it is a Sheet Metal part.  If not, skip to next referenced document
		If oRefDoc.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then Continue For
		Dim oSMDoc As PartDocument = oRefDoc
		Dim oSMDef As SheetMetalComponentDefinition = oSMDoc.ComponentDefinition
		'check if it is set to a specific SheetMetalStyle by name
		If oSMDef.ActiveSheetMetalStyle.Name = sOldSheetMetalStyleName Then
			Try
				oSMDef.SheetMetalStyles.Item(sNewSheetMetalStyleName).Activate
			Catch
				Logger.Error("Error activating specified SheetMetalStyle.")
			End Try
		End If
		If oRefDoc.RequiresUpdate Then oRefDoc.Update2(True)
	Next 'oRefDoc
	If oADoc.RequiresUpdate Then oADoc.Update2(True)
End Sub

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

esaldana
Enthusiast
Enthusiast

Really thankful,

You call it basic, but to me is like 'magic' 🙂

it worked perfectly well.

 

Thanks for your time and help,

 

Eric

0 Likes