Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

API 3DSketch Arc Issues

1 REPLY 1
Reply
Message 1 of 2
Anonymous
406 Views, 1 Reply

API 3DSketch Arc Issues

I am trying to create a 3D arc in a sketch but am getting an error "The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))" 

 

Every part of the below code works except the final line that makes the arc in the sketch. After running the code I can manually create the arc using using the points created by the code. It is my understanding that the AddByThreePoints() wants the points by start middle end and that's how I have them so I'm not sure what the issue is.

 

Any help would be greatly appreciated.

 

 SyntaxEditor Code Snippet

Sub Main()

Dim oPartDoc As PartDocument 
        oPartDoc = ThisApplication.ActiveDocument
Dim oPartDef As PartComponentDefinition
        oPartDef = oPartDoc.ComponentDefinition

Dim tg As TransienTGeometry
tg = ThisApplication.TransientGeometry



    Dim sketch6 As Sketch3D
    
            sketch6 = oPartDef.Sketches3D.Add
            
            
    Dim points As Inventor.SketchPoints3D = sketch6.SketchPoints3D 
    Dim lines As Inventor.SketchLines3D = sketch6.SketchLines3D
    Dim arcs As Inventor.SketchArcs3D = sketch6.SketchArcs3D

    X1 = 19.3471
    Y1 = 0.72775
    Z1 = 111.147
    X2 = 19.2853
    Y2 = -0.2478
    Z2 = 111.509
    X3 = 19.2512
    Y3 = 0.42015
    Z3 = 111.801
    
    Dim pointArray(2) As Inventor.SketchPoint3D
    
    pointArray(0) = points.Add(tg.CreatePoint(X1, Y1, Z1) )
    pointArray(1) = points.Add(tg.CreatePoint(X2, Y2, Z2) ) 
    pointArray(2) = points.Add(tg.CreatePoint(X3, Y3, Z3) )

    Dim line2 As Inventor.SketchLine3D
    line2 = lines.AddByTwoPoints(pointArray(0), pointArray(1))

    ' Create Arc
    Dim arc1 As Inventor.SketchArc3D
    arc1 = arcs.AddByThreePoints(pointArray(1), pointArray(2), pointArray(0))
    
    
    
    End Sub
1 REPLY 1
Message 2 of 2
t_remal
in reply to: Anonymous

Hi,

Please try using a regular Point (not SketchPoint3D) for the midpoint of the arc:

 

    Dim pointArray(2) As Inventor.SketchPoint3D
    
    Dim oMidPoint As Point
    Set oMidPoint = tg.CreatePoint(X3, Y3, Z3)
    
    Set pointArray(0) = points.Add(tg.CreatePoint(X1, Y1, Z1))
    Set pointArray(1) = points.Add(tg.CreatePoint(X2, Y2, Z2))

    Dim line2 As Inventor.SketchLine3D
    Set line2 = lines.AddByTwoPoints(pointArray(0), pointArray(1))

    ' Create Arc
    Dim arc1 As Inventor.SketchArc3D
    Set arc1 = arcs.AddByThreePoints(pointArray(1), oMidPoint, pointArray(0))

 

Lubomir

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report