@mss_selcukuni a écrit :
Can i ask 2 thing if it is not hard? 😕 😥
1)
When we "select" boundary box, can we select with "select box"?
Now we can select "select point"..
Can you please see attachment?
2)
can you add for circle and ellipse?
This?
(defun PolylineByLayer (l_pt / ss i pline ename layer len area lst sub)
(if (setq ss (ssget "_WP" l_pt (append (list '(0 . "LWPOLYLINE,LINE,SPLINE,CIRCLE,ELLIPSE") (cons 410 (getvar "CTAB"))))))
(repeat (setq i (sslength ss))
(setq
pline (ssname ss (setq i (1- i)))
ename (vlax-ename->vla-object pline)
layer (cdr (assoc 8 (entget pline)))
)
(if (member (vlax-get ename 'ObjectName) '("AcDbEllipse" "AcDbSpline"))
(setq len (vlax-curve-getDistAtParam ename (vlax-curve-getEndParam ename)))
(foreach typ_measure '("Length" "Circumference" "Perimeter")
(if (vlax-property-available-p ename (read typ_measure))
(setq len (vlax-get ename (read typ_measure)))
)
)
)
(if (vlax-property-available-p ename "Area")
(setq area (vlax-get ename 'Area))
(setq area 0.0)
)
(setq lst
(if (setq sub (assoc layer lst))
(subst (list layer (1+ (cadr sub)) (+ (caddr sub) len) (+ (cadddr sub) area)) sub lst)
(cons (list layer 1 len area) lst)
)
)
)
)
)
(defun WriteExcel (data / xlApp wBook cells i j)
(setq
xlApp (vlax-create-object "Excel.Application")
wBook (vlax-invoke-method (vlax-get-property xlapp 'WorkBooks) 'Add)
cells (vlax-get-property xlApp 'Cells)
i 0
)
(foreach row data
(setq i (1+ i) j 0)
(foreach val row
(setq
j (1+ j)
cell (vlax-variant-value (vlax-get-property cells 'Item i j))
)
(vlax-put-property cell 'Value2 val)
)
)
(vlax-invoke-method
(vlax-get-property
(vlax-get-property xlApp 'ActiveSheet)
'Columns
)
'AutoFit
)
(vlax-put-Property xlApp 'Visible :vlax-true)
)
(defun c:boxinfo ( / areaname js ent dxf_ent lst_pt data)
(while (/= (setq areaname (getstring "\nArea name >")) "")
(princ "\nSelect selection boundary")
(while (/= (sslength (setq js (ssget '((0 . "LWPOLYLINE"))))) 1)
(princ "\nOject isn't valide or selection have too many objects")
)
(setq
ent (ssname js 0)
dxf_ent (entget ent)
lst_pt (mapcar '(lambda (x) (trans x ent 0)) (mapcar 'cdr (vl-remove-if '(lambda (x) (/= (car x) 10)) dxf_ent)))
data (append (mapcar '(lambda (x) (cons areaname x))(PolylineByLayer lst_pt)) data)
)
)
(if data (WriteExcel (cons (list "Box name" "Layer" "Item" "Length" "Area") data)))
(prin1)
)