12-01-2020
11:18 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
12-01-2020
11:18 PM
Hi @inulobo
What you need to do is to create a geometry intent for the intersection point between the two drawing curves.
Here's an example:
Sub IntersectionDimExample()
'Get the active sheet
Dim oSheet As Sheet
Set oSheet = ThisApplication.ActiveDocument.ActiveSheet
'Get the curves for intersection point
Dim oCurve1 As DrawingCurve
Set oCurve1 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Pick first intersection curve").Parent
Dim oCurve2 As DrawingCurve
Set oCurve2 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Pick second intersection curve").Parent
'Create GeometryIntent for intersection
Dim oIntersectionIntent As GeometryIntent
Set oIntersectionIntent = oSheet.CreateGeometryIntent(oCurve1, oCurve2)
'Get curve to set dimension to
Dim oCurve3 As DrawingCurve
Set oCurve3 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingCurveSegmentFilter, "Pick curve to dimension to").Parent
'Create Geometry intent for that curve
Dim oCurveIntent As GeometryIntent
Set oCurveIntent = oSheet.CreateGeometryIntent(oCurve3)
'Create a text origin point for dimension
Dim oPt As Point2d
Set oPt = oIntersectionIntent.PointOnSheet
Dim oVector As Vector2d
Set oVector = oPt.VectorTo(oCurve3.MidPoint)
Call oVector.ScaleBy(1 / 2)
Call oPt.TranslateBy(oVector)
'Create the dimension
Dim oDim As LinearGeneralDimension
Set oDim = oSheet.DrawingDimensions.GeneralDimensions.AddLinear(oPt, oIntersectionIntent, oCurveIntent)
'Arrange the dimension
Dim oCol As ObjectCollection
Set oCol = ThisApplication.TransientObjects.CreateObjectCollection
Call oCol.Add(oDim)
Call oSheet.DrawingDimensions.Arrange(oCol)
End Sub
The macro will ask you to first pick the two curves that you want to get the intersection point of. Then pick a third curve that you want to create the dimension from the intersection point to.
Notice how I create the intersectionpoint geometry intent by calling CreateGeometryIntent using the two curves as arguments ![]()
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website