Move object, Translate coord....puzzled

Discussion in 'AutoCAD' started by Dan, Feb 10, 2005.

  1. Dan

    Dan Guest

    Essentially, I want to move a user selected Attribute Block object, to a
    predetermined UCSW x,y,z coordinate.
    Currently I have the user select the object, and destination, but I wish to
    change it so the user just selects the object, and the code will move it to
    the propper place.
    The UCSW x,y,z coord will always be the same: (i.e. (-229,226,0))

    I have been trying to understand the TranslateCoordinates method.
    Example: RetVal = object.TranslateCoordinates(OriginalPoint, From, To,
    Disp[, OCSNormal])

    Thanks,
    Dan

    Here is a smippet from my code:

    Dim basePnt As Variant
    Dim myObj As AcadEntity
    Dim point1(0 To 2) As Double
    Dim point2(0 To 2) As Double
    Dim endPnt As Variant
    Dim prompt1 As String

    On Error GoTo Err_Control
    ThisDrawing.Utility.Prompt vbCrLf & " " & vbCrLf
    ThisDrawing.Utility.GetEntity myObj, basePnt, "Select Piece:"
    myObj.Highlight True

    prompt1 = vbCrLf & "Select Destination point for the Piece: "
    endPnt = ThisDrawing.Utility.GetPoint(, prompt1)

    myObj.Move basePnt, endPnt
    myObj.Rotation = 0
    myObj.Update

    '====cut===
     
    Dan, Feb 10, 2005
    #1
  2. Why don't you just set the insertion point of the
    block reference to the specified coordinates?
     
    Tony Tanzillo, Feb 10, 2005
    #2
  3. Dan

    Dan Guest

    Sounds good, I have not figured out how to do that yet.
    Dan

     
    Dan, Feb 11, 2005
    #3
  4. Dan

    Dan Guest

    Thanks for the lead Tony.
    I changed the object typ from AcadEntity to AcadBlockReference, and this
    opened up the myObj.InsertionPoint that I needed. Thanks again.
    Dan

     
    Dan, Feb 11, 2005
    #4
  5. Dan,
    Does your current code crash if you pick something other than a Block
    Reference? If so, you should use an AcadEntity when doing the object
    selection, and then cast it to an AcadBlockRef variable before using the
    InsertionPoint properties.... sorry, the uppercase I used to highlight the
    new code is hard on the eyes....

    Dim myObj As AcadEntity
    DIM MYBLOCKREF AS ACADBLOCKREFERENCE

    On Error GoTo Err_Control
    ThisDrawing.Utility.Prompt vbCrLf & " " & vbCrLf
    ThisDrawing.Utility.GetEntity myObj, basePnt, "Select Piece:"
    IF TYPEOF MYOBJ IS ACADBLOCKREF THEN
    SET MYBLOCKREF = MYOBJ
    MYBLOCKREF.INSERTIONPOINT = ....
    ELSE
    'USER PICKED SOMETHING OTHER THAN BLOCK REF
    ENDIF

    James
     
    James Belshan, Feb 11, 2005
    #5
  6. Dan

    Dan Guest

    Thanks for the advice, I will incorporate it.
    Afterall, we all know users do exactly what they are supposed to do 100% of
    the time..
    Dan
     
    Dan, Feb 11, 2005
    #6
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.