Selection set by window selection

Selection set by window selection

Anonymous
Not applicable
11,745 Views
92 Replies
Message 1 of 93

Selection set by window selection

Anonymous
Not applicable

I am trying to create a selection set by selecting entities by a window. i thought it was

 

(prompt "\nSelect Objects by Window")
(setq p1 (getpoint "\nFirst Corner: "))
(setq p2 (getpoint p1 "\nSecond Corner: "))
(setq ss1 (ssget "w" p1 p2))

 

i am having some trouble though. I must be missing something & just not thinking of it.

0 Likes
Accepted solutions (1)
11,746 Views
92 Replies
Replies (92)
Message 41 of 93

dlanorh
Advisor
Advisor

Oops, my bad. I've committed a sin I'm aways chastising others for. Go to the local error routine and change the line with the command call ("command" "undo" 1) to ("command-s" "undo" 1). If you still get an error just comment out the line for now. I will sort the lisp in the next couple of days when I return to the office.

 

It's a common problem with old lisp routines that have local error functions. Many contain command calls which are now illegal as they could cause malicious to be triggered. It is quite common with some express tools as they haven't been updated for years, but it's usually generated when a user quits the lisp using the ESC key. The problem affects all versions after 2015 so my 2012 doesn't generate it.

I am not one of the robots you're looking for

0 Likes
Message 42 of 93

Anonymous
Not applicable

Yeah i'm still getting the error even after commenting out the line. I did read about the command versus command-s but so far not working. I did find several post about this error on various forums but not exactly with my issue with the locked layer

0 Likes
Message 43 of 93

dlanorh
Advisor
Advisor

Trying to explode an object on a locked layer will fail with an error. Trying to select an object on a locked layer by window won't select that object. Do you want to unlock all layers, do all the stuff then relock or ignore stuff on locked layers? My opinion is the former as you are returning the drawing to it's pre lisp state. Up to you.

 

I am not one of the robots you're looking for

0 Likes
Message 44 of 93

Kent1Cooper
Consultant
Consultant

To have it ignore things on locked Layers, add the "_:L" operator to the (ssget) function for getting things to Wblock out [here a piece of the code in Message 36]:

 

 

....
    (prompt (strcat "\nSelect Objects for " dnme ".dwg by Window"))
    (setq ss (ssget "_:L"))
....

 

 

Without trial, I'm not sure the "_X" and "_:L" operators can be combined  earlier [to find all Multileaders in the drawing not on a locked Layer] the way some operators can.

 

If you don't want it to ignore things on locked Layers, but have them included, then I think the only option is to build in unlocking all Layers in the beginning, and at the end use a LAYERP command to re-lock them.

Kent Cooper, AIA
0 Likes
Message 45 of 93

Anonymous
Not applicable

I really need it to ignore the locked layer. Much like if you just type in the wblock command. wblock ignores the locked layers. Maybe if all lock layers are frozen so it doesn't get selected in the selection set? I am attaching the template file that contains the locked layer & also the pool drawing which will be the final result

0 Likes
Message 46 of 93

dlanorh
Advisor
Advisor

Try the attached.

 

 

I am not one of the robots you're looking for

0 Likes
Message 47 of 93

Anonymous
Not applicable

I still get this error message:

 

** Error: Automation Error. Calling method Clear of interface IAcadSelectionSet failed **

 

Now it fails even if you unlock the layer. 

0 Likes
Message 48 of 93

dlanorh
Advisor
Advisor

What is the lisp doing when you get that error, the explode multileaders or the wblock? Is QAFLAGS set to 0?

 

I cannot test because the Pool.dwg you attached is in a later version of AutoCAD than mine (2012)

I am not one of the robots you're looking for

0 Likes
Message 49 of 93

Kent1Cooper
Consultant
Consultant

@dlanorh wrote:

.....

I cannot test because the Pool.dwg you attached is in a later version of AutoCAD than mine (2012)


[If you get DWG TrueView, a free download from Autodesk, you can use it to convert later-version drawings to earlier file formats, so you can open them without needing to ask people to back-convert them.]

Kent Cooper, AIA
0 Likes
Message 50 of 93

Anonymous
Not applicable

The error occurs when I try to select the objects for the selection set. I can save down the pool drawing for you if you like. I'm at a doctors appointment but I can do it when I get back home. I'm not sure about qaflags. I can check that later too 

0 Likes
Message 51 of 93

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

I still get this error message:

** Error: Automation Error. Calling method Clear of interface IAcadSelectionSet failed **

.... 



Could it be [speculation, untested] in this part?

....

  (setq ss (ssget))
  (cond (ss
    (setq ass (vla-get-activeselectionset cdoc)

....

 

Is that applicable only to what it says -- an active  selection set, such as with pre-selected items that are highlighted/gripped -- and not to the mere contents of a variable resulting from (ssget)?

 

I would also suggest removing the 7 argument from the (initget) function a little farther down.  The 1 bit that's part of that will prevent the User from hitting Enter.  But the prompt is offering a default value, which they should be permitted to accept by hitting Enter.  Also, the 2 & 4 bits that are part of that 7 prevent entering zero or a negative number, which are not applicable to what's being asked for.

Kent Cooper, AIA
0 Likes
Message 52 of 93

dlanorh
Advisor
Advisor

@Anonymous wrote:

The error occurs when I try to select the objects for the selection set. I can save down the pool drawing for you if you like. I'm at a doctors appointment but I can do it when I get back home. I'm not sure about qaflags. I can check that later too 


There is no need to upload the drawing. I have something to test on.

 

OK. Story. I've managed to reproduce the error, but the error kept re-occuring no matter what I changed. I quit the drawing, reopened it and ran the latest code (attached) again. It ran without a problem. I can only assume that there is a bug somewhere that won't reset from the automation error. You are correct, it was connected with getting the active selection set for processing for the wblock. I also found another minor bug which I have fixed.

 

All locked layers are unlocked. The Multileaders are exploded. The wblocks are processed. The relevant layers are re-locked. The drawing is reverted to the state prior to running the lisp.

 

I still don't know if the (command-s) in the error routine will trigger another error as I cannot test this.

I am not one of the robots you're looking for

0 Likes
Message 53 of 93

dlanorh
Advisor
Advisor

@Kent1Cooper wrote:

@dlanorh wrote:

.....

I cannot test because the Pool.dwg you attached is in a later version of AutoCAD than mine (2012)


[If you get DWG TrueView, a free download from Autodesk, you can use it to convert later-version drawings to earlier file formats, so you can open them without needing to ask people to back-convert them.]


My companies owns the computers I work on. It views "TrueView" as an extraneous program which I (under my job description) don't need and can't justify. 🙄

I am not one of the robots you're looking for

0 Likes
Message 54 of 93

Anonymous
Not applicable

It runs without that error now, but layer 2-BORDER gets brought into the pool.dwg that's the layer that is locked. i would like that layer to not show up in the new file if that is possible. Maybe we just just freeze or turn off all layers that are locked before the selection set is done. I'm attaching both drawings saved down so you should be able to open them

0 Likes
Message 55 of 93

dlanorh
Advisor
Advisor
Accepted solution

Attached is revised lisp. I've moved the layer re-lock before the wblock, and as per @Kent1Cooper 's suggestion made the wblock selection sets ignore locked layers. Tested on your supplied drawings and no errors.

I am not one of the robots you're looking for

Message 56 of 93

Anonymous
Not applicable

I think its working now. i don't get any errors & its ignoring the locked layers which is awesome

0 Likes
Message 57 of 93

dlanorh
Advisor
Advisor

Excellent 👍

I am not one of the robots you're looking for

0 Likes
Message 58 of 93

Anonymous
Not applicable

Thank you for all of the help. You & others have been extremely helpful. I need to study this routine to try to understand as much as i can of it. i'm not that good with visual lisp. I've looked at some things online but i would love to find a good book on this that really goes in depth on the details of visual lisp. 

0 Likes
Message 59 of 93

dlanorh
Advisor
Advisor

You could start here AFRALISP  it's online, free and still one of the better sites I reference from time to time. It sticks to the documented functions, so you won't (i don't think) find references to the undocumented ones (e.g. vlax-get, vlax-put, vlax-invoke) which allow an easier integration with AutoLisp and its functions.  

I am not one of the robots you're looking for

0 Likes
Message 60 of 93

Anonymous
Not applicable

yes that's on my favorites, I've been there many times. Also Lee Macs stuff is really good. I still would love to find a good book with lots of explanations & samples. I have the ABC's of Autolisp by George Omura. Something like that for visual lisp would be great if there is such a book. I do have the Visual Lisp Developers Bible by David Stein.

0 Likes