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: 

AddMidpoint for Arc

7 REPLIES 7
Reply
Message 1 of 8
Anonymous
724 Views, 7 Replies

AddMidpoint for Arc

How would one add a sketchpoint to a midpoint of an arc? For a SketchLine its easy...

 

oSketch.GeometricConstraints.AddMidpoint oSketchPoint, oSketchLine

 

However, I can't see how to do the same operation to find the midpoint of a SketchArc. The interface of course has a selection filter for this so I assume the API can do the same?

 

-AP

7 REPLIES 7
Message 2 of 8
Anonymous
in reply to: Anonymous

Never mind. Gave up too easy.

 

SketchArc.CenterSketchpoint

 

-AP

Message 3 of 8
Anonymous
in reply to: Anonymous

Well, thats not going to work either. Anyone have any ideas how to ge the midpoint of an arc?

 

 

Message 4 of 8
Anonymous
in reply to: Anonymous

Does anyone know about this? I'm trying to constrain a line endpoint to the vertex/midpoint of a sketch arc and can't seem to find a way to do it.

 

-Thomas

Message 5 of 8
ekinsb
in reply to: Anonymous

Hi Thomas,

 

I have some bad new that this is not currently possible using the API.  Inventor was enhanced at some point to support creating a midpoint to an arc and the API was not updated at the time to support this so the API currently only supports creating midpoing constraints to the centers of lines.

 

I have logged a change request (1503866) for an enhancement to support this but don't know when it might be implemented.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 6 of 8
Anonymous
in reply to: ekinsb

Thanks for getting back to me on this. I was pulling my hair out trying to find a way to use the midpoint method. I'd be really interested to know how the construction line that runs from end to end on an "overall slot" is made. Have any ideas?

 

Is there a way to reference the arc as a line segment?

 

Thanks again for the help.

 - Thomas

Message 7 of 8
ekinsb
in reply to: Anonymous

There's nothing special going to create the overall slot.  It's just using the existing set of constraints.  Here's a sample program that creates the identical result using the API.

 

Public Sub BuildSlot()
    Dim sk As PlanarSketch
    If Not TypeOf ThisApplication.ActiveEditObject Is Sketch Then
        MsgBox "A sketch must be active."
        Exit Sub
    Else
        Set sk = ThisApplication.ActiveEditObject
    End If
    
    Dim tg As TransientGeometry
    Set tg = ThisApplication.TransientGeometry
    
    Dim line1 As SketchLine
    Dim arc1 As SketchArc
    Dim line2 As SketchLine
    Dim arc2 As SketchArc
    Set line1 = sk.SketchLines.AddByTwoPoints(tg.CreatePoint2d(0, 0), tg.CreatePoint2d(10, 0))
    Set arc1 = sk.SketchArcs.AddByCenterStartEndPoint(tg.CreatePoint2d(10, 2), line1.EndSketchPoint, tg.CreatePoint2d(10, 4))
    Set line2 = sk.SketchLines.AddByTwoPoints(arc1.EndSketchPoint, tg.CreatePoint2d(0, 4))
    Set arc2 = sk.SketchArcs.AddByCenterStartEndPoint(tg.CreatePoint2d(0, 2), line2.EndSketchPoint, line1.StartSketchPoint)
    
    ' Add constraints.
    Dim geomConstraints As GeometricConstraints
    Set geomConstraints = sk.GeometricConstraints
    Call geomConstraints.AddTangent(line1, arc1)
    Call geomConstraints.AddTangent(line2, arc1)
    Call geomConstraints.AddTangent(line2, arc2)
    Call geomConstraints.AddTangent(line1, arc2)
    Call geomConstraints.AddParallel(line1, line2)
    
    Dim centerLine As SketchLine
    Dim centerPoint As SketchPoint
    Set centerLine = sk.SketchLines.AddByTwoPoints(tg.CreatePoint2d(-1, 2), tg.CreatePoint2d(11, 2))
    centerLine.Construction = True
    Set centerPoint = sk.SketchPoints.Add(tg.CreatePoint2d(5, 2), False)
    Call geomConstraints.AddMidpoint(centerPoint, centerLine)
    
    ' Add constraints to tie line to the slot.
    Call geomConstraints.AddCoincident(centerLine, arc1.CenterSketchPoint)
    Call geomConstraints.AddCoincident(centerLine, arc2.CenterSketchPoint)
    Call geomConstraints.AddCoincident(centerLine.StartSketchPoint, arc2)
    Call geomConstraints.AddCoincident(centerLine.EndSketchPoint, arc1)
End Sub

 

And you can't reference an arc as a line.  They're two different types.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 8 of 8
mucip
in reply to: Anonymous

Hi,

Thanks a lot sir. It helped me very much...  🙂

 

Regards,

Mucip:)

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

Post to forums  

Autodesk Design & Make Report