Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Selection set over multiple drawings

7 REPLIES 7
Reply
Message 1 of 8
jkusnick
333 Views, 7 Replies

Selection set over multiple drawings

I have an autolisp program where I create a selection set of blocks in one drawing, and then it is hard-coded for now to open a second drawing and create a second selection set of blocks.

The purpose of the program is to compare the 2 selection sets for duplicate blocks. I have created it so that it works within one drawing (creating 2 selection sets), but when I try to open a second drawing to create the second selection set, I get the following error:

"Specify first corner:
Can't reenter LISP.
Invalid point."

This occurs after it starts the getcorner command. In addition to this, the program also seems to lose the first selection set that was created in the first drawing, and produces the error:

"error: invalid selection set: "

The code that opens the second drawing and creates the second selection set looks like this:

(command "fileopen" "C:/test_comp.dwg")
(setq f1 (getpoint "\nSpecify first corner: "))
(setq s1 (getcorner f1 "\nSpecify opposite corner: "))
(Command "_Zoom" "_W" f1 s1)
(setq ss2 (ssget "_w" f1 s1))

If anyone has any insight, I would really appreciate it.
Thank you.
-Josh
7 REPLIES 7
Message 2 of 8
t.willey
in reply to: jkusnick

Lisp doesn't work well with more than one drawing. You have to really know
what you are doing, and even then it may not be possible to do what you want
(most likely that latter will be true).

--

Tim
"A blind man lets nothing block his vision."


wrote in message news:5682327@discussion.autodesk.com...
I have an autolisp program where I create a selection set of blocks in one
drawing, and then it is hard-coded for now to open a second drawing and
create a second selection set of blocks.

The purpose of the program is to compare the 2 selection sets for duplicate
blocks. I have created it so that it works within one drawing (creating 2
selection sets), but when I try to open a second drawing to create the
second selection set, I get the following error:

"Specify first corner:
Can't reenter LISP.
Invalid point."

This occurs after it starts the getcorner command. In addition to this, the
program also seems to lose the first selection set that was created in the
first drawing, and produces the error:

"error: invalid selection set: "

The code that opens the second drawing and creates the second selection set
looks like this:

(command "fileopen" "C:/test_comp.dwg")
(setq f1 (getpoint "\nSpecify first corner: "))
(setq s1 (getcorner f1 "\nSpecify opposite corner: "))
(Command "_Zoom" "_W" f1 s1)
(setq ss2 (ssget "_w" f1 s1))

If anyone has any insight, I would really appreciate it.
Thank you.
-Josh
Message 3 of 8
jkusnick
in reply to: jkusnick

Yeah, it definately is a bad tool for working with multiple drawings, but I always find myself needing to do this.

I have at least narrowed down the problem. While all other variables carry over from the first drawing to the second, the selection set (ss1 in my program) does not. AutoLISP loses the selection set.

This is crucial to my program because it uses while-loops to compare all of the entities in the two selection sets. The only work-around I can think of is to extract all the necessary information from each entity in the first selection set before the second drawing is opened, and save this information to a variable or a list, and then compare those variables or lists to the entities from the second selection set (in the second drawing).

This, however, would be very complex, and it would be really nice if my first selection set just carried over to the second drawing. Se la vi 🙂

Thank you anyway for taking a look.
Message 4 of 8
t.willey
in reply to: jkusnick

So are you in single document mode (sdi = 1) ?

If so I'm not sure where it wouldn't bring over the selection set. Maybe
try (vl-propagate 'ss1) and see what that does for you.

--

Tim
"A blind man lets nothing block his vision."


wrote in message news:5682474@discussion.autodesk.com...
Yeah, it definately is a bad tool for working with multiple drawings, but I
always find myself needing to do this.

I have at least narrowed down the problem. While all other variables carry
over from the first drawing to the second, the selection set (ss1 in my
program) does not. AutoLISP loses the selection set.

This is crucial to my program because it uses while-loops to compare all of
the entities in the two selection sets. The only work-around I can think of
is to extract all the necessary information from each entity in the first
selection set before the second drawing is opened, and save this information
to a variable or a list, and then compare those variables or lists to the
entities from the second selection set (in the second drawing).

This, however, would be very complex, and it would be really nice if my
first selection set just carried over to the second drawing. Se la vi 🙂

Thank you anyway for taking a look.
Message 5 of 8
jkusnick
in reply to: jkusnick

Yes, SDI is set to 1 and lispinit is set to zero.

Thanks for the vl-propagate suggestion; I am not familiar with visual lisp so I did not know about that. I tried entering that code after the second drawing is opened, but it returned the error:

"; error: Visual LISP: Illegal inter-doc import/export object"

Any ideas? It's looking to me like selection sets may only remain active in one drawing since AutoCAD assigns them a specific name (usually two integers like ). However, the error is returning , as if it is losing that information.

If it matters, this is how I create the first selection set:
(Setq ss1 (ssadd))
(setq f1 (getpoint "\nSpecify first corner: "))
(setq s1 (getcorner f1 "\nSpecify opposite corner: "))
(Setq ss1 (ssget "_w" f1 s1))

Message was edited by: jkusnick Message was edited by: jkusnick
Message 6 of 8
t.willey
in reply to: jkusnick

I'm thinking you can't carry over selection sets. I guess you have to go
the list route.


Note Selection set and entity names are volatile. That is, they apply only
to the current drawing session.


--

Tim
"A blind man lets nothing block his vision."


wrote in message news:5683130@discussion.autodesk.com...
Yes, SDI is set to 1 and lispinit is set to zero.

Thanks for the vl-propagate suggestion; I am not familiar with visual lisp
so I did not know about that. I tried entering that code after the second
drawing is opened, but it returned the error:

"; error: Visual LISP: Illegal inter-doc import/export object"

Any ideas? It's looking to me like selection sets may only remain active in
one drawing since AutoCAD assigns them a specific name (usually two integers
like ). However, the error is returning
0*>, as if it is losing that information.

If it matters, this is how I create the first selection set:
(Setq ss1 (ssadd))
(setq f1 (getpoint "\nSpecify first corner: "))
(setq s1 (getcorner f1 "\nSpecify opposite corner: "))
(Setq ss1 (ssget "_w" f1 s1))

Message was edited by: jkusnick

Message was edited by: jkusnick
Message 7 of 8
jkusnick
in reply to: jkusnick

Yeah, found that out the hard way 🙂

Thank you though. I have figured out a way around it by altering my routine. Now I only create one selection set in the second drawing, so no "first" selection set needs to be carried over.

Thanks a lot.
-Josh
Message 8 of 8
t.willey
in reply to: jkusnick

You're welcome. Glad you got something to work.

--

Tim
"A blind man lets nothing block his vision."


wrote in message news:5683444@discussion.autodesk.com...
Yeah, found that out the hard way 🙂

Thank you though. I have figured out a way around it by altering my routine.
Now I only create one selection set in the second drawing, so no "first"
selection set needs to be carried over.

Thanks a lot.
-Josh

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost