intersect with block problem

Discussion in 'AutoCAD' started by sylv7320, Oct 5, 2004.

  1. sylv7320

    sylv7320 Guest

    I am trying to get the intersection point between a leader object and a blockref consisting of an ellipse and some text attributes (a part number balloon) so I can trim the leader to the edge of the ellipse. When I run the code (below) no point is returned even though the leader runs from the center of the ellipse to the object I am labeling. I get a subscript out of range error, the ellipse, and a leader from the center of the ellipse to the object I am labeling. Am I doing something wrong or is there a better way to attach the leader to an ellipse?

    Code: (excuse wrapping of lines if it occurs)

    Dim returnPnt, returnPnt2 As Variant
    Dim insertionPnt(0 To 2) As Double
    Dim blockRefObj As AcadBlockReference
    Dim leaderObj As AcadLeader
    Dim points(0 To 5) As Double
    Dim IntersectPnt(0 To 2) As Double
    Dim leaderType As Integer
    Dim annotationObject As AcadObject
    Dim polarPnt As Variant
    Dim intRadMult
    Dim coord

    intRadMult = Me.ComboBox1
    returnPnt = ThisDrawing.Utility.GetPoint(, "Place Balloon:")
    insertionPnt(0) = returnPnt(0): insertionPnt(1) = returnPnt(1): insertionPnt(2) = returnPnt(2)

    Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock(insertionPnt, "C:\Documents and Settings\jsylvester\My Documents\bomdb\cutbubbleblock.dwg", intRadMult, intRadMult, intRadMult, 0)
    ' Create the leader object in model space
    returnPnt2 = ThisDrawing.Utility.GetPoint(, "Select Item to Label:")
    points(0) = returnPnt2(0): points(1) = returnPnt2(1): points(2) = returnPnt2(2)
    points(3) = returnPnt(0): points(4) = returnPnt(1): points(5) = returnPnt(2)
    leaderType = acLineWithArrow
    Set annotationObject = Nothing
    Set leaderObj = ThisDrawing.ModelSpace.AddLeader(points, annotationObject, leaderType)
    leaderObj.ScaleFactor = intRadMult / 2
    ' Trim leader to bubble
    polarPnt = blockRefObj.IntersectWith(leaderObj, acExtendNone)
    IntersectPnt(0) = polarPnt(0): IntersectPnt(1) = polarPnt(1): IntersectPnt(2) = polarPnt(2)
    coord = leaderObj.Coordinate(1)
    coord(0) = IntersectPnt(0)
    coord(1) = IntersectPnt(1)
    coord(2) = IntersectPnt(2)
    leaderObj.Coordinate(1) = coord
    leaderObj.Update
     
    sylv7320, Oct 5, 2004
    #1
  2. sylv7320

    Jeff Mishler Guest

    It works fine for me, provided I select a point outside the ellipse.
    However, since you are using the Intersectwith on a blockref, the actual
    point of intersection is on the Block's bounding box, not the ellipse. You
    may want to explode the block, get the intersection with the ellipse, then
    delete the exploded entities. I can dulpicate your error, b ut only if I
    select the second point inside the boundingbox of the block.
     
    Jeff Mishler, Oct 5, 2004
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.