[oPartDocument API] How to edit rectangularpattern and add a new feature in

[oPartDocument API] How to edit rectangularpattern and add a new feature in

tomas.pascual
Enthusiast Enthusiast
158 Views
2 Replies
Message 1 of 3

[oPartDocument API] How to edit rectangularpattern and add a new feature in

tomas.pascual
Enthusiast
Enthusiast

Hi Sirs,

I'm trying to edit an existing pattern in a oPartDoc and add a new feature.

Since now I have not been able to do it.

Some idea wellcome

Thanks,

 

 

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

ryan.rittenhouse
Advocate
Advocate
Accepted solution

You can do this by pulling the object collection out of the existing pattern, adding the new features to the collection, then putting it back in the pattern definition. The code below should work if you change the patternName and featureName to what you are using - with the option to hand it a Document that you already have, just use that in place of partDoc.

 

Dim patternName As String = "Bracket Pattern"
Dim featureName As String = "New Feature"
Dim partDoc As PartDocument = ThisDoc.Document
Dim partDef As PartComponentDefinition = partDoc.ComponentDefinition
Dim patternDef As RectangularPatternFeatureDefinition = partDef.Features.RectangularPatternFeatures(patternName).Definition
Dim patternFeatures As ObjectCollection = patternDef.ParentFeatures
Dim newFeature As PartFeature = partDef.Features(featureName)
patternFeatures.Add(newFeature)
patternDef.ParentFeatures = patternFeatures

.

 

If this solved your problem, or answered your question, please click Accept Solution.
0 Likes
Message 3 of 3

tomas.pascual
Enthusiast
Enthusiast

Vualá Ryan, amazing !!!
I was spending 6h or more.

Thanks,

 

0 Likes