elegent way to see if paperspace is empty?

Discussion in 'AutoCAD' started by James Maeding, Oct 15, 2004.

  1. I have to test if there are any entities in any of the layout tabs, any obvious way to do this with lisp?
    I am going to try looking at the non-modelspace collections but I think there has to be a quicker way...
    thanks
    James Maeding
    jmaeding at hunsaker dot com
    Civil Engineer/Programmer
     
    James Maeding, Oct 15, 2004
    #1
  2. James Maeding

    R.K. McSwain Guest


    What about:

    (ssget "X" '((67 . 1)))
     
    R.K. McSwain, Oct 15, 2004
    #2
  3. James Maeding

    Jeff Mishler Guest

    Something like this?
    (defun c:empty_tabs (/ doc tabs)
    (setq doc (vla-get-activedocument (vlax-get-acad-object))
    tabs (vla-get-layouts doc))
    (vlax-for tab tabs
    (setq blk (vla-get-block tab))
    (if (= (vla-get-count blk) 1); use 1 since an empty tab still has the
    main PS viewport
    (princ (strcat "\n" (vla-get-name tab)))
    )
    )
    (vlax-release-object tabs)
    (vlax-release-object doc)
    (princ)
    )
     
    Jeff Mishler, Oct 15, 2004
    #3
  4. Actually, even a brand new blank drawing has a couple items in it, at a minimum, the paperspace block.

    The reason I asked the question was because the -AecObjExplode command , needed for killing the AEC objects before
    converting to A2000 format, changes its prompts based on if any visible objects exist in paperspace.

    Its crazy because even though the "ADCADD_ZZ" block exists in the paperspace, that does not trigger the -AecObjExplode
    command to ask what it nornally does when stuff is in PS.

    So here is what I wrote:
    It allows for the case of an empty drawing with the invisible "ADCADD_ZZ" block.
    Its still brute force though.

    (DEFUN ANY-PS-ITEMS ( / LAYOUT NAME SS RET)
    ;LOOP THROUGH LAYOUTS
    (VLAX-FOR LAYOUT (VLA-GET-LAYOUTS (VLA-GET-ACTIVEDOCUMENT (VLAX-GET-ACAD-OBJECT)))
    (IF (AND
    (/= (SETQ NAME (VLA-GET-NAME LAYOUT)) "Model")
    (SETQ SS (SSGET "x" (LIST (CONS 410 NAME))))
    (> (SSLENGTH SS) 1)
    ;IF ONE IS VP AND ONE IS ZZ BLOCK...
    (NOT (AND (= (SSLENGTH SS) 2)
    (SSGET "x" (LIST (CONS 410 NAME)(CONS 2 "ADCADD_ZZ")))
    )
    )
    )
    (SETQ RET 1)
    )
    )
    RET
    )

    James Maeding <>
    |>I have to test if there are any entities in any of the layout tabs, any obvious way to do this with lisp?
    |>I am going to try looking at the non-modelspace collections but I think there has to be a quicker way...
    |>thanks
    |>James Maeding
    |>jmaeding at hunsaker dot com
    |>Civil Engineer/Programmer

    James Maeding
    jmaeding at hunsaker dot com
    Civil Engineer/Programmer
     
    James Maeding, Oct 15, 2004
    #4
  5. James Maeding

    CJ Follmer Guest

    The reason I asked the question was because the -AecObjExplode command ,
    needed for killing the AEC objects before
    paperspace, that does not trigger the -AecObjExplode
    ADCADD_ZZ has nothing to do with ADT ojbects. It is used for the AEC
    details which is came from softdesk. A left over if you will. The AEC
    details and the ADT objects are completely separate things so aecobjexplode
    has no need to worry about it.

    are you using ADT 2004/5 or 3?

    cj
     
    CJ Follmer, Oct 15, 2004
    #5
  6. Wait, I never said this was ADT.
    You must have assumed that from the -AecObjExplode command.
    I am actually using LDT2005 and the -AecObjExplode must be used before doing a saves to 2000 format.

    I am well aware of the Export to Acad command in the Land menu, its lousy though because the land menu does ugly things
    to batch scripters. I am trying to automate the -AecObjExplode so I can run it in a batch on lots of files.
    I also know of the Etransmit way of doing this, Etransmit is lousy for selecting files recursively.

    So my questions have nothing to do with a judgement of what needs to be exploded or not.
    They have to do with detecting the conditions that cause the -AecObjExplode to change its prompts.
    Once I get that nailed, I let the -AecObjExplode explode what it wants to.

    thanks

    "CJ Follmer" <cjfollmer@NOT - SO - h_o_t_m_a_i_l_.com>
    |>> The reason I asked the question was because the -AecObjExplode command ,
    |>needed for killing the AEC objects before
    |>> converting to A2000 format, changes its prompts based on if any visible
    |>objects exist in paperspace.
    |>>
    |>> Its crazy because even though the "ADCADD_ZZ" block exists in the
    |>paperspace, that does not trigger the -AecObjExplode
    |>> command to ask what it nornally does when stuff is in PS.
    |>
    |>ADCADD_ZZ has nothing to do with ADT ojbects. It is used for the AEC
    |>details which is came from softdesk. A left over if you will. The AEC
    |>details and the ADT objects are completely separate things so aecobjexplode
    |>has no need to worry about it.
    |>
    |>are you using ADT 2004/5 or 3?
    |>
    |>cj
    |>

    James Maeding
    jmaeding at hunsaker dot com
    Civil Engineer/Programmer
     
    James Maeding, Oct 15, 2004
    #6
  7. James Maeding

    CJ Follmer Guest

    I'm trying to remember what all i had to look for in my old SaveAsR14
    routine i did for ADT. Like you said there were all these conditions to
    look for.

    viewports
    AEC layers - X_* and AECOBJEXPLODE_*
    xrefs
    or none of the above

    Again though ADCADD_ZZ is a left over from softdesk days. It was used with
    the civil package as well as the architectural one. It is not what
    aecobjexplode looks for to remove. It is meant for backwards compatibility
    with older S8 stuff.

    hopefully what i've posted will help you. I wrote a routine which i used to
    make the dumbing down to r14 easier and as you stated the AecObjExplode
    routine changes its prompts based on what's in the drawing. My routine had
    to account for that and respond correctly.

    CJ
     
    CJ Follmer, Oct 15, 2004
    #7
  8. but I just want to go to A2000 format, see my new thread for the solution

    "CJ Follmer" <cjfollmer@NOT - SO - h_o_t_m_a_i_l_.com>
    |>I'm trying to remember what all i had to look for in my old SaveAsR14
    |>routine i did for ADT. Like you said there were all these conditions to
    |>look for.
    |>
    |>viewports
    |>AEC layers - X_* and AECOBJEXPLODE_*
    |>xrefs
    |>or none of the above
    |>
    |>Again though ADCADD_ZZ is a left over from softdesk days. It was used with
    |>the civil package as well as the architectural one. It is not what
    |>aecobjexplode looks for to remove. It is meant for backwards compatibility
    |>with older S8 stuff.
    |>
    |>hopefully what i've posted will help you. I wrote a routine which i used to
    |>make the dumbing down to r14 easier and as you stated the AecObjExplode
    |>routine changes its prompts based on what's in the drawing. My routine had
    |>to account for that and respond correctly.
    |>
    |>CJ
    |>

    James Maeding
    jmaeding at hunsaker dot com
    Civil Engineer/Programmer
     
    James Maeding, Oct 15, 2004
    #8
  9. James Maeding

    CJ Follmer Guest

    The conditions existed whether i was saving it to 14, 2000 or 13. My
    routine was for ADT 3 and 2 on 2000-2002 but those were the conditions I
    always had to look for. Perhaps your conditions are different but in my
    experience with ADT, it wasn't just any object in PS. It was *only*
    viewports because the aecobjexplode command would make a block of the
    contents in each viewport so the layouts could be properly plotted.

    I don't have access to LDT2005 here on this PC so i can't check your
    routine. They haven't installed here for me to play with :(

    Try asking in the LDT customization group if there are any other conditions
    you need to check. I found out about which conditions to look for from the
    ADT one.

    good luck

    cj
     
    CJ Follmer, Oct 15, 2004
    #9
  10. cool, thx

    "CJ Follmer" <cjfollmer@NOT - SO - h_o_t_m_a_i_l_.com>
    |>The conditions existed whether i was saving it to 14, 2000 or 13. My
    |>routine was for ADT 3 and 2 on 2000-2002 but those were the conditions I
    |>always had to look for. Perhaps your conditions are different but in my
    |>experience with ADT, it wasn't just any object in PS. It was *only*
    |>viewports because the aecobjexplode command would make a block of the
    |>contents in each viewport so the layouts could be properly plotted.
    |>
    |>I don't have access to LDT2005 here on this PC so i can't check your
    |>routine. They haven't installed here for me to play with :(
    |>
    |>Try asking in the LDT customization group if there are any other conditions
    |>you need to check. I found out about which conditions to look for from the
    |>ADT one.
    |>
    |>good luck
    |>
    |>cj

    James Maeding
    jmaeding at hunsaker dot com
    Civil Engineer/Programmer
     
    James Maeding, Oct 15, 2004
    #10
  11. James Maeding

    David Bethel Guest

    (princ "\nPaperspace Viewports = ")
    (prin1 (if (setq ss (ssget "X" '((0 . "VIEWPORT")(67 . 1))))
    (sslength ss) 0))
    (princ "\nPaperspace Entities = ")
    (prin1 (if (setq ss (ssget "X" '((0 . "~VIEWPORT")(67 . 1))))
    (sslength ss) 0))

    -David
     
    David Bethel, Oct 16, 2004
    #11
  12. actually that does not work in my case.
    Its funny because that is the first thing I tried and a worthy post since it illustrates the ability to use wcmatch type
    syntax in the ssget "x" method - very slick.
    For me, you have to do some additional tests to see if there were invisible blocks returned which the objectexplode
    command does not consider as being there.

    So I guess your code is correct but just needs some further filtering. Thanks for the reply as I was not quite sure if
    the ~ thing worked but it does.

    David Bethel <>
    |> (princ "\nPaperspace Viewports = ")
    |> (prin1 (if (setq ss (ssget "X" '((0 . "VIEWPORT")(67 . 1))))
    |> (sslength ss) 0))
    |> (princ "\nPaperspace Entities = ")
    |> (prin1 (if (setq ss (ssget "X" '((0 . "~VIEWPORT")(67 . 1))))
    |> (sslength ss) 0))
    |>
    |>-David
    |>
    |>James Maeding wrote:
    |>> I have to test if there are any entities in any of the layout tabs, any obvious way to do this with lisp?
    |>> I am going to try looking at the non-modelspace collections but I think there has to be a quicker way...
    |>> thanks
    |>> James Maeding
    |>> jmaeding at hunsaker dot com
    |>> Civil Engineer/Programmer

    James Maeding
    jmaeding at hunsaker dot com
    Civil Engineer/Programmer
     
    James Maeding, Oct 18, 2004
    #12
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.