SketchDrivenPattern - Create new bodies

jiri.paur
Participant
Participant

SketchDrivenPattern - Create new bodies

jiri.paur
Participant
Participant

Hello!

I am not able to find out how to set "Create new bodies" for a sketch driven patter via API.

 

jiripaur_0-1714981917200.png

 

I have tried the following without success:

 

    'add solid to collection
    Dim colSolid, As ObjectCollection
    Set colSolid, = ThisApplication.TransientObjects.CreateObjectCollection
    colSolid,.Add oShell.SurfaceBodies.Item(1)
    
    'sketch pattern
    Dim oPtnDef As SketchDrivenPatternDefinition
    Set oPtnDef = oPartDef.Features.SketchDrivenPatternFeatures.CreateDefinition(colSolid, oSketch)
    oPtnDef.Operation = kNewBodyOperation

    Dim oPtn As SketchDrivenPatternFeature
    Set oPtn = oPartDef.Features.SketchDrivenPatternFeatures.Add(oPtnDef)

 

 

Any suggestion where I do mistake?

 

Thank you!

 

Best regards

Jiri

0 Likes
Reply
Accepted solutions (1)
228 Views
2 Replies
Replies (2)

Michael.Navara
Advisor
Advisor
Accepted solution

I'm not sure this is bug or feature, but you can set the operation of existing pattern and the result is as expected

 

Dim part As PartDocument = ThisDoc.Document
Dim partDef As PartComponentDefinition = part.ComponentDefinition

Dim positionSketch As Sketch = partDef.Sketches(2)
Dim parentFeatures As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection()
parentFeatures.Add(partDef.SurfaceBodies(1))

Dim patternDef As SketchDrivenPatternDefinition = partDef.Features.SketchDrivenPatternFeatures.CreateDefinition(parentFeatures, positionSketch)
patternDef.Operation = PartFeatureOperationEnum.kNewBodyOperation

Dim patternFeature As SketchDrivenPatternFeature = partDef.Features.SketchDrivenPatternFeatures.Add(patternDef)
patternFeature.Definition.Operation = PartFeatureOperationEnum.kNewBodyOperation

 

 

jiri.paur
Participant
Participant

Thank you Michael!

I did not try to set the operation again after the pattern is created. But it works!

 

Thanks

Jiri

0 Likes