PDA

View Full Version : 3D Sketch Constraints with VBA



BruceEasom
2012-06-13, 04:03 PM
I am trying to generate an Inventor 2013 3-D sketch using VBA but need help with constraints. The code snippet below creates points in a 3-D sketch, anchors one at the origin and creates a vertical line one unit long. I would like to create a coincident constraint between oPoint and the start of oLines(1). Any suggestions?


Sub GenFrame()
Dim oTransGeom As TransientGeometry
Dim oCoord(1 To 10) As Point
Dim oLines(1 To 10) As SketchLine3D
Dim oPoint As SketchPoint3D
Dim oSketch As Sketch3D

Set oSketch = ThisApplication.ActiveEditObject
Set oTransGeom = ThisApplication.TransientGeometry
Set oCoord(1) = oTransGeom.CreatePoint(0, 0, 0)
Set oCoord(2) = oTransGeom.CreatePoint(0, 0, 1)

Set oPoint = oSketch.SketchPoints3D.Add(oCoord(1)) ' Add origin as a point
Call oSketch.GeometricConstraints3D.AddGround(oPoint) ' Lock the origin point down


Set oLines(1) = oSketch.SketchLines3D.AddByTwoPoints(oPoint, oCoord(2))
' Now what?
End Sub