• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Leggi altro.

Centroide di un'area delimitata da una polilinea

Professione: *
Software: AutoCAD
Regione: Lombardia
#1
Inserisce un punto nel centroide delle geometrie selezionate (le polilinee devono essere chiuse)



Codice:
(defun c:polycen (/ polySet polyList Model newPl obArr newReg newPt) 
  (princ "\n*** Select closed polylines *** ") 
  (if 
  (setq polySet(ssget '((0 . "LWPOLYLINE")))) 
   (progn 
     (setq polyList(mapcar 'vlax-ename->vla-object 
                            (vl-remove-if 'listp 
                              (mapcar 'cadr(ssnamex polySet)))) 
      Model(vla-get-ModelSpace 
         (vla-get-ActiveDocument 
           (vlax-get-acad-object))) 
      ); end setq 
     (foreach p polyList 
       (if(= :vlax-true(vla-get-Closed p)) 
    (progn 
       (setq newPl(vla-copy p) 
        obArr(vlax-make-safearray vlax-vbObject '(0 . 0)) 
        ); end setq 
       (vlax-safearray-put-element obArr 0 newPl) 
       (setq newReg(car(vlax-safearray->list 
           (vlax-variant-value 
             (vla-AddRegion Model obArr)))) 
             newPt(vlax-3d-point 
          (append 
          (vlax-safearray->list 
            (vlax-variant-value 
         (vla-get-Centroid newReg)))(list 0.0))) 
    ); end setq 
       (vla-AddPoint Model newPt) 
       (vla-delete newPl)(vla-delete newReg) 
       ); end progn 
    ); end if 
       ); end foreach 
     ); end progn 
  (princ "\n*** Notning closed polylines selected! *** ") 
  ); end if 
  (princ) 
  ); end of c:polycen
(vl-load-com)
segnalato da antoniovinci
 
Ultima modifica: