Get a Point of a Model Space Object from Paper space

Discussion in 'AutoCAD' started by Cristian Leon, Oct 28, 2004.

  1. Hello

    I'm developing a lisp program that works with a 3D piping design, and i need to dimension an isometric view. It's supposed that with the system variable dimassoc = 2 the dimensions take the real value from model space, but only works with orthogonal views...

    The question is... is there a lisp function that retrieves the world coordinates of an object in model space being in paper space?

    (i tried with (trans [point] 3 2) but it doesn't works whit the world coordinates and i can't relate with it)

    thanks

    Cristian Leon
    Chile
     
    Cristian Leon, Oct 28, 2004
    #1
  2. Cristian Leon

    James Allen Guest

    Hi Cristian. Perhaps you can glean from this code what you need?
    --
    James Allen, EIT
    Malicoat-Winslow Engineers, P.C.
    Columbia, MO

    ;;; Draws a line in paperspace between two points picked in modelspace.
    ;;; No error checking included.
    ;;; Assumes that you will already be "in" a pviewport.
    ;;; For demonstration purposes only.
    (defun c:test (/ doc p1 p2 ht)
    (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))
    p1 (getpoint "\nPick a point. ")
    p2 (getpoint "\nPick another point. ")
    p1 (trans p1 1 2) ;From model UCS to pviewport DCS
    p2 (trans p2 1 2) ;From model UCS to pviewport DCS
    ;; Correct z-value for pviewport target height
    ht (vlax-get (vla-get-ActivePViewport doc) 'Target)
    ht (list 0 0 (last ht))
    p1 (mapcar '+ p1 ht)
    p2 (mapcar '+ p2 ht)
    p1 (trans p1 2 3) ;From pviewport DCS to paper DCS
    p2 (trans p2 2 3) ;From pviewport DCS to paper DCS
    )
    (vla-put-MSpace doc :vlax-False)
    (setq ;; Correct z-value for paper target height
    ht (vlax-get (vla-get-ActivePViewport doc) 'Target)
    ht (list 0 0 (last ht))
    p1 (mapcar '+ p1 ht)
    p2 (mapcar '+ p2 ht)
    p1 (trans p1 2 1) ;From paper DCS to paper UCS
    p2 (trans p2 2 1) ;From paper DCS to paper UCS
    )
    (command "line" p1 p2 "")
    )

    need to dimension an isometric view. It's supposed that with the system
    variable dimassoc = 2 the dimensions take the real value from model space,
    but only works with orthogonal views...
    coordinates of an object in model space being in paper space?
    coordinates and i can't relate with it)
     
    James Allen, Oct 28, 2004
    #2
  3. Hi:

    It wasn't what exactly i need, but was very useful, i could make some changes that helps me.

    One thing... i didn't understood what means the second part of the program:

    (setq ;; Correct z-value for paper target height
    ht (vlax-get (vla-get-ActivePViewport doc) 'Target)
    ht (list 0 0 (last ht))
    p1 (mapcar '+ p1 ht)
    p2 (mapcar '+ p2 ht)
    p1 (trans p1 2 1) ;From paper DCS to paper UCS
    p2 (trans p2 2 1) ;From paper DCS to paper UCS
    )


    because i probe your program without this part and i get the same result...

    Thanks a lot

    Cristian Leon
    Chile
     
    Cristian Leon, Oct 29, 2004
    #3
  4. Cristian Leon

    James Allen Guest

    (setq ;; Correct z-value for paper target height
    This part corrects for z value in the target. In my testing in A2k2, trans
    was returning points with z values equal to the target z value. If you took
    this part out and the viewport target had any z value, then the resulting
    point would also have that z value.
    This part allows for a non-world paper space ucs. In other words, if
    (really big if I think) your paper space ucs is non-world, then this will
    allow it to still return the correct point.

    If your viewports target z value value equals zero and the paper space ucs
    equals wcs, then none of the second portion has any effect. I put it in to
    try to allow for any possibility. I am glad it was helpful.
     
    James Allen, Oct 30, 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.