Community
Hello.
Just by selecting a bend line on the flat pattern, I'd like to draw only 2 lines on a sketch (without any border projection, only points) at both ends of the bend line.
I'm sure it can be done via VBA, but don't know how to start for it.
Any idea?
Solved! Go to Solution.
Solved by denis.bourasseau. Go to Solution.
OK, I got it:
Sub Marquages() Dim oPartDoc As PartDocument Dim oPoint1, oPoint2 As Point2d Set oPartDoc = ThisApplication.ActiveDocument Dim oSheetMetalDef As SheetMetalComponentDefinition Set oSheetMetalDef = ThisApplication.ActiveDocument.ComponentDefinition Dim oFlatPattern As FlatPattern Set oFlatPattern = oSheetMetalDef.FlatPattern If oPartDoc.SelectSet.Count = 0 Then MsgBox "Selectionner un axe de pliage", vbExclamation End End If Dim oBendEdge As Edge Set oBendEdge = oPartDoc.SelectSet(1) Dim oSketch As PlanarSketch Set oSketch = oFlatPattern.Sketches.Add(oSheetMetalDef.FlatPattern.TopFace, False) oSketch.Name = "Marquages " & oFlatPattern.Sketches.Count Dim oTransGeom As TransientGeometry Set oTransGeom = ThisApplication.TransientGeometry Dim oLines(1 To 3) As SketchLine Set oLines(1) = oFlatPattern.Sketches(1).AddByProjectingEntity(oBendEdge) Set oPoint1 = oLines(1).Geometry.StartPoint Set oPoint2 = oLines(1).Geometry.EndPoint Set oLines(2) = oSketch.SketchLines.AddByTwoPoints(oPoint1, oPoint2) Call oSketch.GeometricConstraints.AddGround(oLines(2).StartSketchPoint) Call oSketch.DimensionConstraints.AddTwoPointDistance(oLines(2).StartSketchPoint, oLines(2).EndSketchPoint, kAlignedDim, oPoint1) oSketch.DimensionConstraints(1).Parameter.Value = 1 Set oLines(3) = oSketch.SketchLines.AddByTwoPoints(oPoint1, oPoint2) Call oSketch.GeometricConstraints.AddGround(oLines(3).EndSketchPoint) Call oSketch.DimensionConstraints.AddTwoPointDistance(oLines(3).StartSketchPoint, oLines(3).EndSketchPoint, kAlignedDim, oPoint2) oSketch.DimensionConstraints(2).Parameter.Value = 1 Call oSketch.GeometricConstraints.AddCollinear(oLines(2), oLines(3)) oLines(1).Delete End Sub