Selection Loss

2»

Comments

  • Michael Mayer
    edited June 2018

    OMG
    I use parentheses and even nested parentheses all over my forum posts
    to structure my text walls.
    (And even didn't care about "lather, rinse, repeat" (reverse logic))
    I wasn't aware of the danger that an ACAD user might try to execute my code.

    Why bother learning LISP when there is Diesel or C#

    Just kidding.
    I am happy that I can follow your first examples :)

  • @Anthony Apostolaros said:
    Here are the two custom commands I suggested earlier:
    (defun c:BEFORE () (setq LastE (entlast))) ; ------------------------ (defun c:AFTER ( / NewSS) (setq NewSS (_ssafter LastE)) (if NewSS (sssetfirst nil NewSS) (sssetfirst nil (ssget "P"))) )
    You don't need to understand them in order to use them. You can just copy that text and paste it into an unformatted text file called on_doc_load.lsp in the Support folder of your Bricscad program folder. Then the two commands will always be available, and you can include them in command macros:
    before;^C^Crectang;\\^C^Cafter;
    before;^C^Cline;\\^C^Cafter;
    before;copy;\\^C^Cafter;

    I took some time to go through this at the weekend and actually try it out, but for some reason this fails to work I get an error message that there is no function definition for <_ssafter>
    I also can't find any references to a lisp function 'ssafter' anywhere on the internet, could it be that this is also a custom function that needs to be defined?

    I did manage to put together a few macros using lisp for making selections based on different entity properties which I'm really happy actually worked.

  • Anthony Apostolaros
    edited January 2019

    @Steven_g said:
    ....
    I also can't find any references to a lisp function 'ssafter' anywhere on the internet, could it be that this is also a custom function that needs to be defined?
    ....

    Sorry about that. I should have known it wasn't a built-in function, just from the fact that the function name begins with the underline character.

    You're right, it's a custom function, created by the brilliant MP, of The Swamp, revised per comments made by the brilliant Lee Mac. The revised version is in the third post at http://www.theswamp.org/index.php?topic=49346.0. You can get the function definition code there, in the style that real lisp programmers use, or here it is re-formatted in an amateur style that makes it easier for me to understand:
    (defun _SSAfter ( ename / ss d e ) (if (eq 'ename (type ename)) (progn (setq ss (ssadd)) (setq e (entnext ename)) (while e (if (and (setq d (entget e)) (null (member (cdr (assoc 0 d)) '("VERTEX" "ATTRIB" "SEQEND"))) ) ; end And (ssadd e ss) ) ; end 2nd If (setq e (entnext e)) ) ; end While (if (and (eq 'pickset (type ss)) (< 0 (sslength ss))) ss) ))) ; end Progn, 1st If, Defun

    So I assume you want to terminate commands with a selection set? I don't know what else that (After) function could be used for. If so, note that to work that way you have to keep PickAdd off. And so you have to draw with complex entities such as polylines, and use quick selection filters, so that you can usually create the selection set you want with just a single window or crossing. I made a bunch of two- and three-letter selection set filters, which you're welcome to if you want them. And for times when I can't create the selection set with a single window or crossing, I made this toggle for the PickAdd variable (though actually I use it so rarely that I usually can't remember what to type to get it):
    (defun c:Add () (sssetfirst nil nil) (if (= (getvar "PICKADD") 0) (progn (setvar "PICKADD" 1) (princ "PICKADD = Add to selection set.")) (progn (setvar "PICKADD" 0) (princ "PICKADD = Don't add selection set.")) ))BAD IDEA. See below.

  • To tell you the truth, I am happy that the function was missing, I was going through your earlier posts trying to follow the logic and reading up on the various functions, it was all starting to make sense until I reached _ssafter, I tried to follow along on your other examples and made some of my own that worked, but kept getting lost with _ssafter I really couldn't understand why the logic didn't look right, and when I tried it in Bricscad it reported an error (spelling mistake ? missing bracket ?) I eventually worked out the only thing wrong was "something is missing", I'm really glad I got that far.
    It is hopefully a sequence I can use, I tend to create a string of objects for use in BIM and then go back and classify them and give them properties and this looks like a good method to add into the workflow.
    And yes at the moment selection sets are bugging me, how they work (or don't yet), and the different ways they can be created (and emptied).

  • Good idea. You can use Before as a marker, and then later use After to select everything created after that marker.

    What's bugging you about selection sets? How aren't they working?

  • Steven_g
    edited July 2018

    When I was younger, I used to take things apart to see how they work, (and left them in pieces), the fact that my clockwork car no longer worked wasn't even an issue, I now knew how it worked inside the casing. Later I would start putting them back together but having a clockwork car is boring, knowing what makes it tick is the important bit.
    I really am at the very basics in LISP, if I draw a couple of lines in Bricscad or Autocad and run (setq ss(ssget "x")) it is my understanding that it creates a selection set of all elements in the drawing, but what? how can you see whats in the selection set, it's that basic level that I can't visualize, because each time I run (setq ss(ssget "x")) I get a different return result in Bricscad or Autocad and reseting ss to nil and repeat then still gives different results. How can you see what ss contains, !ss or (princ ss) just give some random values. How can you follow what is going on. In Excel VBA you can step through a program hover over a variable and actually see what is happening. At the moment I'm looking for "Pirsig's Brick" (from Zen and the art of motorcycle maintenance) just trying to "see".

  • Ricardo Cruz
    edited July 2018

    @Michael Mayer said:
    Is there any chance to not lose a tediously created Selection,
    like when using "classifying as Wall" and you would like to go on manipulating or editing ?

    Or even worse, losing the selection when you just want to fit your View
    by things like "Zoom Extends"

    I wish we could do it without coding...

  • So long as you have actually done something with the selection, then "select-previous" will reselect it. I often (in macros) will move a selection from 0,0 to 0,0 (nowhere) but that at least puts the selected items into memory, so it can be re-selected for the next set of commands.

  • Anthony Apostolaros
    edited July 2018

    @Steven_g said:
    ....
    .... if I draw a couple of lines in Bricscad or Autocad and run (setq ss(ssget "x")) it is my understanding that it creates a selection set of all elements in the drawing, but what? how can you see whats in the selection set....

    A lisp selection set isn't the same as what we normally call a selection set, i.e. a highlighted and gripped selection set. You can't see a lisp selection set until you use the (sssetfirst) function to highlight its entities and show their grips. But that will only show you which of the entities in the current tab are in ss. Changing to another tab automatically cancels all highlighted and gripped selections.

    But the lisp selection set isn't affected by changing tabs, so when you change to that other tab and then execute (ssetfirst nil ss) again, you'll see which entities in that tab are in ss. That should be all of them, since you used the "x" switch in (ssget).

    Note also that commands only operate on the part of the selection set that's in the current tab. That's even true of commands issued via the (command) function. But other lisp functions will operate on the entire lisp selection set. So, for example, Theodorus Winata's "LV" command locks all viewports in the file, not just the ones in the current layout tab. It uses (ssget "x") to select them, and then uses another lisp function, (vla-put-DisplayLocked), to lock them.

  • Anthony Apostolaros
    edited January 2019

    @Anthony Apostolaros said:
    ..... for times when I can't create the selection set with a single window or crossing, I made this toggle for the PickAdd variable (though actually I use it so rarely that I usually can't remember what to type to get it):
    (defun c:Add () (sssetfirst nil nil) (if (= (getvar "PICKADD") 0) (progn (setvar "PICKADD" 1) (princ "PICKADD = Add to selection set.")) (progn (setvar "PICKADD" 0) (princ "PICKADD = Don't add selection set.")) ))

    I did have occasion to use that PICKADD toggle recently, and the result was disastrous. If you're going to work in this pseudo-VectorWorks/Sketchup mode, I recommend never having PICKADD on except temporarily for creating a single selection set. The following custom version of the SELECT command does that. It creates and highlights a selection set with PICKADD on, and then turns PICKADD off automatically:
    (defun c:SS () (sssetfirst nil nil) (defun *error* (msg) (setvar "PICKADD" 0) ) (command "PICKADD" 1) (command "_select" pause) (sssetfirst nil (ssget "P")) (setvar "PICKADD" 0) (sssetfirst nil (ssget "P")) )

  • I think I could live with a PICKADD Mode.
    As long as there would be a counterpart that does strictly De_Selection only.
    Like any 3D Mesh Model App provides.

    Like by ALT+Click
    (But that does already something arbitrary like activating perspective camera
    and moving my geometry view out of the screen ...)

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!