lisp help

Discussion in 'AutoCAD' started by Jamie Duncan, Apr 27, 2004.

  1. Jamie Duncan

    Jamie Duncan Guest

    Just a simple routine, and I'm making a dumb mistake somewhere



    (setq ss1 (ssget "x" '((0 . "VIEWPORT"))) ctr 0)
    (repeat (sslength ss1)
    (setq en1 (ssname ss1 ctr) ctr (+ 1 ctr)
    end1 (entget en1)
    obj1 (vlax-ename->vla-object en1)
    objscl1 (vlax-safearray->real (vla-get-customScale obj))
    objlay1 (cons (strcat (cdr (assoc 410 end1)) ": Has a Scale of "
    (rtos (/ 1 objscl1))) objlay1)
    )
    (acad_strlsort objlay1)
    (foreach vp1 objlay1 (princ (strcat "\n" vp1)))
    )


    Now if someone can explain how I get the layout name from a pspace viewport
    (which I can't see in the dump), I might learn a wee bit more about vlisp...


    Thanks

    Jamie Duncan
     
    Jamie Duncan, Apr 27, 2004
    #1
  2. Jamie Duncan

    Mike Weaver Guest

    Jamie,
    You've already got it:
    (cdr (assoc 410 end1)) is the layout name for the subject viewport

    Unless I missunderstood the question, which may be the case:)


    Mike
     
    Mike Weaver, Apr 27, 2004
    #2
  3. Jamie Duncan

    PG. Guest

    (vl-load-com)
    ;; add
    (setq ss1 (ssget "x" '((0 . "VIEWPORT"))) ctr 0)
    (repeat (sslength ss1)
    (setq en1 (ssname ss1 ctr) ctr (+ 1 ctr)
    end1 (entget en1)
    obj1 (vlax-ename->vla-object en1)
    ;;objscl1 (vlax-safearray->real (vla-get-customScale obj)) ;;
    commented
    objscl1 (vla-get-customScale obj1)
    ;; and corrected
    objlay1 (cons (strcat (cdr (assoc 410 end1)) ": Has a Scale of "
    (rtos (/ 1 objscl1))) objlay1)
    )
    (acad_strlsort objlay1)
    (foreach vp1 objlay1 (princ (strcat "\n" vp1)))
    )
     
    PG., Apr 27, 2004
    #3
  4. Jamie Duncan

    Jamie Duncan Guest

    Ahhh,

    so,

    objscl1 (vla-get-customScale obj1)

    returns a real, not a safearray.

    Thanks!

    Jamie Duncan
     
    Jamie Duncan, Apr 27, 2004
    #4
  5. Jamie Duncan

    Jamie Duncan Guest

    Thanks for the reply Mike. I have the vl-vload-com activedocument stuff in
    my startup suite.

    Jamie Duncan
     
    Jamie Duncan, Apr 27, 2004
    #5
  6. Jamie Duncan

    Jamie Duncan Guest

    Oh, thanks PG. can you tell me with vlisp how I obtain the layout name?

    Seems strange that I can get it with old lisp and dxf and not vlisp.

    Jamie Duncan
     
    Jamie Duncan, Apr 27, 2004
    #6
  7. Jamie Duncan

    Jeff Mishler Guest

    Here you are, Jamie. Note that *doc* & vport must be valid pointers to the
    Activedocument and the PS Vport in question.

    (setq layout_name (vla-get-name
    (vla-get-layout
    (vla-objectidtoobject *doc*
    (vla-get-ownerid vport)
    )
    )
    )
    )

    HTH,
    Jeff
     
    Jeff Mishler, Apr 27, 2004
    #7
  8. Jamie,

    Take a moment to look at the object model map in the documentation. Under
    the PViewport object do you see any properties that jump out at you?
    Something that starts with "Owner..."? ;^)


    --
    R. Robert Bell


    Oh, thanks PG. can you tell me with vlisp how I obtain the layout name?

    Seems strange that I can get it with old lisp and dxf and not vlisp.

    Jamie Duncan
     
    R. Robert Bell, Apr 27, 2004
    #8
  9. Jamie Duncan

    PG. Guest

    Hi Jamie,

    (cdr (assoc 410 end1))

    Also, you can query the object by (vlax-dump-object obj) [where obj is a
    vla-object]

    -PG.
     
    PG., Apr 27, 2004
    #9
  10. Jamie Duncan

    Jamie Duncan Guest

    Thanks Robert.

    Jamie Duncan
     
    Jamie Duncan, Apr 27, 2004
    #10
  11. You can use this little helper to get the owner of any object:

    (defun Get-Owner (obj)
    (vla-ObjectIdToObject
    (vla-get-Database obj)
    (vla-get-OwnerId obj)
    )
    )

    To get the name of the layout:

    (vla-get-Name (vla-get-Layout (get-owner <PViewportObj>)))
     
    Tony Tanzillo, Apr 27, 2004
    #11
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.