Inventor Customization

Posts: 27
Registered: ‎12-13-2012
Message 1 of 2 (282 Views)
Accepted Solution

Bend line projection on a sketch

282 Views, 1 Replies
02-04-2013 12:36 AM


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?

Posts: 27
Registered: ‎12-13-2012
Message 2 of 2 (263 Views)

Re : Bend line projection on a sketch

02-04-2013 06:23 AM in reply to: denis.bourasseau

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 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))

End Sub


You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community

Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor