Visual LISP, AutoLISP and General Customization

Reply
Distinguished Contributor
rphillips
Posts: 248
Registered: ‎06-06-2005
Message 1 of 6 (287 Views)

Group codes lisp

287 Views, 5 Replies
06-13-2012 10:44 AM

I am using this

(setq DL(ssget "W" P1 P2 (list (cons 0 "line")(cons 8 "C-ROAD-PROF-GRID-MAJR"))))

to select the line on the layer c-road-prof-grid-majr but i would like to know how to add an additional filter so that it will select the lines on the layer c-road-prof-grid-majr that are at the angle of 90. I do know know the group number.

I use this

(setq info (entget (car (entsel "\nSelect Object: "))))

to list the common groups but it does not list all off them is there another string that will list more or is there a document some where that list them?

 

I have some vertical lines (more that 2) and i would would like the code to pick the 2 outer lines and draw a line between them ignoring the lines in the middle. Imagine vertical lines and you want to connect the most outer lines with a horizontal line making a U.
The code will seach the file for lines on the layer c-temp and then draw another line connecting the two outer horizontal lines. Can anyone help with this
Thanks

*Expert Elite*
dbroad
Posts: 1,492
Registered: ‎08-16-2007
Message 2 of 6 (278 Views)

Re: Group codes lisp

06-13-2012 11:32 AM in reply to: rphillips

There is no dxf code for line angle.  You will need to select the lines and filter the selection programmatically.

*Expert Elite*
Kent1Cooper
Posts: 5,255
Registered: ‎09-13-2004
Message 3 of 6 (275 Views)

Re: Group codes lisp

06-13-2012 12:00 PM in reply to: rphillips

rphillips wrote:

.... i would like to ... select the lines ... that are at the angle of 90. ....

....

I have some vertical lines (more that 2) and i would would like the code to pick the 2 outer lines and draw a line between them ignoring the lines in the middle. Imagine vertical lines and you want to connect the most outer lines with a horizontal line making a U.
....


 

Some questions for you:  Would all the vertical Lines always be drawn from the bottom up, that is, truly be at an angle of 90 degrees by AutoCAD's definition of that, or might some of them be at an angle of 270 degrees?  It would make a difference to how you would determine where to draw the horizontal Line.  And would their ends always align horizontally?  If they might not, would you want a not-necessarily-horizontal Line to connect their bottom ends, or a horizontal Line regardless?  If the latter, should it meet the bottom end of one of the vertical Lines, or average their Y coordinates, or be positioned by some other determination?

Kent Cooper
Distinguished Contributor
rphillips
Posts: 248
Registered: ‎06-06-2005
Message 4 of 6 (251 Views)

Re: Group codes lisp

06-13-2012 02:28 PM in reply to: Kent1Cooper

Never mind on this what i was trying to do will not work anyway.

Thanks

*Expert Elite*
scot-65
Posts: 2,127
Registered: ‎12-11-2003
Message 5 of 6 (247 Views)

Re: Group codes lisp

06-13-2012 03:19 PM in reply to: rphillips

DFX 10 for a line is the start point.

DFX 11 is the end point.

Using (angle (dfx 10) (dfx 11)) will return the value in radians.

 

I do not think we can set up a boolean equation inside the filter list to cover this.

See Relational Tests and Logical Grouping of Filter Test sections in the AutoLISP reference.

 

What you will be looking for is

(= (angle (dfx 10) (dfx 11)) (/ pi 2.0)) or

(= (angle (dfx 10) (dfx 11)) (* 3.0 (/ pi 2.0)))

 

???

Scot-65
Dyslexia is a permanent physical disability that cannot be seen.
*Expert Elite*
Kent1Cooper
Posts: 5,255
Registered: ‎09-13-2004
Message 6 of 6 (224 Views)

Re: Group codes lisp

06-14-2012 04:19 AM in reply to: scot-65

scot-65 wrote:

.... 

What you will be looking for is

(= (angle (dfx 10) (dfx 11)) (/ pi 2.0)) or

(= (angle (dfx 10) (dfx 11)) (* 3.0 (/ pi 2.0)))

....


If it doesn't matter whether vertical is upward or downward, you could cover both possibilities with one check, not for the angle but for whether the X coordinates of the endpoints are the same [within whatever precision you want]:

 

(equal (cadr (assoc 10 edata)) (cadr (assoc 11 edata)) 1e-8)

Kent Cooper

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community