Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Active Member
bhaushalter1
Posts: 8
Registered: ‎02-11-2013
Message 1 of 23 (552 Views)
Accepted Solution

Select Arcs by with Normal Z = -1

552 Views, 22 Replies
02-11-2013 07:52 AM

Newbie here trying to learn LISP. My first program is to flip all arcs and circles that have a Normal Z property of -1. But I'm having trouble finding a detailed list of commands and functions for the LISP language that explain creating circles to selecting entities filtered by properties. I must be searching for the wrong terminology.

 

Any links will be greatly apriciated.

 

Thx

 

Bill H.

DXF code 210 hold the vector direction 

 

(210 0.0 0.0 1.0) 

 

positive, from monitor to our face 

 

negative, from our face to the monitor 

 

(setq -1z-arc&circle (ssget "X" (list (cons 0 "ARC,CIRCLE" ) (cons 210 '( 0 0 -1)))))

 

normal z=-1

 

command: flatten

 

nornal z = 1

 

 

Henrique

bhaushalter1,

in this example, in the pedit command, I used the option multiple to be faster, and in this way created two polylines

 

Command: ucs
Current ucs name:  *WORLD*
Specify origin of UCS or [Face/NAmed/OBject/Previous/View/World/X/Y/Z/ZAxis]
<World>: w
Command: plan
Enter an option [Current ucs/Ucs/World] <Current>:
Regenerating model.
Command: flatten
Select objects to convert to 2d...
Select objects: all
19 found
Select objects:
Remove hidden lines? <No>:
Command: pe
PEDIT Select polyline or [Multiple]: Select polyline or [Multiple]: m
Select objects: all
19 found
Select objects:
Convert Lines, Arcs and Splines to polylines [Yes/No]? <Y>
Enter an option [Close/Open/Join/Width/Fit/Spline/Decurve/Ltype
gen/Reverse/Undo]: j
Join Type = Extend
Enter fuzz distance or [Jointype] <0.0000>:
17 segments added to 2 polylines

 

but if you select the objects in the orden which we want the polyline be joined, like the dwg I have attached you'll only get with one polyline

 

Command: pedit Select polyline or [Multiple]:
Object selected is not a polyline
Do you want to turn it into one? <Y>
Enter an option [Close/Join/Width/Edit vertex/Fit/Spline/Decurve/Ltype
gen/Reverse/Undo]: j
Select objects: 1 found
Select objects: 1 found, 2 total
Select objects: 1 found, 3 total
Select objects: Specify opposite corner: 13 found, 16 total
Select objects: 1 found, 17 total
Select objects: 1 found, 18 total
Select objects:
18 segments added to polyline

 

hope that helps

Henrique

*Expert Elite*
hmsilva
Posts: 2,873
Registered: ‎12-17-2004
Message 2 of 23 (526 Views)

Re: Select Arcs by with Normal Z = -1

02-11-2013 12:45 PM in reply to: bhaushalter1

bhaushalter1 wrote:

...

My first program is to flip all arcs and circles that have a Normal Z property of -1. But I'm having trouble finding a detailed list of commands and functions for the LISP language that explain creating circles to selecting entities filtered by properties. I must be searching for the wrong terminology

. ...

Any links will be greatly apriciated

. ...

 

 

I do not know what you mean by "flip", but to select arcs and circles with a z value of -1 You can use something like

 

(setq	ss (ssget "_X"
		  (list
		    '(0 . "CIRCLE,ARC")
		    '(-4 . "*,*,=")
		    (cons 10 (list 0.0 0.0 -1.0))
		  )
	   )
  )

 

results in a selection set in the variable ss with all the circles and arcs with z = -1

You can see this site, that is very good to learn lisp, do a google with "AutoLISP" or "AutoLISP tutorials" you'll find several good sites

 

hope that helps

Henrique

Mentor
devitg
Posts: 1,704
Registered: ‎03-14-2004
Message 3 of 23 (512 Views)

Re: Select Arcs by with Normal Z = -1

02-11-2013 02:37 PM in reply to: bhaushalter1

DXF code 210 hold the vector direction 

 

(210 0.0 0.0 1.0) 

 

positive, from monitor to our face 

 

negative, from our face to the monitor 

 

(setq -1z-arc&circle  (ssget  "X" (list  (cons 0 "ARC,CIRCLE" )    (cons 210 '( 0 0 -1)))))

 

Active Member
bhaushalter1
Posts: 8
Registered: ‎02-11-2013
Message 4 of 23 (502 Views)

Re: Select Arcs by with Normal Z = -1

02-11-2013 04:50 PM in reply to: devitg

Thanks for the help Guys.

 

I get curve data imported form another cad system and some of the arcs have a Z normal of -1. Autocad can't join the curves as a polyline which is required for our laser cutting system.

 

I think I can run with information given.

 

Thanks again.

Mentor
devitg
Posts: 1,704
Registered: ‎03-14-2004
Message 5 of 23 (496 Views)

Re: Select Arcs by with Normal Z = -1

02-11-2013 06:23 PM in reply to: bhaushalter1

 

 

 

bhaushalter1  , I do not know what yout lisp do , but when you change the Z vector sign , from 1 to -1  the arc will change its value , as the start and end angle.

See the attached dwg 

 

the red one has Z  1  positive

the black, is the same arc, and  has Z -1 negative , 

so it will not be so easy to flip the arc .

New Member
Sjem
Posts: 1
Registered: ‎11-20-2012
Message 6 of 23 (484 Views)

Re: Select Arcs by with Normal Z = -1

02-12-2013 03:46 AM in reply to: bhaushalter1

When you use boundary on the geometriy which has an arc with Z=-1 you will get a closed polyline without that Z=-1

Active Member
bhaushalter1
Posts: 8
Registered: ‎02-11-2013
Message 7 of 23 (471 Views)

Re: Select Arcs by with Normal Z = -1

02-12-2013 05:56 AM in reply to: devitg

devitg wrote:

 

 

 

bhaushalter1  , I do not know what yout lisp do , but when you change the Z vector sign , from 1 to -1  the arc will change its value , as the start and end angle.

See the attached dwg 

 

the red one has Z  1  positive

the black, is the same arc, and  has Z -1 negative , 

so it will not be so easy to flip the arc .


My program will select all arcs with a Normal Z of -1 and mirror3d about the XY. All geometry is always flat in the Z plane.

Active Member
bhaushalter1
Posts: 8
Registered: ‎02-11-2013
Message 8 of 23 (470 Views)

Re: Select Arcs by with Normal Z = -1

02-12-2013 06:09 AM in reply to: Sjem

Sjem wrote:

When you use boundary on the geometriy which has an arc with Z=-1 you will get a closed polyline without that Z=-1


Didn't seem to work with my geometry. We need a lead in and lead out for the laser which creates crossing curves.

*Expert Elite*
Kent1Cooper
Posts: 5,513
Registered: ‎09-13-2004
Message 9 of 23 (464 Views)

Re: Select Arcs by with Normal Z = -1

02-12-2013 06:23 AM in reply to: bhaushalter1

bhaushalter1 wrote:
....

My program will select all arcs with a Normal Z of -1 and mirror3d about the XY. All geometry is always flat in the Z plane.


Just Mirroring a Circle or Arc with Z = -1 in the current plane still results in another with Z = -1.  I gave a quick try to Mirror3D, but I must have been misunderstanding how to define the axis, because it didn't work.  But this seems to work, which rotates them about the axis between their center and midpoint, possibly essentially the same thing that MIrror3D does [minimally tested]:

 

(foreach ent
  (mapcar 'cadr (ssnamex (ssget "_X" '((0 . "CIRCLE,ARC") (210 0.0 0.0 -1.0)))))
  (command
    "_.ucs" "_zaxis"
      (trans (cdr (assoc 10 (entget ent))) ent 0); origin
      (vlax-curve-getPointAtDist ; Z-direction point [midpoint]
        ent
        (/
          (vlax-curve-getDistAtParam ent (vlax-curve-getEndParam ent))
          2
        ); /
      ); ...getPoint... and UCS
    "_.rotate" ent "" "0,0" "180"
    "_.ucs" "_previous"
  ); command
); foreach

Kent Cooper
Mentor
devitg
Posts: 1,704
Registered: ‎03-14-2004
Message 10 of 23 (457 Views)

Re: Select Arcs by with Normal Z = -1

02-12-2013 06:34 AM in reply to: Kent1Cooper

Kent , as ever , your lisp work, ay least at my sample .

Thanks

 

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 or visit the Installation and Licensing Forum to get help installing your software.