AnchorPoints

AnchorPoints

Anonymous
Not applicable
586 Views
3 Replies
Message 1 of 4

AnchorPoints

Anonymous
Not applicable

I know how to get the anchor points from a dimension, but I can't seem to access them once I get them?  I have just this simple code:

  For Each oPartDim In oSketch.DimensionConstraints
    
    If oPartDim.Parameter.Name = "Angle" Then
      Debug.Print oPartDim.AnchorPoints
    End If
    
  Next oPartDim

 I've tried .item(0) .item(1), but I keep erroring out and I haven't seen anything else on these, I was hoping someone could show me how?

 

Thanks

0 Likes
Accepted solutions (1)
587 Views
3 Replies
Replies (3)
Message 2 of 4

Vladimir.Ananyev
Alumni
Alumni
Accepted solution

Try this sample code.  It prints anchor points coordinates using (a) 2d-points collection and (b) sketch points associated with given dimension constraint (here - ThreePointAngleDimConstraint). Note that AnchorPoints collection contains Point2D objects (not SketchPoint).

 

Private Sub Sketch_Dims_Test()

    Dim oDoc As PartDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oDef As PartComponentDefinition
    Set oDef = oDoc.ComponentDefinition
    
    Dim oSketch As PlanarSketch
    Set oSketch = oDef.Sketches.Item(1)
    
    Dim oDims As DimensionConstraints
    Set oDims = oSketch.DimensionConstraints
    
    'reference to 3-point angular dimension
    Dim oDim As ThreePointAngleDimConstraint
    Set oDim = oDims.Item(1)
    
    'coordinates of anchor 2d-points
    Dim oP As Point2d
    For Each oP In oDim.AnchorPoints
        Debug.Print oP.X, oP.Y
    Next
    Debug.Print
    
    'anchor sketch points
    Dim oSkp As SketchPoint
    
    Set oSkp = oDim.PointOne
    Debug.Print oSkp.Geometry.X, oSkp.Geometry.Y
    Set oSkp = oDim.PointTwo
    Debug.Print oSkp.Geometry.X, oSkp.Geometry.Y
    Set oSkp = oDim.PointThree
    Debug.Print oSkp.Geometry.X, oSkp.Geometry.Y
    
    Beep
End Sub

 Hope this helps.
Cheers,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 4

Anonymous
Not applicable

Thanks Vladimir,

 

That did the trick.  I'm guessing the code you provided is for 2014, in the bottom section I don't seem to have the "PointOne" option - but no matter, the part up above was what I needed.

 

Thanks again!

0 Likes
Message 4 of 4

Vladimir.Ananyev
Alumni
Alumni

Good news. 
Best regards!


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes