Jump to content

If theres an Implied selection, add it to the new one


Recommended Posts

Posted

Hello guys,

I'm using this routine to filter objects by their layer:

(defun C:test ( / )

 (setvar 'errno 0)
 (setq ent (entsel "\nPick object to filter by its Layer"))
     (if (= (getvar 'errno) 7)
       (progn (princ "\nMissed.. Try again!")
              (C:test)
       )
       nil
     );if

 (setq layername (cdr (assoc 8 (entget (car ent))))) ;<-LayerName
 (if (= layername nil)
   (setq layername 256)
 )
 (princ (strcat "\nLayername to filter \"" layername "\" " ))

 (princ "\nSelect objects to filter and press enter OR press enter right away to filter all: \n")
 (if (not (setq sset (ssget (list (cons 8 layername)))))
     (setq sset (ssget "_X" (list (cons 8 layername) (cons 410 (getvar 'ctab)))))
 )
 (sssetfirst sset sset)
 (princ (strcat "\nSelected " (itoa (sslength sset)) " objects on layer \"" layername "\" "))

 (princ)

);defun

My question is if I have pre-selected objects, how do I add them to my new filtered selection (sset) ?

 

For example:

I filter some objects by their layer1, then I re-run the routine and filter other objects by their layer2, and in the end I got selection containing (layer1 + layer2 ... and so on)

 

I have read about implied selection, but I don't have idea how to nest it with the new one (if it exists).

Posted

Hi Grrrr. Implied selection is what you need as where you read about them, where obviously you took some inspiration for a part your routine.

With a simple if like that maybe? :)

 

(defun c:select-opt ( / ss)
 (princ "\nSelect objects and press enter or press enter right away to select all: \n")
 (if (not (setq ss (ssget "_:L" '((0 . "TEXT,MTEXT")))))
     (setq ss (ssget "_X" (list '(0 . "TEXT,MTEXT") (cons 410 (getvar 'ctab)))))
 )
 (princ (itoa (sslength ss)))
 )

 

 

I limited the ssget _x to the current tab only, without it it would select from all tabs and model as well.

 

Cheers!

Jef!

Receiving some credit is always appreciated, and might help getting answers. Mini rant over, heres an example on how to grab it.

[humourtag]
(defun c:IsThereASelectionMadeAlready ( / VariableThatWillContainTheSelectionSetIfThereWereObjectsPreviouslySelected)
(if (setq VariableThatWillContainTheSelectionSetIfThereWereObjectsPreviouslySelected (ssget "_I"))
   (alert "A selection was already made when this lisp was launched!")
   (alert "No objects are selected yet!"))
 (princ)
 )
[/humourtag]

 

You can add single entities a selection set with (ssadd ). If you want to merge together 2 selection sets, you must iterate thru one selection set and add items one by one to the second one using that method.

 

Another good thing to know, using ssadd on its own (setq selectionset (ssadd)) would create an empty selection set to which you could add entities (again, using the same method described precedingly).

 

I'm not sure i fully understood your goal, but here are some thougths

  (setq ent (entsel "\nPick object to filter by its Layer"))
     (if (= (getvar 'errno) 7)
       (progn (princ "\nMissed.. Try again!")
              (C:test)
       )
       nil
     )

Quite few issues right here. Right click (or enter) instead of making a selection will cause errno 52, (bad argument type: lentityp nil). Beside that it doesnt just relaunch the command, but relaunch it recursively. Lets put that graphically

If you have a random command like the following

(defun c:randomcommand ()
  (conditionnally execute command A)
  (execute command B)
  (execute command C)
)

In that example it is clear that

Randomcommand starts

Randomcommand will execute (or not) command A

Randomcommand will execute command B

Randomcommand will execute command C

End of randomcommand

Now lets take the same example changing one thing, naming the function A instead of randomcommand

(defun c:A ()
  (conditionnally execute command A)
  (execute command B)
  (execute command C)
)

Assuming that the criteria to conditionnally execute command A is met the first time

command A starts

command A will execute (or not) recursively command A.. it does

recursive command A starts

recursive command A will execute (or not) recursively command A.. it does not

recursive command A will execute command B

recursive command A will execute command C

End of recursive command A

command A will execute command B

command A will execute command C

End of command A

When the recursive command A ends, The command A will keep running. Basically with your code, for every time you misclick the remainder of your code will get evaluated one time too many.

 

In the following code, I fixed that, and also merged the active selection set at launch every time with the new selection.

(defun c:test ( / SelectedFirst ent layername sset sspos e)
 ;Jef! 2016-02-25
 (vl-load-com)
 (setvar 'errno 0)
 (if (setq SelectedFirst (ssget "_I"))
     (sssetfirst nil nil);required
 )
 (while (not (and (setq ent (car(entsel "\nSelect an object of the required layer: ")))
	   (setq layername (cdr (assoc 8 (entget ent))))
             )
 )
 (cond
           (   (= 52 (getvar 'errno))
               (princ "\nYou must select an object.")
           )	   
           (   (null ent)
               (princ "\nYou missed, try again.")
           )
        )
 )
 (princ (strcat "\nLayername to filter \"" layername "\" " ))
 (princ "\nSelect objects to filter and press enter OR press enter right away to filter all: \n")
 (if (not (setq sset (ssget (list (cons 8 layername)))))
           (setq sset (ssget "_X" (list (cons 8 layername) (cons 410 (getvar 'ctab)))))
       )
 (if SelectedFirst
   (progn
     (setq sspos (sslength SelectedFirst))
     (while (setq e (ssname SelectedFirst (setq sspos (1- sspos))))
     (ssadd e sset)
     )
   )
 )
 (sssetfirst nil sset)
 (vla-Regen (vla-get-ActiveDocument (vlax-get-acad-object)) acActiveViewport)
 (princ)
)

At the beginning, after storing the implied selection into a variable i deselected it (commented "required" in my code) because to quote M.Lee Mac note that ssget will honour an implied selection by default providing PICKFIRST=1., meaning that if you use (ssget (list (cons 8 "0"))), it will ask for a selection. If you use it having things on the layers 1 2 and 3 selected, it will drop the selection and prompt you to make another one... but if you use it having things on the layers 0 1 and 2 selected, it will not prompt for the user to make a selection, it will instead use the one already made, and remove everything that is not on the layer 0.

 

That being said, another reason why I think you didn't get any replies yet is that I personally see that as a typical X Y problem. You have a problem X. As Y beeing the solution you think is best suited (using and merging an implied selection with any other selection that will be made) you ask about Y without talking about the problem X. We have no clue what exactly you need/are trying to achieve (my feeling is that you want to make a global selection, then select things one by one and have the lips make/return a selection of everything that is on the same layers as chosen objects so far, within the original global selection. If my feeling of what you are trying to achieve is wrong, most chances are that I might have lost some time in the "wrong direction". And if my feeling of what you are trying to achieve is right, most chances are that... I have lost some time in the "wrong direction" as well. I wouldn't use an implied selection and run the lisp routine many times in a row, I would instead use while statements to achieve the same result running the command only once. The code I provided might do the job, but as it is, if for any reason you have an involuntary manually made selection (maybe even outside of the screen) when you launch the command, you will get weird and unwanted results (maybe even without knowing why)... that is my 2 cents, from what I think you are trying to achieve. mini rant #2 over :)

 

That too being said, I answered because for a long time I wanted to play and try implied selections, wanted some exercises on selections merging/handling, because I wanted to use the errno variable that I just discovered (thanks to Lee!), because I wanted to make my 2 mini rants (hahaha), because it was fun, because....

 

I hope it (somewhat) helped!

Cheers

8)

Posted (edited)

Jef!, your reply is the best reply I ever recieved!

 

Receiving some credit is always appreciated, and might help getting answers. Mini rant over, heres an example on how to grab it.

Ofcourse I'll add you to the credits!

 

Maybe you already noticed that I got the first example from you - it didn't seemed hard to code this:

Quote Originally Posted by Jef! View Post

With a simple if like that maybe?

 

Code:

(defun c:select-opt ( / ss)

(princ "\nSelect objects and press enter or press enter right away to select all: \n")

(if (not (setq ss (ssget "_:L" '((0 . "TEXT,MTEXT")))))

(setq ss (ssget "_X" (list '(0 . "TEXT,MTEXT") (cons 410 (getvar 'ctab)))))

)

(princ (itoa (sslength ss)))

)

 

I limited the ssget _x to the current tab only, without it it would select from all tabs and model as well.

 

Cheers!

Jef!

 

Actually this routine is a small part from my bigger (selecion filter routine), soo its information will look like this (I hope everyone is happy in the credits):

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Routine Information ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;																					  ;
; Author: Grrr																				  ;
; Credits to: Lee Mac, Tharwat - I had(and took) many examples from them, about different parts of the code								  ;
;             AlanJT, CAB      - They made the first filter routines of this kind, I took that idea and decided to develop it						  ;
;             Jef!             - He gave me the best examples, for storing the Implied selection - which is a big deal, and the selection options (window sel or sel all) ;
;																					  ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

I just posted a part from it, to clear my question - because its important for me.

The whole routine is still in progress, I'll post it when I'm done. :)

I'm not a handsome coder, but I learn bit by bit, and I'm good with assembling stuff from other codes/examples.

 

And yeah, Lee Mac is everywhere (in every code), even when you don't expect it. I also learnt for errno variable from him (and many other stuff) :D

 

In the end the only thing that matters for me is the final routine (since we all are ACAD users/drafters). Well if not all, atleast I am! :)

 

I'll probably re-read your post several times to get it (because coding is hard), but the final result you posted is exactly what I wanted!

 

EDIT:

The more I read, more I see how complicated was the question I ask (well the slow or no replying comfirms it).

 

Well to answer to your feeling(it was right) with an example:

1. Run the routine

2. Select entity to store its layer (lets name it layer1)

3. Filter objects by that layer

4. Now when filtered, users keeps that selection

5. Re-run the routine

6. Select entity to store by its entity type (lets say thats a circle)

7. Filter objects by that entity type

8. The selection contains entities on layer1, and circle entities (no matter the layer)

 

This method provides unlimited stacking of filtered selections, which contains various objects.

And the next possibility is to ISOLATE/ERASE/SAVE AS NEW SELSET/etc... that final selection with other routine.

That was the whole concept...

 

Thank you Jef! ! :)

Edited by Grrr
Posted

Hi Grrr.

 

Well, your credits to section is very... kind. You forgot wife -> support and mummy -> good food! :P

Maybe my wording choice wasnt the best (english is my 2nd language)... Addind "many examples from them, about different parts of the code" doesnt say which part came from who. Lets say someone else would want to use a part of your final code, who made that specific part? It is not about going overboard, lets say I learned how to make "if" function using jeff sanders tutorials, i'm not going to thank jeff every time i use a "if". If I use a function made by someone, I keep the author original headers. Other examples, a day I asked for help, I made a tiny function (5 lines) that was very slow. I posted it here, and someone helped me and made it 50 times faster. In the header over the defun i added that comment

;; thanks for clint (cwake) who helped optimize

Sometimes ago I made one (cant find it, bravo microsoft on win7 content: x search not working) and the way I processed the object was inpired by someone, so I added

;inspired by peter jamtgaard wathever function (source: w w w .xxx)

It helps me keep track of what comes from where and find it back if needed, who wrote it, and if I post it on here to ask for help to enable others to know it too... and definitly from the beginning instead of on the final code posted at the end of the thread.

 

Well to answer to your feeling(it was right) with an example:

1. Run the routine

2. Select entity to store its layer (lets name it layer1)

3. Filter objects by that layer

4. Now when filtered, users keeps that selection

5. Re-run the routine

6. Select entity to store by its entity type (lets say thats a circle)

7. Filter objects by that entity type

8. The selection contains entities on layer1, and circle entities (no matter the layer)

Maybe I was partially right, but now that i'm reading that list, the way you wrote it - make a selection, chose 1 layer by picking an object, chose an entity type by picking an object (that part i havn't foreseen) makes me wonder: why not use the quickselect/filter native function?

 

This method provides unlimited stacking of filtered selections, which contains various objects.

And the next possibility is to ISOLATE/ERASE/SAVE AS NEW SELSET/etc... that final selection with other routine.

Maybe provide unlimited "AND" selections (selection of entities that are on layer x AND are circles AND...) If all the "filters" have to apply to the same original selection, I'd rather make the user complete his choices and making 1 ssget with the logic operators (and/or/not...) instead of have them process 1 at a time. As it is lets say you gather all on layer 1, then all circles, you end up with a selection set (A) on circles on layer 1. Then you want to add all rectangles on layer 2, would require selection B. If you do that you need 1 selection set per "and". Include B in A as soon as B is made you lose the option of going back if you misclick. You would have to start from scratch. I'm not sure saving them independently is a better idea, depending on what you want to achieve, as there is a limit to how many selection sets the selection set collection can hold. Both of these Y seems to lead in a dead end or non optimal approach. For sure X has a solution :)

 

You don't mention where in your 8 steps you make your global selection (or selectionS?) (selection on which your different filters would apply)

If all the filters apply to the same selection and lets say you want to make a selection to include

-multileaders on layer 0

-multileaders on layer 1

-any line that would start or end on the coordinate 55.0,45.0,0.0

-circles with radius of 1 that are on both layers 0 and layer 1

You could retrieve that with one unique ssget/ssget "x"

(ssget "_x"
  '(
       (-4 . "<OR")
           (-4 . "<AND") (0 . "MULTILEADER") (-4 . "<OR")  (8 . "1")(8 . "0") (-4 . "OR>") (-4 . "AND>")
           (-4 . "<AND") (0 . "LINE") (-4 . "<OR") (10 55.0 45.0 0.0) (11 55.0 45.0 0.0) (-4 . "OR>") (-4 . "AND>")
           (-4 . "<AND") (0 . "CIRCLE") (40 . 1.0)(-4 . "<OR")  (8 . "1")(8 . "0") (-4 . "OR>") (-4 . "AND>")
       (-4 . "OR>")
   )
)

While your code can enable somewhat unlimited stacking of manually made AND filters, some other approaches could be faster than asking the user to click for each geometry/layer samples. Think of all the clicking required to make a selection of circles on layers 0, 1 and 2, along with all lines on layers 0, 1 and 2. Doing that with "AND" filters on the ssget it would look like that.

(ssget "_x"
  '(
       (-4 . "<OR")
           (-4 . "<AND") (0 . "CIRCLE")  (8 . "0") (-4 . "AND>")
           (-4 . "<AND") (0 . "CIRCLE")  (8 . "1") (-4 . "AND>")
           (-4 . "<AND") (0 . "CIRCLE")  (8 . "2") (-4 . "AND>")
           (-4 . "<AND") (0 . "LINE")    (8 . "0") (-4 . "AND>")
           (-4 . "<AND") (0 . "LINE")    (8 . "1") (-4 . "AND>")
           (-4 . "<AND") (0 . "LINE")    (8 . "2") (-4 . "AND>")
       (-4 . "OR>")
   )
)

Few "or" can save a lot of "and", this will do the same job as the preceding code

(ssget "_x"
  '(
            (-4 . "<OR")(0 . "CIRCLE")(0 . "LINE")(-4 . "OR>") (-4 . "<OR") (8 . "0")(8 . "1")(8 . "2") (-4 . "OR>") 
   )
)

 

If instead of making them by picking you mold the ssget with a menu that look like the qselect menu, you could do it faster, and even store the ssget strings locally, make a list of "favorite" ssget strings (selection filter stacks), selecting right away instead of rewriting them every time. Now it probably starts to sound very interesting, right? Let me introduce you the same result as the above 2 ssget done with filter command sel_set_filter.png

You can build custom and complex filters, save and load them... sometimes what we need is right under our nose, out of the box :D

Jef!, your reply is the best reply I ever recieved!

I'm glad you didnt take the mini rants personnal and that I could help you out!

Cheers!

Posted

Hi, Jef!

Sorry for late reply

Well, about the credits stuff, maybe I'll shorten them - I just want to make everyone happy in there.

 

I don't see any english/wording mistakes from you - so no need to apologize (by the way english is my 2nd (or 3rd) language aswell) :D

 

Thank you for the tutorial (actually I'm not that familiar with FILTER command, but I know about QSELECT)

Do you think the examples you showed will work with dynamic block's names also?

I have tested with QSELECT (for example combine some objects on layer, some other objects, and a block by name), but I haven't succeeded.

I'm not sure how faster and easier would be with FILTER to do this, but I'll learn more about this command.

 

The reason I want the routine to "read" for the first picked entity's LAYER/TYPE/etc.. because I find it faster and easier.

Also sometimes I have to correct some exported drawings from programs like REVIT so I end up with a bunch of layers and blocks (and I think it will be slower to organize those filters in FILTER)

 

You don't mention where in your 8 steps you make your global selection (or selectionS?) (selection on which your different filters would apply)

Well I could answer with re-running the routine S times, until statisfied with the(stacked) global selection.

 

However, I'll check for the alternate solutions you gave me.

But my developed theory about working faster in autocad is to:

avoid populating and using such (alert)menus,

avoid typing strings in the routine

Simply to say the fastest way would be by "picking" objects (for example like MATCHPROP command is structured).

 

I'm glad you didnt take the mini rants personnal and that I could help you out!

How I can get offended when providing so much help and information? :)

Cheers!

Posted

Hi again!

Well I could answer with re-running the routine S times, until statisfied with the(stacked) global selection.

As your routine is right now, it asks for the "global selection to apply the filter you chose will apply to, then add it to the cumulative filtered selection. One thing I think might be more efficient would be to prompt for the global selection only once, unless you really need different global selections for each added filter. Using a while statement instead of inplied selection could have simplified things. Relaunching the command can look at the implied selection, but only allow 1 implied selection to be used. Using a while statement instead, since you would be running the command only once, you could then reuse the global selection to which apply the next filter, or redefine it only if you need to, instead of systematically having to query the user again and again to maybe indicate the same global selection time after time.

 

Do you think the examples you showed will work with dynamic block's names also?
mmm. maybe yes maybe no. That is an example of where a different approach might be required, depending on what you are trying to filter. Dynamic blocks are special. When you have a dynamic block, it has a "default state" (the one you see in the block editor. You can also use the "resetblock" command on any dynamic block to reset it, but you would of course "loose" any information that could be given by its state.) If you use lets say (ssget (list (cons 8 "0"))). If dynamic blocks are on layer 0, they will be in the selection set. The thing would not work the same way if you would want to grab all the dynamic blocks of the same name. Why? LEts say I have a dynamic block called "title". If I (entget(car(entsel))) it on its default state, i get that
((-1 . ) (0 . "INSERT") (5 . "86CF6") (102 . "{ACAD_XDICTIONARY") (360 . ) (102 . "}") (330 . ) (100 . "AcDbEntity") (67 . 1) (410 . "PAGE01") (8 . "0") (100 . "AcDbBlockReference") (66 . 1) (2 . "TITLE") (10 19.7826 -36.9387 0.0) (41 . 1.0) (42 . 1.0) (43 . 1.0) (50 . 0.0) (70 . 0) (71 . 0) (44 . 0.0) (45 . 0.0) (210 0.0 0.0 1.0))
Now, if I alter it dynamically, and entget it again, here's what I get
((-1 . ) (0 . "INSERT") (5 . "86CF6") (102 . "{ACAD_XDICTIONARY") (360 . ) (102 . "}") (330 . ) (100 . "AcDbEntity") (67 . 1) (410 . "PAGE01") (8 . "0") (100 . "AcDbBlockReference") (66 . 1) (2 . "*U174") (10 19.7826 -36.9387 0.0) (41 . 1.0) (42 . 1.0) (43 . 1.0) (50 . 0.0) (70 . 0) (71 . 0) (44 . 0.0) (45 . 0.0) (210 0.0 0.0 1.0))

It is now an anonymous block. The assoc 2 of a block is its name. If you would ssget every block having the same name as a dynamic block at its default state, you would only retrieve all other occurences of the block that currently are on their default state as well. If you would ssget every block having the same name as a dynamic block that is NOT at its default state, you would always end up with a selection of 1 (the original selection) as every anonymous block has a different number. And you don'T see anything to identify them if you entget them...

 

If you use (dumpAllProperties (car(entsel))) on a dyn block, you see that blocks have a IsDynamicBlock property. That is, I think, the only thing you can do with them using lisp. The only way to find these blocks would be by Visual-Lisp, which has some more properties and methods you can use for dynamic blocks. If you (vlax-dump-object (vlax-ename->vla-object(car(entsel)))) on a dynamic block, you can see..

Command: (vlax-dump-object (vlax-ename->vla-object(car(entsel))))
Select object: ; IAcadBlockReference: AutoCAD Block Reference Interface
; Property values:
;   Application (RO) = #<VLA-OBJECT IAcadApplication 00000001402ea130>
;   Document (RO) = #<VLA-OBJECT IAcadDocument 000000003cd78268>
;   [b]EffectiveName (RO) = "TITLE"  <--------------[/b]
;   EntityTransparency = "ByLayer"
;   Handle (RO) = "86CF6"
;   HasAttributes (RO) = -1
;   HasExtensionDictionary (RO) = -1
;   Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 000000003c77de78>
;   InsertionPoint = (19.7826 -36.9387 0.0)
;   InsUnits (RO) = "Inches"
;   InsUnitsFactor (RO) = 1.0
;   IsDynamicBlock (RO) = -1
;   Layer = "0"
;   Linetype = "ByLayer"
;   LinetypeScale = 1.0
;   Lineweight = -1
;   Material = "ByLayer"
;   [b]Name = "*U174" <---------[/b](...)

In other words, if you want to to make a selection set of all blocks that have a specific name, you need to determine if the source is a dynamic block. If it is a dyn block, retrieve its property "EffectiveName" and look for every other blocks that are dynamic and have the same "EffectiveName". If it is not a dyn block, you could look at the assoc 2 to retrieve its name... or use its vlisp "name" property, or maybe even just the same as dyn blocks, "EffectiveName" as per this little test I made

Command: (vlax-dump-object (vlax-ename->vla-object(car(entsel))))

Select object: ; IAcadBlockReference: AutoCAD Block Reference Interface

; Property values:

; Application (RO) = #

; Document (RO) = #

; EffectiveName (RO) = "thisIsANonDynamicBlock"

; EntityTransparency = "ByLayer"

(...)

; Lineweight = -1

; Material = "ByLayer"

; Name = "thisIsANonDynamicBlock"

 

I never really played with these, never really tested. I think this isformation will be usefull for you even if I'm not totally sure of what you are trying to do with the said dynamic blocks. If you need more in depth informations on them, there are plenty in here.

Posted

Hi again Jef! , sorry for my late reply

 

One thing I think might be more efficient would be to prompt for the global selection only once, unless you really need different global selections for each added filter. Using a while statement instead of inplied selection could have simplified things.

Well I agree about that, the problem is I'm not that skilled yet.

 

I am aware of the method you described about geting the dynamic's block effective name,

infact I've already assembled (took from Lee Mac's and Tharwat's codes) a routine that works in the same way (using selections only):

(defun C:FilterByBlockname ( / sel blkname blk )
;(princ "\nFunction Filter By Blockname is runned!" )

   (vl-load-com)

(if (setq CLIPROMPTLINES-old (getvar "CLIPROMPTLINES" ))
   (setvar "CLIPROMPTLINES" 4)
)

 (setvar 'errno 0)
 (prompt "\nSelect source block to filter by its EffectiveName" )
 (if (and (setq sel (ssget "_:S:E" '((0 . "INSERT"))))
          (setq blkname (LM:al-effectivename (ssname sel 0)))                        ;<-BLOCK NAME
          (princ (strcat "\nBlockName to filter \"" blkname "\" " ))
          (princ "\nSelect objects to filter" )
          (setq found (tblsearch "BLOCK" blkname))
          (setq objs (ssadd)
                ss   (ssget "_:L" '((0 . "INSERT")))
          )
     )
   (progn
     (repeat
       (setq i (sslength ss))
        (setq name (vla-get-effectivename
                     (vlax-ename->vla-object
                       (setq blk (ssname ss (setq i (1- i))))
                     )
                   )
        )
        (if (eq (strcase blkname) (strcase name))
          (ssadd blk objs)
        )
     )
     (if objs
       (sssetfirst nil objs)
     )
   (princ (strcat "\nSelected " (itoa (sslength objs)) " blocks \"" blkname "\"."))
   )
   (cond ((not blkname)
          (progn (princ "\nMissed.. Try again!")(C:FilterByBlockname))
         )
         ((not found)
          (princ "\n Block not found in drawing !!!")
         )
         (t
          (princ "\n couldn't find any block !!! ")
         )
   )

 )

   (princ "\n")
   (vla-Regen (vla-get-ActiveDocument (vlax-get-acad-object)) acActiveViewport)
   (if CLIPROMPTLINES-old (setvar "CLIPROMPTLINES" CLIPROMPTLINES-old))

(princ)

);defun

I just have to figure out how to implement your modifications to this one (for me its harder to read it).

 

 

Also I was not sure about QSELECT's and FILTER's possibilites (esp. FILTER), thank you for clearing this up!

 

Thank you for the:

(vla-Regen (vla-get-ActiveDocument (vlax-get-acad-object)) acActiveViewport)

The smoothest REGEN I've ever had!

 

My opinion is that with lisp it can be more flexible to apply very custom filters (I mean examples like: filter dynamic blocks by attribute value, or parameter value and so on...)

 

Btw, I've seen other posts(and yours) about selections with lisp and now I see you as a Selection-lisp GOD!

I appreciate your help!

Posted

Hi GRrr

Well I agree about that, the problem is I'm not that skilled yet.

Your skill level is beside the point. Implied selection were beyond what you had learned so far, yet you asked about them. (My question is if I have pre-selected objects, how do I add them to my new filtered selection (sset) ?) The problem is that you just asked about what you thought was the best solution without giving us any clear hints that it was just a wild guess. Different goal also quite often means different path... tell us your destination. Add what is the best path you think of if you can, and maybe we will prevent going into unessarly detours (and dead ends).

 

Caricature of XY problem

-I want to learn to pilot an helicopter

-Ok, come, i'll show you.

(few months later)

-Thanks! Now that I know how to pilot the helicopter, tell me how to get to the moon.

 

You seem like a good learner, I have faith! :D

 

I just have to figure out how to implement your modifications to this one (for me its harder to read it).

I'm not sure which modifications you are talking about, and yes i can sometimes be hard to read and understand someone elses code... but it can be a great way to learn. Trying to literally evaluate and solve it 1 expression at a time. I used to add alerts everywhere in codes. alerts pause the execution, and you can use them to monitor some variables, and know exactly what line of the code is executed. Vlide can also help, with animation of step by step, and possibility to monitors variables and expressions.

 

thank you for clearing this up!

 

Thank you for the:

Code:

(vla-Regen (vla-get-ActiveDocument (vlax-get-acad-object)) acActiveViewport)

The smoothest REGEN I've ever had!

Not using (command "regen") if my feeling is right...

Avoiding any commands whenever possible, they always are the slowest way to go). Also regen-ing only a viewport is always faster then the whole document. You're welcome!

 

Btw, I've seen other posts(and yours) about selections with lisp and now I see you as a Selection-lisp GOD!

I appreciate your help!

Seriously, i'm no god, just an alien with a keyboard, walking in somebody else's footsteps :D

I appreciate the thought, and i'm glad I could help you.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...