Newbie Needs to Rotate Current UCS

Discussion in 'AutoCAD' started by Steve Graffeo, Apr 21, 2004.

  1. Is there a line of code to rotate the current ucs, say 45 degrees on the z
    axis?
     
    Steve Graffeo, Apr 21, 2004
    #1
  2. Boy, My first post in here and I stumped all?

    Hoping for a little help here....
    Steve
     
    Steve Graffeo, Apr 23, 2004
    #2
  3. Here's all I know about it.... 2 ways, the proper way, and the practical way
    (it's late, I'm tired, and cynical)
    first the practical way. this way uses SendCommand, so it's asynchronous,
    which means the rest of your code won't wait for this SendCommand to finish
    before your code moves on.... For a command this simple it shouldn't cause
    problems, but if your SendCommand were more complex, and later parts of your
    code needed it to be finished, you could have problems. Anyway, try:

    Sub Test()
    Dim dRotAng As Double
    dRotAng = 45
    SendCommand "ucs n z " & Trim$(Format$(dRotAng)) & " "
    End Sub

    The proper way involves getting the UCS info (such as its X & Y axes) and
    then doing the math to rotate them about Z. There are math functions such
    as TransformBy that could help you do the rotation math, but it's not
    documented all that well, IMO. You could also find code, I believe, to
    create line objects that represent the UCS axes, and then use ACAD methods
    to rotate the lines and get the new coordinates. Anyway, after you get the
    rotated axes, you would feed them to the AddUCS method. This method seems
    to be VERY picky about the X&Y axes being perpendicular. Lastly, you would
    set the new UCS to be your active UCS. You can find code snippets in this
    group to help do a lot of this, but it'll be a lot longer than the first
    solution.

    HTH,
    James
     
    James Belshan, Apr 23, 2004
    #3
  4. Steve Graffeo

    AKS Guest

    Steve,

    Working with a rotated UCS results in a stiff neck. I prefer to rotate
    the view ( I think the acad term is twist) and then set the UCS to the
    "view". You can automate that process down to a single click.by using
    conventional means in lieu of VBA. Any home tools you use under these
    conditions need to work in transformed coordinates. Is that any help?

    AKS
     
    AKS, Apr 23, 2004
    #4
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.