- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, I've been working on this code for a while and I'm kinda hopeless in finding solution for the last part. So here is what my code does:
1) Takes textbox from sketch on flat pattern. (The textbox is placed there by another rule.)
2) Writes the same text from textbox but using simple lines
Subs are runed in this order (Main > WriteText > WriteSymbol > Symbol code)
--- now the part that isn't working ---
3) Takes positon of bend lines
--- end of the not working code ---
4) Places text next to each bend line ("U" for lines bend up and "D" for lines bend down)
Subs are runed in this order (Main > BendLineText > WriteText > WriteSymbol > Symbol code)
...Then another rule exports the flat pattern with this sketch to DXF, so it can be used by our laser.
The problem is that im getting wrong positions of these bend lines. I'll be glad for any suggestions. Here are my last 3 attempts which failed, the rest of the code is in attachment.
Sub BendLineText3(oDoc As Document, oSketch As PlanarSketch, oFlatPattern As FlatPattern, oFSS As Double) oRotation = 0 oFSS = oFSS * 0.5 BendResults = oFlatPattern.FlatBendResults a = BendResults.Item(1).Edge.StopVertex.Point.X b = BendResults.Item(1).Edge.StopVertex.Point.Y oTextB = "U-D" Call WriteText(oTextB, a, b, oFSS) End Sub
Sub BendLineText2(oDoc As Document, oSketchA As PlanarSketch, oFlatPattern As FlatPattern, oFSS As Double) BendResults = oFlatPattern.FlatBendResults X = BendResults.Item(1).Edge.StopVertex.Point.X Y = BendResults.Item(1).Edge.StopVertex.Point.Y oSketchA.TextBoxes.AddFitted(ThisApplication.TransientGeometry.CreatePoint2d(X, Y), "Autodesk") End Sub
Sub BendLineText(oDoc As Document, oSketch As PlanarSketch, oFlatPattern As FlatPattern, oFSS As Double) oRotation = 0 oFSS = oFSS * 0.5 Dim oTransaction As Transaction = ThisApplication.TransactionManager.StartTransaction(oDoc, "Find area") Try Ymin = 1000000 Ymax = -1000000 For Each oEntity in oSketch.SketchEntities EntityMin = oEntity.RangeBox.minPoint.Y EntityMax = oEntity.RangeBox.maxPoint.Y Ymin = Min(Ymin, EntityMin) Ymax = Max(Ymax, EntityMax) Next Dim oTempEdge As Edge Dim oTopFaceBendEdges As Edges = oFlatPattern.Edges Xmin = 1000000 For Each oTempEdge In oTopFaceBendEdges Val1 = oTempEdge.StartVertex.Point.X Val3 = oTempEdge.StopVertex.Point.X EdgeX = Min(Val1, Val3) Xmin = Min(Xmin, EdgeX) Next Dim oTopFaceBendUpEdges As Edges = oFlatPattern.GetEdgesOfType(FlatPatternEdgeTypeEnum.kBendUpFlatPatternEdge, True) For Each oTempEdge In oTopFaceBendUpEdges Val1 = oTempEdge.StartVertex.Point.X Val3 = oTempEdge.StopVertex.Point.X AA = GetYValue(Val1, Val3) a = AA + (0.11 * oFSS) Val1 = oTempEdge.StartVertex.Point.Y Val3 = oTempEdge.StopVertex.Point.Y If Abs(Ymax) > Abs(Ymin) Then BB = GetYValue(Val1, Val3) a = a + (0.25 * oFSS) 'a = a + (SheetMetal.FlatExtentsLength * 0.0016) + (0.25 * oFSS) Else BB = 0 End If b = BB - (0.11 * oFSS) oTextB = "N" Call WriteText(oTextB, a, b, oFSS) Next Dim oTopFaceBendDownEdges As Edges = oFlatPattern.GetEdgesOfType(FlatPatternEdgeTypeEnum.kBendDownFlatPatternEdge, True) For Each oTempEdge In oTopFaceBendDownEdges Val1 = oTempEdge.StartVertex.Point.X Val3 = oTempEdge.StopVertex.Point.X AA = Min(Val1, Val3) If AA = Xmin Then a = Max(Val1, Val3) Else a = Xmin + Max(Val1, Val3) End If MsgBox(Val1 & vblf & Val3 & vblf & a) Val1 = oTempEdge.StartVertex.Point.Y Val3 = oTempEdge.StopVertex.Point.Y If Abs(Ymax) > Abs(Ymin) Then BB = GetYValue(Val1, Val3) Else BB = 0 End If b = BB - (0.11 * oFSS) oTextB = "D" Call WriteText(oTextB, a, b, oFSS) Next oTransaction.End Catch oTransaction.Abort End Try End Sub
And ofc. sorry for my English.
- - - - - - - - - - - - - - -
Regards,
Mike
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Solved! Go to Solution.