Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Anonymous
429 Views, 4 Replies

Why intermediate Work entities are needed?

I have a Polyline3d having four lines, forming a planar rectangle (pt1,pt2,pt3,pt4)

 

I wish to create a sketch, which is normal to the rectangle plane, along one of the rectangle sides (say, pt1->pt4).

In the sketch, I wish to add a line, starting from pt1, at a distance 'd' along the normal. Picture attached.

 

Following code does it, but just to be compatible with the arguments, I have to create some intermediate work entities. Why? Is there ant elegant way?

 

 

 

Private Function CreateGuideSketchForFlange(ByVal oPl As Inventor.Polyline3d, ByRef ofeat As FlangeFeature) As PlanarSketch


    Dim point1 As Point = oPl.PointAtIndex(1)
    Dim point2 As Point = oPl.PointAtIndex(2)
    Dim point3 As Point = oPl.PointAtIndex(3)
    Dim point4 As Point = oPl.PointAtIndex(4)

 

    Dim v1 As Vector = _invApp.TransientGeometry.CreateVector(point2.X - point1.X, point2.Y - point1.Y, point2.Z - point1.Z)
    Dim uv1 As UnitVector = v1.AsUnitVector

 

    Dim v2 As Vector = _invApp.TransientGeometry.CreateVector(point4.X - point1.X, point4.Y - point1.Y, point4.Z - point1.Z)
    Dim uv2 As UnitVector = v2.AsUnitVector

 

    Dim v3 As Vector = v1.CrossProduct(v2)


    Dim uv3 As UnitVector = v3.AsUnitVector
    uv3.AsVector.ScaleBy(m_thickness)


    Dim point5 As Point = point1.Copy()
    point5.TranslateBy(uv3.AsVector)

 

    Dim wpt1 As WorkPoint = m_compDef.WorkPoints.AddFixed(point1)

    Dim wpt2 As WorkPoint = m_compDef.WorkPoints.AddFixed(point5)

    Dim pl As WorkPlane = m_compDef.WorkPlanes.AddFixed(point1, uv1, uv3)
    Dim skt As PlanarSketch = m_compDef.Sketches.Add(pl)
    Dim skpt1 As SketchPoint = skt.AddByProjectingEntity(wpt1)
    Dim skpt2 As SketchPoint = skt.AddByProjectingEntity(wpt2)
    Dim skln1 As SketchLine = skt.SketchLines.AddByTwoPoints(skpt1, skpt2)

    CreateGuideSketchForFlange = skt

End Function

Tags (1)