Project edge of a curved surface to 2d Sketch

Project edge of a curved surface to 2d Sketch

A.Acheson
Mentor Mentor
410 Views
2 Replies
Message 1 of 3

Project edge of a curved surface to 2d Sketch

A.Acheson
Mentor
Mentor

Hi All, Running into a block on trying to project an edge of a cylinder face to a 2d sketch. I can do this manually by selecting the edge but can't seem to be able  to find the method by API. I am able to get the vertical edges but not the horizontal edge. Any help appreciated. 

 

AAcheson_0-1683416582055.png

 

 

 

	Dim oFace As Face = ThisApplication.CommandManager.Pick _
  					(SelectionFilterEnum.kPartFaceCylindricalFilter, "Select a face") 
   Dim oPartDoc As PartDocument = ThisDoc.Document
   Dim Set1 As HighlightSet = ThisApplication.ActiveDocument.CreateHighlightSet
   Dim oCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition
   Dim oSketch As PlanarSketch = oCompDef.Sketches.Add(oCompDef.WorkPlanes(3))
	oSketch.Edit
	
	Dim oLine1 As SketchLine = oSketch.AddByProjectingEntity(oFace.Edges(2))
	Dim oLine2 As SketchLine = oSketch.AddByProjectingEntity(oFace.Edges(1))

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
411 Views
2 Replies
Replies (2)
Message 2 of 3

Andrii_Humeniuk
Advisor
Advisor

Hi @A.Acheson . I couldn't find a method to project a curved surface, but in case you can't find a solution, then I suggest just creating a new line based on two points of the projected lines.

Dim oDoc As Document = ThisApplication.ActiveDocument
If TypeOf oDoc Is PartDocument Then
	Dim oPDoc As PartDocument = oDoc
	Dim oFace As Face = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceCylindricalFilter, "Select a face")
	Dim oCompDef As PartComponentDefinition = oPDoc.ComponentDefinition
	Dim oTM As TransactionManager = ThisApplication.TransactionManager
	Dim newTM As Transaction = oTM.StartTransaction(oPDoc, "CreatSketch")
	Dim oSketch As PlanarSketch = oCompDef.Sketches.Add(oCompDef.WorkPlanes(3))
	oSketch.Edit()
	If oFace.SurfaceType = SurfaceTypeEnum.kCylinderSurface Then
		Dim oVertLine1 As SketchLine = oSketch.AddByProjectingEntity(oFace.Edges(1))
		Dim oVertLine2 As SketchLine = oSketch.AddByProjectingEntity(oFace.Edges(2))
		Dim oGorzLine1 As SketchLine = oSketch.SketchLines.AddByTwoPoints(oVertLine1.StartSketchPoint, oVertLine2.EndSketchPoint)
	End If
	oSketch.ExitEdit()
	newTM.End()
End If

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

WCrihfield
Mentor
Mentor

Just an FYI.  This situation is exactly what the PlanarSketch.AddBySilhoutette() method is good for.  The tricky part is specifying a point on that face nearer to one side or the other, in order to specify which side of the cylinder you want to project.  You could simply use the Face.PointOnFace, which will work for one side, then just mirror that accross the cylinder's axis, but I don't know if that would remain fully constrained.  Or use the PlanarSketch.ProjectedCuts.Add method, if the plane goes through the center of the cylinder.

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)