Create sketch array iLogic using ObjectCollection

Create sketch array iLogic using ObjectCollection

Anonymous
Not applicable
694 Views
2 Replies
Message 1 of 3

Create sketch array iLogic using ObjectCollection

Anonymous
Not applicable

Hello, I am wondering if there is a good way to create a sketch array using an ObjectCollection. I have a for loop that uses a new sketch every iteration. However I have not had any luck declaring a sketch as an object collection, and I can't simply reuse the same sketch variable every iteration, because declaring a new sketch with the same object name throws an error after it has already been consumed by a feature. Any thoughts?

0 Likes
695 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable

Correction:

I mistakenly thought you could not get away with declaring a new sketch though every iteration under the same variable name. This is not the case. It still would cleaner if it could be an array somehow, but it is not necessary. 

0 Likes
Message 3 of 3

JelteDeJong
Mentor
Mentor

did you try to make the sketch shared. shared sketches can be consumed by multiple features.

code snippet from help file.

Public Sub MakeSketchShared()
   ' Set a reference to the part component definition.
   ' This assumes that a part document is active.
   Dim oCompDef As PartComponentDefinition
   Set oCompDef = ThisApplication.ActiveDocument.ComponentDefinition

   ' Get the first extrusion feature in the part.
   ' This assumes that an extrusion feature exists in the part.
   Dim oExtrudeFeature As ExtrudeFeature
   Set oExtrudeFeature = oCompDef.Features.ExtrudeFeatures.Item(1)

   ' Set a reference to the sketch of the feature.
   Dim oSketch As PlanarSketch
   Set oSketch = oExtrudeFeature.Definition.Profile.Parent

   ' Share the sketch of the feature.
   oSketch.Shared = True
End Sub

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com