Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
A.Acheson
in reply to: dimamazutaMMJ32

You were almost there, you just needed to place the workplane object you just selected into the Sketches.Add method.

 

Just swap "oPlane" for the first plane "oDoc.ComponentDefinition.WorkPlanes.Item(1)"

Dim Sketch2 As PlanarSketch = oDoc.ComponentDefinition.Sketches.Add(oPlane,False)

Here is the rest of the rule cleaned up with declarations. Always best practice to declare the objects to gain access to there methods.

 

Dim filename As String = "F:\Work\DesingsHome\iLogic Rules\BOM\01.01.01-02 Деталь.ipt"
Dim PartDoc As PartDocument = ThisApplication.Documents.Open(filename,False)
Dim PartcompDef As PartComponentDefinition = PartDoc.ComponentDefinition

Dim ExtFeature As ExtrudeFeature = PartcompDef.Features.ExtrudeFeatures.item(1)
Dim ExtDef As ExtrudeDefinition = ExtFeature.Definition
Dim ExtProfile As Profile = ExtDef.Profile

Dim oSketchToCopy As PlanarSketch = ExtFeature.Definition.Profile.Parent

Dim oDoc As PartDocument = ThisDoc.Document

Dim oPlane As WorkPlane = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kWorkPlaneFilter, "") '-pick the WorkPlane
 
Dim Sketch2 As PlanarSketch = oDoc.ComponentDefinition.Sketches.Add(oPlane,False)'oDoc.ComponentDefinition.WorkPlanes.Item(1)

oSketchToCopy.CopyContentsTo(Sketch2)

 

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