Renumber occurrence number

Renumber occurrence number

CCarreiras
Mentor Mentor
817 Views
1 Reply
Message 1 of 2

Renumber occurrence number

CCarreiras
Mentor
Mentor

The objective is to create a unique number for each part in an assembly, even if the part is repeated in the assembly by adding the same part several times or creating a pattern.

With part number that is impossible, since the same part when repeated, will have always the same part number.

 

I thaiught to do that by having a different occurrence number for each part in the assembly.

 

It's possible to renumber the occurrence number like the image below and catch that number as a custom parameter?

 

1.png

Thank you, regards.

CCarreiras

EESignature

0 Likes
818 Views
1 Reply
Reply (1)
Message 2 of 2

pball
Mentor
Mentor

This is mostly possible. Changing the occurrence number on the components in the current level assembly is easy. Changing the numbers in the sub-assemblies isn't as straight forward and might not be possible or at least feasible. Also changing the numbers on a sub-assembly would affect how they appear when opening that assembly by itself.

 

This code renumbers all of the current assembly level occurrences to be sequential numbers. Do note the elements of a pattern do not seem to be editable but the parts under each element can be modified. This is iLogic code.

Dim oAssyDoc As AssemblyDocument = ThisApplication.ActiveEditDocument
Dim num As Integer = 1
Dim oOcc As ComponentOccurrence
For Each oOcc In oAssyDoc.ComponentDefinition.Occurrences
	Try
		oOcc.Name = oOcc.Name.Split(":")(0) & ":" & num
	Catch ex As Exception

	End Try
	num += 1
Next

oAssyDoc.Update()

 

I don't completely follow what you mean by catching the occurrence number as a custom parameter. If you mean at the part level that won't work well since if you have multiple parts in an assembly that part would have multiple occurrence numbers assigned to it and if that part is used in an another assembly it would have different values there.

Check out my style edits for the Autodesk forums
pball's Autodesk Forum Style
0 Likes