Existing sketch redefine to another workplane

Existing sketch redefine to another workplane

ArunS2DHBM
Enthusiast Enthusiast
368 Views
2 Replies
Message 1 of 3

Existing sketch redefine to another workplane

ArunS2DHBM
Enthusiast
Enthusiast

I have Sketch1, which should be redefined to Workplane1 if my parameter1=WP1 and it should be redefined to Workplane2 if my parameter1=WP2

 

can anyone help me with the Ilogic code.

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

Andrii_Humeniuk
Advisor
Advisor

Hi @ArunS2DHBM . Try this code, and don't forget to check the compatibility of the names of the sketch and the workplanes.

Private Sub Main()
	Dim oDoc As PartDocument = ThisApplication.ActiveDocument
	Dim oDef As PartComponentDefinition = oDoc.ComponentDefinition
	Dim oSketch As PlanarSketch = oDef.Sketches.Item("Sketch1")
	If parameter1 = "WP1" Then
		oSketch.PlanarEntity = oDef.WorkPlanes.Item("Workplane1")
	Else If parameter1 = "WP2" Then
		oSketch.PlanarEntity = oDef.WorkPlanes.Item("Workplane2")
	End If
End Sub

 

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

Message 3 of 3

ArunS2DHBM
Enthusiast
Enthusiast

Hi @Andrii_Humeniuk ,

 

Thanks for the code and it's working. 

 

When the sketch is redefined, the constraint is deleted, how can I keep up the constrain? example in sketch1 I have drawn a circle positioned at the line's  end point which is projected. i want to keep the constrain .

 

Can u help me ipon that 

0 Likes