Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Bend line projection on a sketch

1 REPLY 1
SOLVED
Reply
Message 1 of 2
denis.bourasseau
631 Views, 1 Reply

Bend line projection on a sketch

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?

1 REPLY 1
Message 2 of 2

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

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report