Sketch Bloks Definition and Geometric Constraints

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a problem to make any geometric constraints on active sketch block definition. When I trying to make constraint I'm getting error. If I will use the same steps to make constraints in just active sketch I have nor problems. Is there any explanation for this?
Short example:
Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.ActiveDocument
Dim obj As Object
Set obj = oPartDoc.ActivatedObject
Dim oSketch As PlanarSketch
Select Case obj.Type
Case kSketchBlockObject
Set oSketch = obj.Definition
Case kSketchBlockDefinitionObject, kPlanarSketchObject
Set oSketch = obj
Case Else
Exit Sub
End Select
Dim oTG As TransientGeometry
Set oTG = ThisApplication.TransientGeometry
Dim oLine1 As SketchLine
Set oLine1 = oSketch.SketchLines.AddByTwoPoints(oTG.CreatePoint2d(-2.5, 0), oTG.CreatePoint2d(2.5, 0))
Dim oLine2 As SketchLine
Set oLine2 = oSketch.SketchLines.AddByTwoPoints(oTG.CreatePoint2d(0, -2.5), oTG.CreatePoint2d(0, 2.5))
Dim oGeomConstraints As Inventor.GeometricConstraints
Set oGeomConstraints = oSketch.GeometricConstraints
Call oGeomConstraints.AddPerpendicular(oLine1, oLine2) 'Error here