#16
You could do “all” but you might pickup unwanted items. Else you could just add the names to the selection set

i.e

Code: Select all

(defun c:pexpxl (/ en fil fname)
 (setq fname (getfiled "Select Excell file" "" "xls" 1))
 (setq fil (open fname "w"))
 (write-line "Object\tPerimeter" fil)
 (foreach en (pxl:getlength)
  (write-line (strcat (car en) "\t" (rtos (cdr en) 2 12)) fil)
 )
 (close fil)
 (princ "\ndone")
 (princ)
)
(defun pxl:getlength ( / c elist ename retlist s)
 (setq retlist '())
 (setq s (ssget '((0 . "CIRCLE,*POLYLINE,ELLIPSE,REGION,SPLINE,LINE,ARC"))))
 (setvar "CMDECHO" 0)
 (if s
  (progn
   (setq c 0)
   (while (< c (sslength s))
    (setq elist (entget (ssname s c))
	  ename (cdr (assoc 0 elist))
    )
    (command "_AREA" "_Object" (cdr (car elist)))
    (setq retlist (cons (cons ename (getvar "PERIMETER")) retlist))
    (setq c (1+ c))
   )
  )
 )
 retlist
)

#18
I got this 'latest' code but it does not count shapes (as in previous post) or write direct to the file, any help please?

(defun C:PEXPXL ( / ss lst fname fil sel2lst dst ed)
(defun sel2lst ( sel / l len )
(if (= 'PICKSET (type sel))
(repeat (setq len (sslength sel))
(setq len (1- len)
l (cons (ssname sel len) l)
) ;setq
) ;repeat
) ;if
)
(setvar "CMDECHO" 0)
(princ "\nSelect Circle,Polyline,Ellipse,Spline,Line,Arc or Region")
(if
(and
(setq ss (ssget '((0 . "CIRCLE,*POLYLINE,ELLIPSE,REGION,SPLINE,LINE,ARC"))))
(setq lst (sel2lst ss))
(setq fname (getfiled "Select Excell file" "" "xls" 1))
)
(progn
(setq fil (open fname "w"))
(write-line "Object\tPerimeter" fil)
(foreach en lst
(cond ((= (cdr(assoc 0 (setq ed (entget en)))) "LINE")
(command "_LENGTHEN" en "")
)
((= (cdr(assoc 0 ed)) "ARC")(command "_LENGTHEN" en ""))
(t(command "_AREA" "_Object" en))
)
(command)(command)(setq dst (getvar "PERIMETER"))
(write-line (strcat (cdr(assoc 0 ed))"\t" (rtos dst 2 12)) fil)
)
(close fil)
(princ "\nPerimeter of ")(princ (length lst))
(princ " object export to ")(princ fname)
)
)
(princ)
)
(princ "\nType PEXPXL to run")

#19
Beyond,

I really don’t follow what you consider a “shape”, there are 51 separate entities in the DXF you posted. Most are Arcs and lines. To get the count of the entities, just use your len variable

Dan

#20
Danielm103 wrote:Beyond,

I really don’t follow what you consider a “shape”, there are 51 separate entities in the DXF you posted. Most are Arcs and lines. To get the count of the entities, just use your len variable

Dan
I called them shapes because I did not know how else to describe them, it is actually 'pierce points I am after for a laser to cut out the profile in the dxf supplied it would be one for the outer profile and one each for the holes total of 14.

I don't know if that is even possible in Intellicad since the outer profile is made up of lines?

If it is possible how ould I add it to the code, someone has given me the auto write to xls below if I could get teh pierce point I would be complete.

(defun C:PEXPXL ( / ss lst fname fil sel2lst)
(defun sel2lst ( sel / l len )
(if (= 'PICKSET (type sel))
(repeat (setq len (sslength sel))
(setq len (1- len)
l (cons (ssname sel len) l)
) ;setq
) ;repeat
) ;if
)
(setvar "CMDECHO" 0)
(princ "\nSelect Circle,Polyline,Ellipse,Spline or Region")
(if
(and
(setq ss (ssget '((0 . "CIRCLE,*POLYLINE,ELLIPSE,REGION,SPLINE"))))
(setq lst (sel2lst ss))
(setq fname (getfiled "Select Excell file" "" "xls" 1))
)
(progn
(setq fil (open fname "w"))
(write-line "Object\tPerimeter" fil)
(foreach en lst
(command "_AREA" "_Object" en)
(write-line (strcat (cdr(assoc 0 (entget en)))"\t" (rtos (getvar "PERIMETER") 2 12)) fil)
)
(close fil)
(princ "\nPerimeter of ")(princ (length lst))
(princ " object export to ")(princ fname)
)
)
(princ)
)
(princ "\nType PEXPXL to run")

#21
Right, because even your circles are Arcs, so you would get two pierce points for each hole. The way I see it is, you need to define what entities are a shape by either marking each entity with XData or by having each entity belong to a collection (A Group , or Block). Since your laser cutter is probably reading the DXF for it’s translation to G-code, blocks probably won’t work for you. But before you design your program, I would consider trying each of the methods on your machine. I would assume that your cutter would ignore the XData and Group DXF code, so one of these two might be your best bet.

Another option I just thought of, would be to convert the Entities to polylines and join them using the PEDIT command.

Dan