Announcements
Notice: Upload of PDF documents is currently unavailable across the Community due to an ongoing issue.

Rename only circular pattern solids

Rename only circular pattern solids

manu.marjanen
Advocate Advocate
910 Views
7 Replies
Message 1 of 8

Rename only circular pattern solids

manu.marjanen
Advocate
Advocate

How can i rename only circular pattern solids?

for example, Circular pattern1 solid names from Part01...Part10

 

manumarjanen_0-1655205572403.png

 

 

 

0 Likes
911 Views
7 Replies
Replies (7)
Message 2 of 8

Michael.Navara
Advisor
Advisor

This renames newly created SurfaceBodies except the first one (source body)

Dim part As PartDocument = ThisDoc.Document
Dim circPattern = part.ComponentDefinition.Features.CircularPatternFeatures(1)
Dim i As Integer = 1
For Each surfBody As SurfaceBody In circPattern.SurfaceBodies
	surfBody.Name = String.Format("Part_{0:0#}", i)
	i += 1
Next
Message 3 of 8

manu.marjanen
Advocate
Advocate

Almost good.
Now, indeed, the first part does not get a new name.

Does anyone get the modified code so that the name of all the parts changes?

manumarjanen_0-1655212700238.png

 

0 Likes
Message 4 of 8

Curtis_W
Consultant
Consultant

Hi @Michael.Navara 

 

Try this update to Michael.Navara's example.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

Dim part As PartDocument = ThisDoc.Document
Dim circPattern = part.ComponentDefinition.Features.CircularPatternFeatures(1)
Dim i As Integer = 1
circPattern.Parent.SurfaceBodies.Item(1).Name = String.Format("Part_{0:0#}", i)
For Each surfBody As SurfaceBody In circPattern.SurfaceBodies
	i += 1
	surfBody.Name = String.Format("Part_{0:0#}", i)
Next

 

 

 

 EESignature

0 Likes
Message 5 of 8

manu.marjanen
Advocate
Advocate

The names of the first circular pattern change correctly.
But the name of the first part of the second circular pattern does not change.

manumarjanen_1-1655263416764.png

 

0 Likes
Message 6 of 8

A.Acheson
Mentor
Mentor

To add to the guys work this is why only the first pattern was targeted where (1) is the first in the CircularPatternFeatures collection. 

Dim circPattern = part.ComponentDefinition.Features.CircularPatternFeatures(1)

Here it is for all patterns just loop through the CircularPatternFeatures collection

Dim part As PartDocument = ThisDoc.Document
Dim i As Integer = 1
For Each circPattern As CircularPatternFeature In part.ComponentDefinition.Features.CircularPatternFeatures
	circPattern.Parent.SurfaceBodies.Item(1).Name = String.Format("Part_{0:0#}", i)
	For Each surfBody As SurfaceBody In circPattern.SurfaceBodies
		i += 1
		surfBody.Name = String.Format("Part_{0:0#}", i)
	Next 
Next

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 7 of 8

manu.marjanen
Advocate
Advocate

I want to rename different circular patterns with different names,  this does not work for it.

for example.

Circular pattern 1: Plate_1_01 ... Plate_1_10 (10 plates)

Circular pattern 2: Plate_2_01 ... Plate_2_05 (5 plates)

 

Can you edit the code to make it work this way?

0 Likes
Message 8 of 8

Curtis_W
Consultant
Consultant

Hi @manu.marjanen ,

 

Give this example a try.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

Dim part As PartDocument = ThisDoc.Document
Dim j As Integer = 1
For Each circPattern As CircularPatternFeature In part.ComponentDefinition.Features.CircularPatternFeatures
	Dim i As Integer = 1
	circPattern.Parent.SurfaceBodies.Item(1).Name = String.Format("Plate_" & j & "_{0:0#}", i)
	For Each surfBody As SurfaceBody In circPattern.SurfaceBodies
		i += 1
		surfBody.Name = String.Format("Plate_" & j & "_{0:0#}", i)
	Next
	j += 1
Next

 

 EESignature