viewport from an object

Discussion in 'AutoCAD' started by mnash, Jul 16, 2004.

  1. mnash

    mnash Guest

    I have a working Lisp routine that utilizes
    "(setq VS (cdr (assoc 45 VP)))" from a viewport where "VP" is assigned earlier.
    This works great for a typically made viewport. But there are times when I need it to work for a viewport that is created form an object. Using the following as a basis:
    (defun c:get ()
    (prompt "\nSelect entity: ")
    (setq ent (car (entsel)))
    (setq e1 (entget ent))
    )
    can I retrieve the "assoc 45" from a viewport made from an object. If you select a viewport that was created from an object, two objects are selected. Can you filter the polyline, (rectangle, circle or whatever it is) to manipulate the viewport only.

    All that in one breath
     
    mnash, Jul 16, 2004
    #1
  2. mnash

    T.Willey Guest

    (if e1
    (and (/= (cdr (assoc 0 VPortEnt)) "VIEWPORT")
    (= (cdr (assoc 102 VPortEnt)) "{ACAD_REACTORS")
    ); and
    (setq vpent2 (entget (cdr (assoc 330 e1))))
    )

    Tim
     
    T.Willey, Jul 16, 2004
    #2
  3. mnash

    T.Willey Guest

    Sorry long morning.

    (if
    (and (/= (cdr (assoc 0 e1)) "VIEWPORT")
    (= (cdr (assoc 102 e1)) "{ACAD_REACTORS")
    ); and
    (setq vpent2 (entget (cdr (assoc 330 e1))))
    )

    Tim
     
    T.Willey, Jul 16, 2004
    #3
  4. mnash

    mnash Guest

    I know long day here too

    That seems to work fine o the viewport that has been created from the object and the "assoc's" are the saem as a regular viewport, but now it's not recognizing the regular viewport

    You rock T
    MN
     
    mnash, Jul 16, 2004
    #4
  5. mnash

    T.Willey Guest

    Change this line
    (setq vpent2 (entget (cdr (assoc 330 e1))))
    to
    (setq e1 (entget (cdr (assoc 330 e1))))

    And in your list do a "find/replace", where you find "vpent2" and replace with "e1". The (if.. statement I gave you will only change youe "e1" if it's not a viewport, so I should have just used your "e1" to be set to the viewport behind the other object instead of "vpent2". Then it should work, if not post your code so I (or someone else here) can help trouble shot it.

    Tim
     
    T.Willey, Jul 16, 2004
    #5
  6. mnash

    Jürg Menzi Guest

    As I answered to your last thread:

    This snippet shows how to select the correct entity:

    (prompt "\nSelect Viewport... ")
    (setq SelSet (ssget "_:E:S" '((0 . "VIEWPORT")))
    VptEnt (ssname SelSet 0)
    )

    Cheers
     
    Jürg Menzi, Jul 17, 2004
    #6
  7. mnash

    mnash Guest

    Here is the small version of the Lisp. This one basically just retrieves the assoc's of an object to view. The concept exists in the much bigger Lisp.
    Here is the small one:
    (defun c:get ()
    (prompt "\nSelect entity: ")
    (setq ent (car (entsel)))
    (setq e1 (entget ent))
    (if
    (and (/= (cdr (assoc 0 e1)) "VIEWPORT")
    (= (cdr (assoc 102 e1)) "{ACAD_REACTORS")
    ); and
    (setq e1 (entget (cdr (assoc 330 e1))))
    )
    )

    In my drawing, I have two objects:1) a viewport that has been created form a circle, and 2) a typically created viewport. The lisp works on the viewport from the object, but comes up "nil" on the second viewport. I look forward to your response.

    Cheers
    mn
     
    mnash, Jul 19, 2004
    #7
  8. mnash

    T.Willey Guest

    MN,

    That seems to work for me. The nil returned is just saying that the (if... statement didn't need to do anything, but e1 should get set.

    Jurg's way is a possibility if you want to use selection sets.

    Here is what my acad says when I pick a regular viewport:

    Command: get

    Select entity: nil

    Command:
    Command: !e1
    ((-1 . <Entity name: 7ef6cd98>) (0 . "VIEWPORT") (330 . <Entity name:
    7ef6cce8>) (5 . "33") (100 . "AcDbEntity") (67 . 1) (410 . "Layout1") (8 . "0")
    (100 . "AcDbViewport") (10 6.20766 5.65773 0.0) (40 . 8.13248) (41 . 6.24777)
    (68 . 3) (69 . 2) (12 6.0 4.5 0.0) (13 0.0 0.0 0.0) (14 0.5 0.5 0.0) (15 0.5
    0.5 0.0) (16 0.0 0.0 1.0) (17 0.0 0.0 0.0) (42 . 50.0) (43 . 0.0) (44 . 0.0)
    (45 . 9.35831) (50 . 0.0) (51 . 0.0) (72 . 1000) (90 . 32864) (281 . 0) (71 .
    1) (74 . 0) (110 0.0 0.0 0.0) (111 1.0 0.0 0.0) (112 0.0 1.0 0.0) (79 . 0) (146
    0.0) (170 . 0))

    Here you can see that e1 is getting set.

    Tim
     
    T.Willey, Jul 19, 2004
    #8
  9. mnash

    Jürg Menzi Guest

    mnash

    This does exactly what you want:
    (defun c:get ( / SelSet)
    (prompt "\nSelect Viewport... ")
    (if (setq SelSet (ssget "_:E:S" '((0 . "VIEWPORT"))))
    (entget (ssname SelSet 0))
    )
    )
    - Returns the viewport entity list
    - nil when nothing or no viewport selected

    Cheers
     
    Jürg Menzi, Jul 19, 2004
    #9
  10. mnash

    mnash Guest

    Jürg and Tim
    You're combined efforts have taught me a lot. I appreciate you're efforts to help me. From your recomendations, I've taken and slighly modified your lines of text and inserted it in to the huge LISP I have. It works perfect.
    Forever in debt. Thanks again
     
    mnash, Jul 19, 2004
    #10
  11. mnash

    mnash Guest

    a question, what does the E:S do
    curiosity speaking
     
    mnash, Jul 19, 2004
    #11
  12. mnash

    T.Willey Guest

    I'm not sure, but from testing it out, the ":E" lets you select the entity one at a time while the ":S" gives you only one pass at selecting objects. So with the combo of ":E:S" it's saying pick one entity (no window or crossing).

    Tim
     
    T.Willey, Jul 19, 2004
    #12
  13. mnash

    Jürg Menzi Guest

    Hi mnash

    Welcome...¦-)
    From the AutoLISP help:
    :E Everything within the cursor's object selection pickbox.
    :S Allow single selection only.

    Cheers
     
    Jürg Menzi, Jul 19, 2004
    #13
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.