Get items in VBA and then pass to LISP selection set?

Get items in VBA and then pass to LISP selection set?

Anonymous
Not applicable
556 Views
12 Replies
Message 1 of 13

Get items in VBA and then pass to LISP selection set?

Anonymous
Not applicable
I'm trying to write a routine that will prompt the user to select a group of items, which will be checked in VBA for correctness of type, and then pass this lisp to LISP where it will be processed. The sort of simple thing i am trying to do (as a testbed/evaluation-of-the-concept-process) is to pick an object and then delete it. I can get it to work in only LISP easily enough, but with VBA i can pick the object, and create the LISP selection set with no probs, but can't seem to pass any information to LISP itself. I though perhaps the objectID could be used, but even though its the equivalent of the objects LISP-entity name, it won't recognise it. I'm guessing that I can't set a LISP symbol to an object name or anything else that VBA could pass, as i don't even seem to be able to do it from the autocad command line. Is this correct, or does anyone have any tips?
0 Likes
557 Views
12 Replies
Replies (12)
Message 2 of 13

Anonymous
Not applicable
A google search of this NG for "ssadd (handent" should give you one way of
doing this.

James
0 Likes
Message 3 of 13

Anonymous
Not applicable
Here's a function I wrote.

Public Function Ent2lspEnt(entObj As AcadEntity) As String
'Designed to work with SendCommand, which can't pass objects.
'This gets an objects handle and converts it to a string
'of lisp commands that returns an entity name when run in SendCommand.
Dim entHandle As String
entHandle = entObj.Handle
Ent2lspEnt = "(handent " & Chr(34) & entHandle & Chr(34) & ")"
End Function

--
Ed
--

"James Belshan" wrote in message
news:DD0790C3845FE5C52B3BE12CA3F18DFF@in.WebX.maYIadrTaRb...
> A google search of this NG for "ssadd (handent" should give you one way of
> doing this.
>
> James
>
>
0 Likes
Message 4 of 13

Anonymous
Not applicable
You can delete an object quite easily from VBA. Why
involve LISP?


--
There are 10 kinds of people. Those who understand binary and
those who don't.

 



style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
I'm
trying to write a routine that will prompt the user to select a group of
items, which will be checked in VBA for correctness of type, and then pass
this lisp to LISP where it will be processed. The sort of simple thing i am
trying to do (as a testbed/evaluation-of-the-concept-process) is to pick an
object and then delete it. I can get it to work in only LISP easily enough,
but with VBA i can pick the object, and create the LISP selection set with no
probs, but can't seem to pass any information to LISP itself. I though perhaps
the objectID could be used, but even though its the equivalent of the objects
LISP-entity name, it won't recognise it. I'm guessing that I can't set a LISP
symbol to an object name or anything else that VBA could pass, as i don't even
seem to be able to do it from the autocad command line. Is this correct, or
does anyone have any tips?
0 Likes
Message 5 of 13

Anonymous
Not applicable
Hello Frank:

I believe he knows that.

He is using that process just as a testbed for
the concept of passing objects to Lisp.

--
Saludos,  Ing. Jorge Jimenez, SICAD S.A., Costa Rica


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">

You can delete an object quite easily from VBA.
Why involve LISP?


--
There are 10 kinds of people. Those who understand binary and
those who don't.

 



style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
I'm
trying to write a routine that will prompt the user to select a group of
items, which will be checked in VBA for correctness of type, and then pass
this lisp to LISP where it will be processed. The sort of simple thing i am
trying to do (as a testbed/evaluation-of-the-concept-process) is to pick an
object and then delete it. I can get it to work in only LISP easily enough,
but with VBA i can pick the object, and create the LISP selection set with
no probs, but can't seem to pass any information to LISP itself. I though
perhaps the objectID could be used, but even though its the equivalent of
the objects LISP-entity name, it won't recognise it. I'm guessing that I
can't set a LISP symbol to an object name or anything else that VBA could
pass, as i don't even seem to be able to do it from the autocad command
line. Is this correct, or does anyone have any
tips?
0 Likes
Message 6 of 13

Anonymous
Not applicable
Thanks Ed, that works great. I'm wanting to use this to write a function that uses the autocad 'subtract' command for 3d solids, but which copies the solid that will be subtracted before it does the subtract. I can't figure out how this is supposed to be done in VBA, so i was going to do what i needed in VBA first then just finish it off in LISP.
0 Likes
Message 7 of 13

Anonymous
Not applicable
In lisp you would issue:

(command "subtract" ss1 ss2).

 

In vba you would use:

ThisDrawing.SendCommand "subtract " &
Ent2lspEnt(ss1) & " " & Ent2LspEnt(ss2)


--
Ed
--


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Thanks
Ed, that works great. I'm wanting to use this to write a function that uses
the autocad 'subtract' command for 3d solids, but which copies the solid that
will be subtracted before it does the subtract. I can't figure out how this is
supposed to be done in VBA, so i was going to do what i needed in VBA first
then just finish it off in LISP.
0 Likes
Message 8 of 13

Anonymous
Not applicable
I assume that VBA selection sets can't be used, only those created in LISP? I looked to see if they have a handle that could be passed but couldn't find one.
0 Likes
Message 9 of 13

Anonymous
Not applicable
Terence,
I've found the easiest, if not most elegant way to send entities to a
command like subtract is to *not* attempt to make a LISP selection set at
all.

Instead, I would just loop through my VBA selection set (or array of
objects, or collection, or whatever) and build a SendCommand string with a
"Ent2lspEnt" for each object and spaces or vbCR's scattered appropriately.
It seems robust enough for my needs so far.... and since it's the only way I
know to build a LISP selection set, the LISP sset becomes redundant.

Just my opinyun,
James
0 Likes
Message 10 of 13

Anonymous
Not applicable
The Acad3DSolid class has a Copy method which will
create a duplicate solid. You can then use the Boolean method to perform your
operation.


--
There are 10 kinds of people. Those who understand binary and
those who don't.

 



style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Thanks
Ed, that works great. I'm wanting to use this to write a function that uses
the autocad 'subtract' command for 3d solids, but which copies the solid that
will be subtracted before it does the subtract. I can't figure out how this is
supposed to be done in VBA, so i was going to do what i needed in VBA first
then just finish it off in LISP.
0 Likes
Message 11 of 13

Anonymous
Not applicable
I didn't think of that. I just did a straight
translation. SS's wouldn't need a handle since they are not stored in the dwg.
You could always use vlax.cls from acadx.com and keep the lisp
syntax.

There might be other vba methods for working with
solids, but I don't normally do much with them, so I'm not the best one to ask.
The subtract command might accept two single objects instead of two ss's.
Then you could use the syntax I provided. Give it a try.

--

Ed
--


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
I
assume that VBA selection sets can't be used, only those created in LISP? I
looked to see if they have a handle that could be passed but couldn't find
one.
0 Likes
Message 12 of 13

Anonymous
Not applicable
Ed, the syntax works fine with single objects...but if I'd known about the boolean method I would have used it instead of going to LISP. There I was thinking there was method for subtracting solids in VBA...Still, useful stuff to know how to do in LISP, when VBA doesn't have a method available.
0 Likes
Message 13 of 13

Anonymous
Not applicable
See in this NG Subject VBA/LISP Selection set.
Doug Broad has a solution that I have tried and it works.
0 Likes