- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I'm trying to add the horizontal and the vertical extent dimensions to a flat pattern view, but so far unsuccesfully. I'm pretty sure someone already has code for that... 🙂
I tried several approaches to find the outmost points, but my current approach is to intersect every drawing curve with the view boundary box lines to find the outmost points and create geometry intents on the found curve at the outermost point, to later add dimensions. But the problem is, sometimes the line2d.intersectwithcurve function does not return anything (unless using a huge tolerance, in which case it returns the wrong point) even though the curve does intersect with the line. Also, if the curve is a line parallel to the intersect line, it also doesn't return an intersection - but then how do I know if the lack of an intersection means a: there's indeed no intersection, or b: the two lines are parallel and coincident?
Anyway, some code showing how to do this would be helpful. Thanks!
Here's the current state of my code:
Private Function Extents(ByRef FlatPatternView As DrawingView) Dim TG, BG, LG, RG As GeometryIntent Set TG = Nothing Set BG = Nothing Set LG = Nothing Set RG = Nothing Dim UVH, UVV As UnitVector2d Set UVH = ThisApplication.TransientGeometry.CreateUnitVector2d(1, 0) Set UVV = ThisApplication.TransientGeometry.CreateUnitVector2d(0, 1) Dim TL, BL, LL, RL As Line2d Set TL = ThisApplication.TransientGeometry.CreateLine2d(ThisApplication.TransientGeometry.CreatePoint2d(FlatPatternView.Left, FlatPatternView.Top), UVH) Set BL = ThisApplication.TransientGeometry.CreateLine2d(ThisApplication.TransientGeometry.CreatePoint2d(FlatPatternView.Left, FlatPatternView.Top - FlatPatternView.Height), UVH) Set LL = ThisApplication.TransientGeometry.CreateLine2d(ThisApplication.TransientGeometry.CreatePoint2d(FlatPatternView.Left, FlatPatternView.Top - FlatPatternView.Height), UVV) Set RL = ThisApplication.TransientGeometry.CreateLine2d(ThisApplication.TransientGeometry.CreatePoint2d(FlatPatternView.Left + FlatPatternView.Width, FlatPatternView.Top - FlatPatternView.Height), UVV) For Each DrawingCurve In FlatPatternView.DrawingCurves If TG Is Nothing Then Set Intersect = TL.IntersectWithCurve(DrawingCurve.Segments.Item(1).Geometry) If Not (Intersect Is Nothing) Then Set TG = FlatPatternView.Parent.CreateGeometryIntent(DrawingCurve, Intersect.Item(1)) End If If BG Is Nothing Then Set Intersect = BL.IntersectWithCurve(DrawingCurve.Segments.Item(1).Geometry) If Not (Intersect Is Nothing) Then Set BG = FlatPatternView.Parent.CreateGeometryIntent(DrawingCurve, Intersect.Item(1)) End If If LG Is Nothing Then Set Intersect = LL.IntersectWithCurve(DrawingCurve.Segments.Item(1).Geometry) If Not (Intersect Is Nothing) Then Set LG = FlatPatternView.Parent.CreateGeometryIntent(DrawingCurve, Intersect.Item(1)) End If If RG Is Nothing Then Set Intersect = RL.IntersectWithCurve(DrawingCurve.Segments.Item(1).Geometry) If Not (Intersect Is Nothing) Then Set RG = FlatPatternView.Parent.CreateGeometryIntent(DrawingCurve, Intersect.Item(1)) End If Next Dim PT1 As Point2d Set PT1 = ThisApplication.TransientGeometry.CreatePoint2d PT1.X = FlatPatternView.Left - 1 PT1.Y = FlatPatternView.Center.Y Set VDim = FlatPatternView.Parent.DrawingDimensions.GeneralDimensions.AddLinear(PT1, TG, BG, kVerticalDimensionType) PT1.X = FlatPatternView.Center.X PT1.Y = FlatPatternView.Top - FlatPatternView.Height - 1 Set HDim = FlatPatternView.Parent.DrawingDimensions.GeneralDimensions.AddLinear(PT1, LG, RG, kHorizontalDimensionType) End Function
Inv 2018
Solved! Go to Solution.