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

Why intermediate Work entities are needed?

Anonymous

Why intermediate Work entities are needed?

Anonymous
Not applicable

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

0 Likes
Reply
431 Views
4 Replies
Replies (4)

Balaji_Ram
Alumni
Alumni

Hi Yogesh,

 

You should be using a 3d sketch, add a work point and use the sketch point from "p1" that you already have from the 2d sketch.

the SketchLine3D can then be used to create a path, if you wish to sweep the profile along the normal direction.

 

        Dim oSketch3d As Sketch3D
        oSketch3d = partDoc.ComponentDefinition.Sketches3D.Add

        Dim wp2 As Inventor.WorkPoint
        wp2 = oCompDef.WorkPoints.AddFixed(oTG.CreatePoint(0, 0, 1))

        Dim oLine As SketchLine3D
        oLine = oSketch3d.SketchLines3D.AddByTwoPoints(skp1, wp2, False, 1)

Regards,

Balaji

 



Balaji
Developer Technical Services
Autodesk Developer Network

0 Likes

Anonymous
Not applicable

Created 3D sketch as suggested, but using this line as path and a rectangular profile, with those 4 points, SWEEP could not be generated.

the path created using the line seems to be erroneous.

 

Visually both profile and path look correct. In fact, though they fail to create SWEEP programmetically, if I selected them intereactively, SWEEP is generated.

 

Both pictures attached.

0 Likes

Anonymous
Not applicable

Another picture attached

0 Likes

Balaji_Ram
Alumni
Alumni

Can you please share the sample code to reproduce the behavior ?

 

Please do not share any information that you consider confidential.

 

Regards,

Balaji

 

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

0 Likes