Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Select Arcs by with Normal Z = -1

22 REPLIES 22
SOLVED
Reply
Message 1 of 23
bhaushalter1
3345 Views, 22 Replies

Select Arcs by with Normal Z = -1

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.

22 REPLIES 22
Message 2 of 23
hmsilva
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

EESignature

Message 3 of 23
devitg
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)))))

 

Message 4 of 23
bhaushalter1
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.

Message 5 of 23
devitg
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 .

Message 6 of 23
Sjem
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

Message 7 of 23
bhaushalter1
in reply to: devitg


@devitg wrote:

@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 .


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.

Message 8 of 23
bhaushalter1
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.

Message 9 of 23
Kent1Cooper
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, AIA
Message 10 of 23
devitg
in reply to: Kent1Cooper

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

Thanks

 

Message 11 of 23
devitg
in reply to: devitg

at least , not ay least

Message 12 of 23
Kent1Cooper
in reply to: Kent1Cooper


@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.

Kent Cooper, AIA
Message 13 of 23
hmsilva
in reply to: bhaushalter1

normal z=-1

 

command: flatten

 

nornal z = 1

 

 

Henrique

EESignature

Message 14 of 23
devitg
in reply to: hmsilva

Just SIMPLE , thanks

 

Message 15 of 23
bhaushalter1
in reply to: devitg

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)
)

Message 16 of 23
hmsilva
in reply to: devitg

You're welcome, devitg

EESignature

Message 17 of 23
bhaushalter1
in reply to: hmsilva


@hmsilva wrote:

normal z=-1

 

command: flatten

 

nornal z = 1

 

 

Henrique


I tried that originally but for some reason these DXF files will not convert to a joined polyline after using that command. If I flip the arcs with the normal z of -1 they will.

Message 18 of 23
hmsilva
in reply to: bhaushalter1

bhaushalter1,

just flatten and pedit...

 

Henrique

EESignature

Message 19 of 23
bhaushalter1
in reply to: hmsilva


@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

Message 20 of 23
hmsilva
in reply to: bhaushalter1

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

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost