Part Number

Part Number

Anonymous
Not applicable
789 Views
4 Replies
Message 1 of 5

Part Number

Anonymous
Not applicable

I want my browsername using iLogic particular change to the part number.
I fill in my iproperties, the part number.
Then the browser name has to take over the part number.

But i get an error.


Can someone help me out.

 

doc = ThisDoc.Document
Dim oCC As ComponentOccurrence
For Each oCC In doc.ComponentDefinition.Occurrences
OccName = oCC.Name
oCC.Name = iProperties.Value("Project", "Part Number")
Next

0 Likes
790 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable

You need to change this line of code :

 

oCC.Name = iProperties.Value(OccName, "Project", "Part Number")

 

Your previous code would be trying to set each occurence to the the Part Number of the document you are running the rule in, which would result in duplicate part numbers, which isn't allowed.

 

Hope this helps

 

Tom

0 Likes
Message 3 of 5

Anonymous
Not applicable
Spoiler
 

Thanks for the response.
I have an assy with three parts and then the rule works well for the parts.
The assy name dus not change!.
If I place the assy in anotherassy and make the rule in the assy and run the rule then I get an error and does the rule not work.

I have to edit or open the subassy and run the rule there.

0 Likes
Message 4 of 5

Anonymous
Not applicable

To change the browser node of the active document you'll need to add this at the end :

 

ThisDoc.Document.DisplayName = iProperties.Value("Project", "Part Number")

 

If you've got sub assemblies in your assembly you need to do another 'For Each' to get the components within that sub assembly. So if your tree looks like this :

 

Assembly

SubAssembly

Part

Part

Sub Assembly

Part

Part

Part

Part

 

This code will set the browser nodes of all components to their part numbers :

 

doc = ThisDoc.Document
Dim oCC As ComponentOccurrence

For Each oCC In doc.ComponentDefinition.Occurrences

	If oCC.Suppressed = False Then
		OccName = oCC.Name
		oCC.Name = iProperties.Value(OccName, "Project", "Part Number")
	End If
	
		For Each oCC2 As ComponentOccurrence In oCC.Definition.Document.ComponentDefinition.Occurrences
		
			If oCC2.Suppressed = False Then
				OccName2 = oCC2.Name
				oCC2.Name = iProperties.Value(OccName2, "Project", "Part Number")
			End If
			
		Next

Next

ThisDoc.Document.DisplayName = iProperties.Value("Project", "Part Number")

 

There is a good example of how to recursively traverse an assembly within the programming help in Inventor.

 

Hope this helps,

 

Tom

0 Likes
Message 5 of 5

Anonymous
Not applicable

Hi Tom


Thanks for your response

I use your code to the part numbers from the completed iproperties in my sub assy to persuade the browser node.

Thay works goodSmiley Very Happy


doc = ThisDoc.Document
Dim oCC As ComponentOccurrence
For Each oCC In doc.ComponentDefinition.Occurrences
OccName = oCC.Name
oCC.Name = iProperties.Value(oCC.Name, "Project", "Part Number")
ThisDoc.Document.DisplayName = iProperties.Value("Project", "Part Number")
Next


Now I have a code that fills in the iproperties.

But it fills in only one part.


pTitle = InputBox("Enter value for 'Part Number'", "Title",iProperties.Value("Project", "Part Number"))
If pTitle = Nothing Then Exit Sub
iProperties.Value("Project", "Part Number") = pTitle

Only now I want the three part numbers to fill in and the name of the assy must be a combination of the first part and third part.
The combination should be 720-08 in which the M of the third part M08 is to be left out.
This rule I use in my form where I can fill in the three part numbers for the iproperties be written.
I then want your first code to write the iproperties to the browser nodes and the combination of the two part numbers so that the assy name  arises.

 

I hope you can help me out.Smiley Very Happy



0 Likes