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.
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
Solved by hmsilva. Go to Solution.
Solved by devitg. Go to Solution.
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
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)))))
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.
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 .
When you use boundary on the geometriy which has an arc with Z=-1 you will get a closed polyline without that Z=-1
@devitg wrote:@Anonymous
@Anonymous , 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.
@Anonymous 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.
@Anonymous 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
@Kent1Cooper wrote:..... I gave a quick try to Mirror3D, but I must have been misunderstanding how to define the axis, because it didn't work. ....
EDIT: NO, hold off on that [I hadn't done something I should have....]. I was trying the Object option, which works manually, but doesn't accept an entity name in a (command) function.
Thanks again Guys for your invaluable help. I ended up finding a program and applying devitg's filter suggestion and it works great!!!!
(defun c:fliparcs3 (/ ss hpi en el)
(setq
ss (ssget "X" (list (cons 0 "ARC") (cons 210 '( 0 0 -1))))
hpi (* 0.5 pi)
)
(cond
(
(not (null ss))
(repeat (sslength ss)
(ssdel (setq en (ssname ss 0)) ss)
(setq el (entget en))
(entmod
(mapcar
(function
(lambda (x / g)
(setq g (car x))
(cond
((= g 10) (cons 10 (mapcar '* (list -1.0 1.0 -1.0) (cdr x))))
((= g 210) (cons 210 (mapcar '- (cdr x))))
((= g 50) (cons 50 (+ hpi (- hpi (cdr (assoc 51 el))))))
((= g 51) (cons 51 (+ hpi (- hpi (cdr (assoc 50 el))))))
(t x)
)
)
)
el
)
)
)
(princ "\nDone")
)
(t (princ "\nNothing selected"))
)
(princ)
)
@hmsilva wrote:bhaushalter1,
just flatten and pedit...
Henrique
Interesting... I must be doing something wrong. Im new to ACad. Below are my steps:
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: Specify opposite corner: 19 found
Select objects:
Remove hidden lines? <Yes>:
-
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: 1 found, 4 total
Select objects: 1 found, 5 total
Select objects:
0 segments added to polyline
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
Can't find what you're looking for? Ask the community or share your knowledge.