Help figuring out what theis LISP code is doing

Help figuring out what theis LISP code is doing

Anonymous
Not applicable
295 Views
7 Replies
Message 1 of 8

Help figuring out what theis LISP code is doing

Anonymous
Not applicable
Hi,

I'm trying to convert the following LISP code to VBA and I'm a little
confused as to what is going on.

(command "circle" "cent" pt1 "mid" pt1)
(setq el1 (ssget "l"))
(setq a (ssname el1 0))
(setq b (entget a))
(setq ptp1 (cdr (assoc 10 b)))
(setq ptpr (cdr (assoc 40 b)))
(setq angmd (rtd (angle ptp1 pt1)))

Basically, I understand that a circle is being created and a reference is
then set to this circle, but the ptp1, and ptpr vars are really throwing me
for a loop. Any suggestions as to how to convert this to VBA would be
welcomed. I'm well versed in VB, just not with LISP or the AutoCAD object
model.
0 Likes
296 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
Mike -
> (command "circle" "cent" pt1 "mid" pt1)
> (setq el1 (ssget "l"))
> (setq a (ssname el1 0))
> (setq b (entget a))
> (setq ptp1 (cdr (assoc 10 b)))
PTP1 grabs the circle's insertion point

> (setq ptpr (cdr (assoc 40 b)))
PTPR grabs the circle's radius

> (setq angmd (rtd (angle ptp1 pt1)))
This line gets the angle between the circle's actual insertion point
[PTP1] and the point submitted as the command line argument [PT1].
Example, the user is selecting another circle and the new one will be
concentric to it. The angle value returned is in radians, so the RTD is
converting to degrees.

===============================
Mike Tuersley
PhD @ CADalyst's AutoCAD Clinic
http://www.cadonline.com
0 Likes
Message 3 of 8

Anonymous
Not applicable
(cdr (assoc 10 b)) returns the DXF group code 10 value, which is "Center
point (in OCS)". Likewise, 40 is the radius. I don't know what (rtd... is,
maybe a UDF. If so, it's passed the angle between the center point, ptp1,
and the argument point, pt1. FWIW.
--
John Goodfellow
irtfnm
use john at goodfellowassoc dot com


"Mike Rand" wrote in message
news:DCD29AC3EE9CFEBE3A199330A3689EBD@in.WebX.maYIadrTaRb...
> Hi,
>
> I'm trying to convert the following LISP code to VBA and I'm a little
> confused as to what is going on.
>
> (command "circle" "cent" pt1 "mid" pt1)
> (setq el1 (ssget "l"))
> (setq a (ssname el1 0))
> (setq b (entget a))
> (setq ptp1 (cdr (assoc 10 b)))
> (setq ptpr (cdr (assoc 40 b)))
> (setq angmd (rtd (angle ptp1 pt1)))
>
> Basically, I understand that a circle is being created and a reference is
> then set to this circle, but the ptp1, and ptpr vars are really throwing
me
> for a loop. Any suggestions as to how to convert this to VBA would be
> welcomed. I'm well versed in VB, just not with LISP or the AutoCAD object
> model.
>
>
0 Likes
Message 4 of 8

Anonymous
Not applicable
Mike,
Although I can't see any reason for converting perfectly good
LISP code to VBA, this ain't good LISP code so you should
freely find a completely different approach.

Don't start with garbage to make a jewel (VBG).

If you want to make a circle, use the addcircle method. A
good place to learn is the VLISP help file which contains the
object model. There are good examples for doing this kind
of stuff in those help files. That's where I would start.

Doug

"Mike Rand" wrote in message
news:DCD29AC3EE9CFEBE3A199330A3689EBD@in.WebX.maYIadrTaRb...
> Hi,
>
> I'm trying to convert the following LISP code to VBA and I'm a little
> confused as to what is going on.
>
> (command "circle" "cent" pt1 "mid" pt1)
> (setq el1 (ssget "l"))
> (setq a (ssname el1 0))
> (setq b (entget a))
> (setq ptp1 (cdr (assoc 10 b)))
> (setq ptpr (cdr (assoc 40 b)))
> (setq angmd (rtd (angle ptp1 pt1)))
>
> Basically, I understand that a circle is being created and a reference is
> then set to this circle, but the ptp1, and ptpr vars are really throwing me
> for a loop. Any suggestions as to how to convert this to VBA would be
> welcomed. I'm well versed in VB, just not with LISP or the AutoCAD object
> model.
>
>
0 Likes
Message 5 of 8

Anonymous
Not applicable
Thanks for everyone's replies.

OK, I understand, BUT,

If I use the AddCircle method, how could I duplicate this line

(command "circle" "cent" pt1 "mid" pt1)




"Mike Tuersley" wrote in message
news:MPG.183c4ae1d22401e09896bc@discussion.autodesk.com...
> Mike -
> > (command "circle" "cent" pt1 "mid" pt1)
> > (setq el1 (ssget "l"))
> > (setq a (ssname el1 0))
> > (setq b (entget a))
> > (setq ptp1 (cdr (assoc 10 b)))
> PTP1 grabs the circle's insertion point
>
> > (setq ptpr (cdr (assoc 40 b)))
> PTPR grabs the circle's radius
>
> > (setq angmd (rtd (angle ptp1 pt1)))
> This line gets the angle between the circle's actual insertion point
> [PTP1] and the point submitted as the command line argument [PT1].
> Example, the user is selecting another circle and the new one will be
> concentric to it. The angle value returned is in radians, so the RTD is
> converting to degrees.
>
> ===============================
> Mike Tuersley
> PhD @ CADalyst's AutoCAD Clinic
> http://www.cadonline.com
0 Likes
Message 6 of 8

Anonymous
Not applicable
Since there is no OSNAP function in VBA you would have to select
objects using a small crossing window with the coordinates of
pt1 +- half the aperture size. You would have to loop through the
selection collection looking for objects that have a center and objects
that have a midpoint. You would have to collect each of the points
and filter them for the closest to PT1.
One point would be the center and the second point would be used
to determine the radius = distance between pt1 and pt2. You would
need to use the distance formula.

Once you have the center and the radius, you could do the addcircle.

The VBA to perform that simple task would probably be several pages
long.


"Mike Rand" wrote in message
news:60D9309FB8256CE366DCC4E4CE1B541C@in.WebX.maYIadrTaRb...
> Thanks for everyone's replies.
>
> OK, I understand, BUT,
>
> If I use the AddCircle method, how could I duplicate this line
>
> (command "circle" "cent" pt1 "mid" pt1)
>
>
>
>
> "Mike Tuersley" wrote in message
> news:MPG.183c4ae1d22401e09896bc@discussion.autodesk.com...
> > Mike -
> > > (command "circle" "cent" pt1 "mid" pt1)
> > > (setq el1 (ssget "l"))
> > > (setq a (ssname el1 0))
> > > (setq b (entget a))
> > > (setq ptp1 (cdr (assoc 10 b)))
> > PTP1 grabs the circle's insertion point
> >
> > > (setq ptpr (cdr (assoc 40 b)))
> > PTPR grabs the circle's radius
> >
> > > (setq angmd (rtd (angle ptp1 pt1)))
> > This line gets the angle between the circle's actual insertion point
> > [PTP1] and the point submitted as the command line argument [PT1].
> > Example, the user is selecting another circle and the new one will be
> > concentric to it. The angle value returned is in radians, so the RTD is
> > converting to degrees.
> >
> > ===============================
> > Mike Tuersley
> > PhD @ CADalyst's AutoCAD Clinic
> > http://www.cadonline.com
>
>
0 Likes
Message 7 of 8

Anonymous
Not applicable
> Since there is no OSNAP function in VBA you would have to select
> objects using a small crossing window with the coordinates of
> pt1 +- half the aperture size. You would have to loop through the
> selection collection looking for objects that have a center and objects
> that have a midpoint. You would have to collect each of the points
> and filter them for the closest to PT1.
> One point would be the center and the second point would be used
> to determine the radius = distance between pt1 and pt2. You would
> need to use the distance formula.
>
> Once you have the center and the radius, you could do the addcircle.
>
> The VBA to perform that simple task would probably be several pages
> long.
>
> > > > (command "circle" "cent" pt1 "mid" pt1)
What???? The line of code is asking for the user to select an entity,
otherwise it would not be filtering the selection point to a "CENTER".
There is no need to grab things by crossing windows, etc., etc. Keep It
Simple!

All you need to do, Mike, is have the user select a CIRCLE or ARC. From
there, get its center point to draw the new circle. Best idea is to ask
the users how they use this...do they normally select arcs, circles, a
combination, whatever. Then offer these entities as selection options.

HTH

Mike
===============================
Mike Tuersley
PhD @ CADalyst's AutoCAD Clinic
http://www.cadonline.com
0 Likes
Message 8 of 8

Anonymous
Not applicable
True. Much better Mike.

An explanation of why the same pt was used in the command for both
the center pick and the radius pick would have been helpful also. If all
the poster wanted to do was to create a circle concentric with and having
the same radius as an arc, it would have been even simpler.

1. Select the arc??
2. Obtain the center and the radius of the arc.
3. Add the circle by using the center and radius of the arc.



> > > > > (command "circle" "cent" pt1 "mid" pt1)
> What???? The line of code is asking for the user to select an entity,
> otherwise it would not be filtering the selection point to a "CENTER".
> There is no need to grab things by crossing windows, etc., etc. Keep It
> Simple!
>
> All you need to do, Mike, is have the user select a CIRCLE or ARC. From
> there, get its center point to draw the new circle. Best idea is to ask
> the users how they use this...do they normally select arcs, circles, a
> combination, whatever. Then offer these entities as selection options.
>
0 Likes