TRANS for rotation angle?

Discussion in 'AutoCAD' started by Mark Ingram, Oct 15, 2004.

  1. Mark Ingram

    Mark Ingram Guest

    Good morning,

    I am looking for help with a TRANS for a rotation angle. I looked at points
    conversion in help, and this is way over my head.

    I'm copying blocks using insert from one ucs to another, and placing them on
    a different layer in the new ucs. Everything is working except for the
    rotation angle. A hardcoded formula doesn't work, as I can't predict new

    Any help here would be greatly appreciated.
    Mark Ingram, Oct 15, 2004
    1. Advertisements

  2. Mark Ingram

    Rudy Tovar Guest

    Search the newsgroup for a 2 or 3 weeks ago, it was discussed.

    9-14-04 "Trans or other"
    Rudy Tovar, Oct 15, 2004
    1. Advertisements

  3. Mark Ingram

    Mark Ingram Guest

    James, thank you for the reply.

    I am taking blocks from WCS to a known, named UCS. I am able to insert the
    blocks in the known UCS in a correct position and on the new layer, just
    don't know how to handle the rotation. I understand the dxf is radians, but
    point matrix is beyond me.

    I don't need 3d orientation, all insert will be at 0 z.

    I looked for the posts you mentioned, and had no luck - using OE6, not web
    access. I will look at vla-transformby, but again, a point matrix melts my

    BTW, I need to re-insert the block, not just copy it, as I use a different

    Any help getting the new rotation would be great.

    Thanks again,
    Mark Ingram, Oct 15, 2004
  4. Mark Ingram

    Mark Ingram Guest

    Thanks Rudy, but I didn't see anything providing an angle, or I don't know
    what I'm looking at.

    Mark Ingram, Oct 15, 2004
  5. Mark Ingram

    Mark Ingram Guest

    Sorry, I can't see it. Could you repost attachment here?

    Thank you,
    Mark Ingram, Oct 15, 2004
  6. Mark Ingram

    BillZ Guest

    How about if we take this back to basics?

    The rotaion angle in the WCS is the same as the rotation angle in the UCS.

    Unless for some reason you want to have your inserts different than the ones on the WCS.

    BillZ, Oct 15, 2004
  7. Mark Ingram

    Mark Ingram Guest

    I guess in short...

    <in degrees or radians, I don't care>
    (functionname rotation_from_WCS) = returns rotation in current/known UCS


    (functionname INS_from_WCS rotation_from_WCS) = returns INSertion point &
    rotation in current/known UCS as list

    Sorry if I am unclear, I'm trying :)
    Mark Ingram, Oct 15, 2004
  8. Mark Ingram

    BillZ Guest

    Maybe this will help:

    You may be able to modify it.

    ; == Function WvpVec2Ang
    ; Converts a vector to an angle.
    ; Arguments [Type]:
    ; Vec = Vector value

    • ; Return [Type]:
      ; > Angle value [REAL]
      ; Notes:
      ; Credits to Luis Esquivel
      (defun Vec2Ang (Vec / XvcVal YvcVal) ;get angle of each segment of pline at vertex.
      (setq XvcVal (car Vec)
      YvcVal (cadr Vec)
      (cond ((equal XvcVal 0 1E-4)
      (if (minusp YvcVal)(* pi 1.5)(* pi 0.5))
      ((equal XvcVal -1 1E-4) pi)
      ((equal YvcVal 0 1E-4)(if (minusp XvcVal) pi 0)
      (T (atan YvcVal XvcVal))
      ) ;defun

      ;;2d LWPOLYLINES
      ;;Usage ([email protected]_point_lst)

      (defun c:[email protected]_point_list (/ block_name CurPar InsAng rslt)
      (setvar "cmdecho" 0)
      (setq *acad* (vlax-get-acad-object)
      *acad_doc* (vla-get-activedocument *acad*)
      *mspace* (vla-get-modelspace *acad_doc*)
      (initget 1)
      (setq plineObj (vlax-ename->vla-object (car (entsel "Pick a 2D Polyline: <> ")))
      (setq block_name (getstring "\nEnter block name: <> ")
      (setq vlist ;get list of xyz reals from polyline.
      ;---; ;convert to list of 2d points.
      (setq rslt (cons (list (car vlist)(cadr vlist)) rslt)
      vlist (cddr vlist)
      (if (tblsearch "BLOCK" block_name) ;insert block
      (foreach Pnt (reverse rslt)
      (setq CurPar (vlax-curve-getParamAtPoint plineObj Pnt)
      InsAng (Vec2Ang (vlax-curve-getFirstDeriv plineObj CurPar))
      (vla-InsertBlock *mspace* (vlax-3d-point Pnt) block_name 1 1 1 InsAng)

      (prompt "\nBlock name not found.")


      Gotta go now.

    BillZ, Oct 15, 2004
  9. Mark Ingram

    Mark Ingram Guest

    Great question. The 'other' ucs would be maybe opposite hand / maybe rotated
    / maybe flipped floor plan. This would make the rotation angle opposite in
    whatever way to the WCS.

    The objective is to have duplicated annotation in the same plan but
    different UCS orientation and different layers.

    The scenario of the new UCS is not predefined by the system, but created by
    the user. The name of the new UCS is known, and consistent, and current
    during this process.

    Mark Ingram, Oct 15, 2004
  10. Mark Ingram

    Mark Ingram Guest

    Thanks Bill, I'll check it out.

    Mark Ingram, Oct 15, 2004
  11. Mark Ingram

    Mark Ingram Guest

    Thanks Bill, I'll check it out.

    Mark Ingram, Oct 15, 2004
  12. Mark Ingram

    Mark Ingram Guest

    I may not be able to post for a few hours, please don't take my lack of
    response as disrespect for your help, I am grateful.

    Thank you very much for your help, :)
    Mark Ingram, Oct 15, 2004
  13. Mark Ingram

    James Allen Guest

    Hi Mark.

    Using vlisp methods, it sounds like all you need for each insert is a
    vla-copy and vla-transformby. Two operations per insert, that's the bottom
    line. Should you choose to accept that mission, the only trick is getting
    the transformation matrix to feed to the transformby method.

    The key question to answer is what defines the two coordinate systems. Are
    they two saved ucs's, one wcs and one ucs, ocs to ucs? For each insert,
    what cs are we going from and to? I wasn't sure from your post. Also, how
    powerful do you want the cs change to be? Are you changing just rotation,
    position as well, or even non-uniform scaling and 3d orientation. All of
    this is possible, and again I'm not sure.

    With that information in hand you can do just what you want. It is possible
    that you can do it without matrices or transformby at all, but depending on
    exactly what you are doing, it might actually be more work IMO.

    I'll be watching for your response. In the meantime, if you want to study
    some example code you can look at some of my recent posts. Find my
    "BlockSwap.lsp" and "rcb2.lsp" attachments (5Oct & 10Oct) in the recent
    thread "how to change the insertpoint of a block,and keep the insert
    objects's place". Or I know John Uhden and Joe Burke (probably others as
    well) have some good code out there as well. Perhaps none of it will
    exactly fit your need, but under the hood it's all fundamentally the same
    James Allen, Oct 15, 2004
  14. Mark Ingram

    James Allen Guest

    Hi Rudy.

    I wish I hadn't missed that thread you referred to.

    Rudy wrote> "Thanks Luis... but it would be a killer utility to incorporate
    all the other factors."

    I think you may be interested in "MWE:BlockTrans" in "rcb2.lsp" that I
    referred Mark to. And perhaps some more of that very long thread.
    James Allen, Oct 15, 2004
  15. Mark Ingram

    James Allen Guest

    Mark, I think Bill's got you going in the right direction. Thank you Bill.
    (We see where my mind's been lately.)

    Another tip: (angle '(0 0 0) (trans '(1 0 0) 1 0 t)) returns the rotation of
    the current ucs in radians. Notice that '(1 0 0) is a vector that defines
    the x-axis, or 0d rotation. So we translate the vector and find the
    resulting angle.

    When you say things like opposite hand and flipped, I'm still not sure that
    ALL we're talking about is position and rotation, but I'll hold off on that
    for now.

    James Allen, Oct 15, 2004
  16. Mark Ingram

    Mark Ingram Guest

    That may be what I was looking for... off to test.
    Thanks :)
    Mark Ingram, Oct 18, 2004
  17. Mark Ingram

    James Allen Guest

    You're welcome.

    James Allen, Oct 18, 2004
    1. Advertisements

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.