How to give Dimension from a Line to Center Line, using Inventor API.

How to give Dimension from a Line to Center Line, using Inventor API.

aniket_pachore
Enthusiast Enthusiast
319 Views
2 Replies
Message 1 of 3

How to give Dimension from a Line to Center Line, using Inventor API.

aniket_pachore
Enthusiast
Enthusiast

While drawing Sketch. How can I give Dimension from a Line to Center Line i.e. (it should give Diameter) using Inventor API.
As shown below

aniket_pachore_0-1729086359346.png

 

0 Likes
Accepted solutions (1)
320 Views
2 Replies
Replies (2)
Message 2 of 3

cidhelp
Advocate
Advocate
Accepted solution

Hello @aniket_pachore ,

 

look at this VBA-Code:

 

Sub CreateOffsetDim()
Dim oCenterline As SketchLine
Dim oSecondLine As SketchLine
Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oSk As PlanarSketch
Set oSk = oDoc.ComponentDefinition.Sketches(1)

'search first centerline
Dim oLine As SketchLine
For Each oLine In oSk.SketchLines
If oLine.Centerline Then
Set oCenterline = oLine
Exit For
End If
Next
If oCenterline Is Nothing Then Exit Sub
'search first parallel line
For Each oLine In oSk.SketchLines
If Not (oLine Is oCenterline) Then
If oLine.Geometry.Direction.IsParallelTo(oCenterline.Geometry.Direction) Then
Set oSecondLine = oLine
Exit For
End If
End If
Next
If oSecondLine Is Nothing Then Exit Sub

'create dimension
Dim oDimPt As Point2d
Set oDimPt = ThisApplication.TransientGeometry.CreatePoint2d(-1, 1)
Dim oDim As DimensionConstraint
Set oDim = oSk.DimensionConstraints.AddOffset(oSecondLine, oCenterline, oDimPt, True)
oDoc.Update
End Sub

 

Message 3 of 3

aniket_pachore
Enthusiast
Enthusiast

@cidhelp 
Thank you for your Answer.
As I am new in Inventor APIs. I am not familiar with the APIs.
It's basic but "offset" property was new for me.
It's working.
Thanks once again.

0 Likes