Jump to content

Display hatch area as a label


Organic

Recommended Posts

Is there a lisp, that I can select a hatch and have the area of the hatch not polyline.    Or that I can select one polyline then tell to substract another polyline from the area of the 1st selected polyline..

Link to comment
Share on other sites

  • Replies 50
  • Created
  • Last Reply

Top Posters In This Topic

  • Organic

    8

  • Lee Mac

    7

  • ReMark

    5

  • pkenewell

    4

Top Posters In This Topic

Posted Images

3 hours ago, Lukasz Bodnar said:

Is there a lisp, that I can select a hatch and have the area of the hatch not polyline.

 

Sure -

(defun c:harea ( / e o )
    (and (setq e (car (entsel)))
         (setq o (vlax-ename->vla-object e))
         (vlax-property-available-p o 'area)
         (princ (strcat "\nArea: " (rtos (vla-get-area o) 2)))
    )
    (princ)
)

Alternatively, simply obtain the area from the Properties Palette.

Link to comment
Share on other sites

  • 4 years later...
On 1/19/2013 at 3:47 PM, GP_ said:

J’ai adapté mon code ici + la routine de Lee.

 

 

401.gif

 

 

 

;;   Write the area of the selected polylines in the position of   ;;
;;   maximum inscribed circle.                                     ;;
;;                                                                 ;;
;;   19.01.2013 - Gian Paolo Cattaneo                              ;;

(defun c:arpoly (/ sel poly POLY_vl Dx Dy Lp List_vert_poly list_p_int P_center dist step1 step2)
   (prompt "\nSelect Polyline: ")
   (setq sel (ssget '((0 . "LWPOLYLINE"))))
   (if sel
       (progn
           (repeat (setq :n (sslength sel))
               (setq poly (ssname sel (setq :n (1- :n))))
               (setq jjj 0)
               (setq step1 30) ;--> grid_1 density
               (setq step2 10) ;--> grid_2 density
               (setq POLY_vl (vlax-ename->vla-object POLY))
               (setq list_vert_poly (LM:LWPoly->List POLY))
               (grid_1)   
               (Point_int)
               ;(grid+) ;increase accuracy
               (Point_center)
               (if (= jjj 1) (setq p_prov P_center))
              ;(repeat 2 ;increase accuracy
                   (grid_2) 
                   (Point_center)
              
               (entmake
                   (list
                       (cons 0 "TEXT")
                       (cons 8 (getvar "clayer"))
                       (cons 7 (getvar "textstyle"))
                       (cons 10 P_center)
                       (cons 11 P_center)
                       (cons 40 (getvar "textsize"))
                       (cons 72 1)
                       (cons 73 2)
                       (cons 1 (rtos (vlax-curve-getArea poly) 2 2))
                   )
               )
           )
           (princ)
       )
       (alert "No selected lwpolyline")
   )
)        

;; LWPolyline to Point List  -  Lee Mac
;; Returns a list of points describing the supplied LWPolyline
(defun LM:LWPoly->List ( ent / der di1 di2 inc lst par rad )
   (setq par 0)
   (repeat (cdr (assoc 90 (entget ent)))
       (if (setq der (vlax-curve-getsecondderiv ent par))
           (if (equal der '(0.0 0.0 0.0) 1e-
               (setq lst (cons (vlax-curve-getpointatparam ent par) lst))
               (if
                   (setq rad (distance '(0.0 0.0) (vlax-curve-getfirstderiv ent par))
                         di1 (vlax-curve-getdistatparam ent par)
                         di2 (vlax-curve-getdistatparam ent (1+ par))
                   )
                   (progn
                       (setq inc (/ (- di2 di1) (1+ (fix (* 10 (/ (- di2 di1) rad (+ pi pi)))))))
                       (while (< di1 di2)
                           (setq lst (cons (vlax-curve-getpointatdist ent di1) lst)
                                 di1 (+ di1 inc)
                           )
                       )
                   )
               )
           )
       )
       (setq par (1+ par))
   )
   (setq x lst)
   lst
)

; Restituisce una griglia di punti all'interno del getboundingbox della poly selezionata
; Returns a grid of points within the BoundingBox of the selected poly
(defun grid_1 (/ P1_ P2_ n P> )
   (vla-getboundingbox POLY_vl 'p1 'p2)
   (setq P1_ (vlax-safearray->list p1))
   (setq P2_ (vlax-safearray->list p2))
   (setq P1_ (list (car P1_) (cadr P1_)))
   (setq P2_ (list (car P2_) (cadr P2_)))
   (setq Dx (/ (- (car P2_) (car P1_)) step1))
   (setq Dy (/ (- (cadr P2_) (cadr P1_)) step1))
   (setq n 0)
   (setq P> P1_)
   (setq Lp (list P1_))
   (repeat (* (1+ step1) step1)
       (setq P> (list (+ (car P>) Dx) (cadr P>)))
       (setq Lp (cons P> Lp))
       (setq n (1+ n))
       (if (= n step1)
           (progn
               (setq n 0)
               (setq P1_ (list (car P1_) (+ (cadr P1_) Dy)))
               (setq P> P1_)
               (setq Lp (cons P> Lp))
           )
       )
   )
   (setq Lp (cdr Lp))
   (setq a Lp)
)
  
; Restituisce una griglia di punti intorno al punto centrale (provvisorio)
; Returns a grid of points around the center point (provisional)
(defun grid_2 (/ P1_  P> n)
   (setq list_p_int nil)
   (setq P1_ (list (- (car P_center) (* Dx 2)) (- (cadr P_center) (* Dy 2))))
   (setq Dx (/ (* 4 Dx) step2))
   (setq Dy (/ (* 4 Dy) step2))
   (setq n 0)
   (setq P> P1_)
   (setq list_p_int (list P1_))
   (repeat (* (1+ step2) step2)
       (setq P> (list (+ (car P>) Dx) (cadr P>)))
       (setq list_p_int (cons P> list_p_int))
       (setq n (1+ n))
       (if (= n step2)
           (progn
               (setq n 0)
               (setq P1_ (list (car P1_) (+ (cadr P1_) Dy)))
               (setq P> P1_)
               (setq list_p_int (cons P> list_p_int))
           )
       )
   )
   (setq d  list_p_int)
)
   
; restituisce la lista dei punti interni ad un poligono
; dati:  - lista coordinate dei punti -> Lp
;        - lista coordinate vertici poligono -> list_vert_poly
; Returns the list of inside points 
(defun Point_int (/ P_distant n Pr cont attr p# Pa Pa_ Pb )
   (setq P_distant (list (car (getvar "extmax")) (* 2 (cadr (getvar "extmax")))))    
   (setq list_p_int nil)
   (foreach Pr Lp 
       (setq cont -1)
       (setq attr 0)
       (setq p# nil) 
       (setq Pa (nth (setq cont (1+ cont)) list_vert_poly))
       (setq Pa_ Pa)
       (repeat (length list_vert_poly)
           (setq Pb (nth (setq cont (1+ cont)) list_vert_poly))
           (if (= cont (length list_vert_poly)) (setq Pb Pa_))
           (setq P# (inters Pa Pb Pr P_distant))
           (if (/= P# nil) (setq attr (1+ attr)))
           (setq Pa Pb)
       )
       (if (> (rem attr 2) 0) (setq list_p_int (cons Pr list_p_int)))      
   )
   (setq b list_p_int)
)

; Infittisce la griglia inserendo altri punti
; nel centro delle diagonali tra i punti interni
; Increases the grid density
(defun grid+ (/ G+)
   (setq G+
       (mapcar '(lambda ( x ) (list (+ (car x) (/ Dx 2)) (+ (cadr x) (/ Dy 2)))) list_p_int)
   )
   (setq list_p_int (append G+ list_p_int))
   (setq c list_p_int)
)

; Da una lista di punti restituisce quello più lontano da un oggetto
; dati:  - lista dei punti -> list_p_int
;        - oggetto -> POLY_vl
; Returns the farthest point from the polyline
(defun Point_center (/ Pa n Pvic)
   (setq Dist 0.0000001)
   (setq P_center nil)
   (foreach Pa list_p_int
(setq Pvic (vlax-curve-getClosestPointTo POLY_vl Pa))
       (if (> (distance Pa Pvic) Dist)
           (progn
               (setq P_center Pa)
               (setq Dist (distance Pa Pvic))
           )
       )
   )
   (setq jjj (1+ jjj))
   (setq pc P_center)
)

(vl-load-com)
(prompt "\n ") (prompt "\n ") (prompt "\n ")
(princ "\nType \"ARPOLY\" to invoke")
(princ)
 

 

hi dont load for me 

error arrond expression 

(princ)

Link to comment
Share on other sites

On 3/10/2024 at 4:22 AM, DELLA MAGGIORA YANN said:

hi dont load for me 

error arrond expression 

(princ)

 Try this below. I found the error of a missing parenthesis and number in the LM:LWPoly->List function.  Tested and works.

(if (equal der '(0.0 0.0 0.0) 1e-8);;<--- Missing parenthesis and fuzz expression was here.

 

Full code:

;;   Write the area of the selected polylines in the position of   ;;
;;   maximum inscribed circle.                                     ;;
;;                                                                 ;;
;;   19.01.2013 - Gian Paolo Cattaneo                              ;;

(defun c:arpoly (/ sel poly POLY_vl Dx Dy Lp List_vert_poly list_p_int P_center dist step1 step2)
   (prompt "\nSelect Polyline: ")
   (setq sel (ssget '((0 . "LWPOLYLINE"))))
   (if sel
       (progn
           (repeat (setq :n (sslength sel))
               (setq poly (ssname sel (setq :n (1- :n))))
               (setq jjj 0)
               (setq step1 30) ;--> grid_1 density
               (setq step2 10) ;--> grid_2 density
               (setq POLY_vl (vlax-ename->vla-object POLY))
               (setq list_vert_poly (LM:LWPoly->List POLY))
               (grid_1)   
               (Point_int)
               ;(grid+) ;increase accuracy
               (Point_center)
               (if (= jjj 1) (setq p_prov P_center))
              ;(repeat 2 ;increase accuracy
                   (grid_2) 
                   (Point_center)
              
               (entmake
                   (list
                       (cons 0 "TEXT")
                       (cons 8 (getvar "clayer"))
                       (cons 7 (getvar "textstyle"))
                       (cons 10 P_center)
                       (cons 11 P_center)
                       (cons 40 (getvar "textsize"))
                       (cons 72 1)
                       (cons 73 2)
                       (cons 1 (rtos (vlax-curve-getArea poly) 2 2))
                   )
               )
           )
           (princ)
       )
       (alert "No selected lwpolyline")
   )
)        

;; LWPolyline to Point List  -  Lee Mac
;; Returns a list of points describing the supplied LWPolyline
(defun LM:LWPoly->List ( ent / der di1 di2 inc lst par rad )
   (setq par 0)
   (repeat (cdr (assoc 90 (entget ent)))
       (if (setq der (vlax-curve-getsecondderiv ent par))
           (if (equal der '(0.0 0.0 0.0) 1e-8);;<--- Missing parenthesis and fuzz expression was here.
               (setq lst (cons (vlax-curve-getpointatparam ent par) lst))
               (if
                   (setq rad (distance '(0.0 0.0) (vlax-curve-getfirstderiv ent par))
                         di1 (vlax-curve-getdistatparam ent par)
                         di2 (vlax-curve-getdistatparam ent (1+ par))
                   )
                   (progn
                       (setq inc (/ (- di2 di1) (1+ (fix (* 10 (/ (- di2 di1) rad (+ pi pi)))))))
                       (while (< di1 di2)
                           (setq lst (cons (vlax-curve-getpointatdist ent di1) lst)
                                 di1 (+ di1 inc)
                           )
                       )
                   )
               )
           )
       )
       (setq par (1+ par))
   )
   (setq x lst)
   lst
)

; Restituisce una griglia di punti all'interno del getboundingbox della poly selezionata
; Returns a grid of points within the BoundingBox of the selected poly
(defun grid_1 (/ P1_ P2_ n P> )
   (vla-getboundingbox POLY_vl 'p1 'p2)
   (setq P1_ (vlax-safearray->list p1))
   (setq P2_ (vlax-safearray->list p2))
   (setq P1_ (list (car P1_) (cadr P1_)))
   (setq P2_ (list (car P2_) (cadr P2_)))
   (setq Dx (/ (- (car P2_) (car P1_)) step1))
   (setq Dy (/ (- (cadr P2_) (cadr P1_)) step1))
   (setq n 0)
   (setq P> P1_)
   (setq Lp (list P1_))
   (repeat (* (1+ step1) step1)
       (setq P> (list (+ (car P>) Dx) (cadr P>)))
       (setq Lp (cons P> Lp))
       (setq n (1+ n))
       (if (= n step1)
           (progn
               (setq n 0)
               (setq P1_ (list (car P1_) (+ (cadr P1_) Dy)))
               (setq P> P1_)
               (setq Lp (cons P> Lp))
           )
       )
   )
   (setq Lp (cdr Lp))
   (setq a Lp)
)
  
; Restituisce una griglia di punti intorno al punto centrale (provvisorio)
; Returns a grid of points around the center point (provisional)
(defun grid_2 (/ P1_  P> n)
   (setq list_p_int nil)
   (setq P1_ (list (- (car P_center) (* Dx 2)) (- (cadr P_center) (* Dy 2))))
   (setq Dx (/ (* 4 Dx) step2))
   (setq Dy (/ (* 4 Dy) step2))
   (setq n 0)
   (setq P> P1_)
   (setq list_p_int (list P1_))
   (repeat (* (1+ step2) step2)
       (setq P> (list (+ (car P>) Dx) (cadr P>)))
       (setq list_p_int (cons P> list_p_int))
       (setq n (1+ n))
       (if (= n step2)
           (progn
               (setq n 0)
               (setq P1_ (list (car P1_) (+ (cadr P1_) Dy)))
               (setq P> P1_)
               (setq list_p_int (cons P> list_p_int))
           )
       )
   )
   (setq d  list_p_int)
)
   
; restituisce la lista dei punti interni ad un poligono
; dati:  - lista coordinate dei punti -> Lp
;        - lista coordinate vertici poligono -> list_vert_poly
; Returns the list of inside points 
(defun Point_int (/ P_distant n Pr cont attr p# Pa Pa_ Pb )
   (setq P_distant (list (car (getvar "extmax")) (* 2 (cadr (getvar "extmax")))))    
   (setq list_p_int nil)
   (foreach Pr Lp 
       (setq cont -1)
       (setq attr 0)
       (setq p# nil) 
       (setq Pa (nth (setq cont (1+ cont)) list_vert_poly))
       (setq Pa_ Pa)
       (repeat (length list_vert_poly)
           (setq Pb (nth (setq cont (1+ cont)) list_vert_poly))
           (if (= cont (length list_vert_poly)) (setq Pb Pa_))
           (setq P# (inters Pa Pb Pr P_distant))
           (if (/= P# nil) (setq attr (1+ attr)))
           (setq Pa Pb)
       )
       (if (> (rem attr 2) 0) (setq list_p_int (cons Pr list_p_int)))      
   )
   (setq b list_p_int)
)

; Infittisce la griglia inserendo altri punti
; nel centro delle diagonali tra i punti interni
; Increases the grid density
(defun grid+ (/ G+)
   (setq G+
       (mapcar '(lambda ( x ) (list (+ (car x) (/ Dx 2)) (+ (cadr x) (/ Dy 2)))) list_p_int)
   )
   (setq list_p_int (append G+ list_p_int))
   (setq c list_p_int)
)

; Da una lista di punti restituisce quello più lontano da un oggetto
; dati:  - lista dei punti -> list_p_int
;        - oggetto -> POLY_vl
; Returns the farthest point from the polyline
(defun Point_center (/ Pa n Pvic)
   (setq Dist 0.0000001)
   (setq P_center nil)
   (foreach Pa list_p_int
   (setq Pvic (vlax-curve-getClosestPointTo POLY_vl Pa))
       (if (> (distance Pa Pvic) Dist)
           (progn
               (setq P_center Pa)
               (setq Dist (distance Pa Pvic))
           )
       )
   )
   (setq jjj (1+ jjj))
   (setq pc P_center)
)

(vl-load-com)
(prompt "\n ") (prompt "\n ") (prompt "\n ")
(princ "\nType \"ARPOLY\" to invoke")
(princ)

 

Link to comment
Share on other sites

Il y a 19 heures, Pkenewell a dit :

Essayez ceci ci-dessous. J’ai trouvé l’erreur d’une parenthèse et d’un numéro manquants dans la fonction LM :LWPoly->List. Testé et fonctionne.

(if (equal der '(0.0 0.0 0.0) 1e-8);;<--- Missing parenthesis and fuzz expression was here.

 

Code complet :

;;   Write the area of the selected polylines in the position of   ;;
;;   maximum inscribed circle.                                     ;;
;;                                                                 ;;
;;   19.01.2013 - Gian Paolo Cattaneo                              ;;

(defun c:arpoly (/ sel poly POLY_vl Dx Dy Lp List_vert_poly list_p_int P_center dist step1 step2)
   (prompt "\nSelect Polyline: ")
   (setq sel (ssget '((0 . "LWPOLYLINE"))))
   (if sel
       (progn
           (repeat (setq :n (sslength sel))
               (setq poly (ssname sel (setq :n (1- :n))))
               (setq jjj 0)
               (setq step1 30) ;--> grid_1 density
               (setq step2 10) ;--> grid_2 density
               (setq POLY_vl (vlax-ename->vla-object POLY))
               (setq list_vert_poly (LM:LWPoly->List POLY))
               (grid_1)   
               (Point_int)
               ;(grid+) ;increase accuracy
               (Point_center)
               (if (= jjj 1) (setq p_prov P_center))
              ;(repeat 2 ;increase accuracy
                   (grid_2) 
                   (Point_center)
              
               (entmake
                   (list
                       (cons 0 "TEXT")
                       (cons 8 (getvar "clayer"))
                       (cons 7 (getvar "textstyle"))
                       (cons 10 P_center)
                       (cons 11 P_center)
                       (cons 40 (getvar "textsize"))
                       (cons 72 1)
                       (cons 73 2)
                       (cons 1 (rtos (vlax-curve-getArea poly) 2 2))
                   )
               )
           )
           (princ)
       )
       (alert "No selected lwpolyline")
   )
)        

;; LWPolyline to Point List  -  Lee Mac
;; Returns a list of points describing the supplied LWPolyline
(defun LM:LWPoly->List ( ent / der di1 di2 inc lst par rad )
   (setq par 0)
   (repeat (cdr (assoc 90 (entget ent)))
       (if (setq der (vlax-curve-getsecondderiv ent par))
           (if (equal der '(0.0 0.0 0.0) 1e-8);;<--- Missing parenthesis and fuzz expression was here.
               (setq lst (cons (vlax-curve-getpointatparam ent par) lst))
               (if
                   (setq rad (distance '(0.0 0.0) (vlax-curve-getfirstderiv ent par))
                         di1 (vlax-curve-getdistatparam ent par)
                         di2 (vlax-curve-getdistatparam ent (1+ par))
                   )
                   (progn
                       (setq inc (/ (- di2 di1) (1+ (fix (* 10 (/ (- di2 di1) rad (+ pi pi)))))))
                       (while (< di1 di2)
                           (setq lst (cons (vlax-curve-getpointatdist ent di1) lst)
                                 di1 (+ di1 inc)
                           )
                       )
                   )
               )
           )
       )
       (setq par (1+ par))
   )
   (setq x lst)
   lst
)

; Restituisce una griglia di punti all'interno del getboundingbox della poly selezionata
; Returns a grid of points within the BoundingBox of the selected poly
(defun grid_1 (/ P1_ P2_ n P> )
   (vla-getboundingbox POLY_vl 'p1 'p2)
   (setq P1_ (vlax-safearray->list p1))
   (setq P2_ (vlax-safearray->list p2))
   (setq P1_ (list (car P1_) (cadr P1_)))
   (setq P2_ (list (car P2_) (cadr P2_)))
   (setq Dx (/ (- (car P2_) (car P1_)) step1))
   (setq Dy (/ (- (cadr P2_) (cadr P1_)) step1))
   (setq n 0)
   (setq P> P1_)
   (setq Lp (list P1_))
   (repeat (* (1+ step1) step1)
       (setq P> (list (+ (car P>) Dx) (cadr P>)))
       (setq Lp (cons P> Lp))
       (setq n (1+ n))
       (if (= n step1)
           (progn
               (setq n 0)
               (setq P1_ (list (car P1_) (+ (cadr P1_) Dy)))
               (setq P> P1_)
               (setq Lp (cons P> Lp))
           )
       )
   )
   (setq Lp (cdr Lp))
   (setq a Lp)
)
  
; Restituisce una griglia di punti intorno al punto centrale (provvisorio)
; Returns a grid of points around the center point (provisional)
(defun grid_2 (/ P1_  P> n)
   (setq list_p_int nil)
   (setq P1_ (list (- (car P_center) (* Dx 2)) (- (cadr P_center) (* Dy 2))))
   (setq Dx (/ (* 4 Dx) step2))
   (setq Dy (/ (* 4 Dy) step2))
   (setq n 0)
   (setq P> P1_)
   (setq list_p_int (list P1_))
   (repeat (* (1+ step2) step2)
       (setq P> (list (+ (car P>) Dx) (cadr P>)))
       (setq list_p_int (cons P> list_p_int))
       (setq n (1+ n))
       (if (= n step2)
           (progn
               (setq n 0)
               (setq P1_ (list (car P1_) (+ (cadr P1_) Dy)))
               (setq P> P1_)
               (setq list_p_int (cons P> list_p_int))
           )
       )
   )
   (setq d  list_p_int)
)
   
; restituisce la lista dei punti interni ad un poligono
; dati:  - lista coordinate dei punti -> Lp
;        - lista coordinate vertici poligono -> list_vert_poly
; Returns the list of inside points 
(defun Point_int (/ P_distant n Pr cont attr p# Pa Pa_ Pb )
   (setq P_distant (list (car (getvar "extmax")) (* 2 (cadr (getvar "extmax")))))    
   (setq list_p_int nil)
   (foreach Pr Lp 
       (setq cont -1)
       (setq attr 0)
       (setq p# nil) 
       (setq Pa (nth (setq cont (1+ cont)) list_vert_poly))
       (setq Pa_ Pa)
       (repeat (length list_vert_poly)
           (setq Pb (nth (setq cont (1+ cont)) list_vert_poly))
           (if (= cont (length list_vert_poly)) (setq Pb Pa_))
           (setq P# (inters Pa Pb Pr P_distant))
           (if (/= P# nil) (setq attr (1+ attr)))
           (setq Pa Pb)
       )
       (if (> (rem attr 2) 0) (setq list_p_int (cons Pr list_p_int)))      
   )
   (setq b list_p_int)
)

; Infittisce la griglia inserendo altri punti
; nel centro delle diagonali tra i punti interni
; Increases the grid density
(defun grid+ (/ G+)
   (setq G+
       (mapcar '(lambda ( x ) (list (+ (car x) (/ Dx 2)) (+ (cadr x) (/ Dy 2)))) list_p_int)
   )
   (setq list_p_int (append G+ list_p_int))
   (setq c list_p_int)
)

; Da una lista di punti restituisce quello più lontano da un oggetto
; dati:  - lista dei punti -> list_p_int
;        - oggetto -> POLY_vl
; Returns the farthest point from the polyline
(defun Point_center (/ Pa n Pvic)
   (setq Dist 0.0000001)
   (setq P_center nil)
   (foreach Pa list_p_int
   (setq Pvic (vlax-curve-getClosestPointTo POLY_vl Pa))
       (if (> (distance Pa Pvic) Dist)
           (progn
               (setq P_center Pa)
               (setq Dist (distance Pa Pvic))
           )
       )
   )
   (setq jjj (1+ jjj))
   (setq pc P_center)
)

(vl-load-com)
(prompt "\n ") (prompt "\n ") (prompt "\n ")
(princ "\nType \"ARPOLY\" to invoke")
(princ)

 

Super ça marche merci.
comment pouvons-nous mettre l’air en M²
mon unité de dessin est en millimètres ?

Link to comment
Share on other sites

4 hours ago, DELLA MAGGIORA YANN said:

Super ça marche merci.
comment pouvons-nous mettre l’air en M²
mon unité de dessin est en millimètres ?

@DELLA MAGGIORA YANN Easily. Change the following line; it will convert from millimeters to Meters and adds a unit string "M2"

;;From this:
(cons 1 (rtos (vlax-curve-getArea poly) 2 2))

;;To This:
(cons 1 (strcat (rtos (/ (vlax-curve-getArea poly) 1000) 2 2) "M" (chr 178)))

;; OR Alternately - since this will be easier to read and you can easily use other units later:
(cons 1 (strcat (rtos (cvunit (vlax-curve-getArea poly) "mm" "m") 2 2) "M" (chr 178)))

image.png.bfb441122f5fe2f37fdf2c82d6c7a0b7.png

 

OR - If you don't want the units string:

(cons 1 (rtos (cvunit (vlax-curve-getArea poly) "mm" "m") 2 2))

 

Edited by pkenewell
Link to comment
Share on other sites

il y a 6 heures, pkenewell Elle a dit :

@DELLA MAGGIORA YANN Facilement. Modifiez la ligne suivante ; il convertira de millimètres en mètres et ajoute une chaîne d’unité « M2"

;;From this:
(cons 1 (rtos (vlax-curve-getArea poly) 2 2))

;;To This:
(cons 1 (strcat (rtos (/ (vlax-curve-getArea poly) 1000) 2 2) "M" (chr 178)))

;; OR Alternately - since this will be easier to read and you can easily use other units later:
(cons 1 (strcat (rtos (cvunit (vlax-curve-getArea poly) "mm" "m") 2 2) "M" (chr 178)))

image.png.bfb441122f5fe2f37fdf2c82d6c7a0b7.png

 

OU - Si vous ne voulez pas de la chaîne d’unités :

(cons 1 (rtos (cvunit (vlax-curve-getArea poly) "mm" "m") 2 2))

 

Merci ça a marché
mais pour avoir des M² j’ai remplacé la division valeur 1000 par 1000000 

((cons 1 (strcat (rtos (/ (vlax-curve-getArea poly) 1000000) 2 2) « M » (chr 178)))
merci encore c’est super
j’apprends petit à petit

Link to comment
Share on other sites

16 hours ago, DELLA MAGGIORA YANN said:

Merci ça a marché
mais pour avoir des M² j’ai remplacé la division valeur 1000 par 1000000 

((cons 1 (strcat (rtos (/ (vlax-curve-getArea poly) 1000000) 2 2) « M » (chr 178)))
merci encore c’est super
j’apprends petit à petit

 

Translation:

Thanks it worked but to have M² I replaced the division value 1000 by 1000000 ((cons 1 (strcat (rtos (/ (vlax-curve-getArea poly) 1000000) 2 2) "M" (chr 178))) thank you again it’s great I learn little by little

@DELLA MAGGIORA YANN Yes - you're right my apologies. I got the conversion factor wrong - I was thinking in length instead of Area 😜. As I noted with the alternative, you could also use (cvunit):

(cons 1 (strcat (rtos (cvunit (vlax-curve-getArea poly) "sq mm" "sq m") 2 2) "M" (chr 178)))

Which does the math for you.

 

Edited by pkenewell
Link to comment
Share on other sites

10 hours ago, BIGAL said:

Please english.

@BIGAL get the Goggle Translate extension for your browser - very helpful when you need a translation. 👍

Link to comment
Share on other sites

21 hours ago, pkenewell said:

@BIGAL Procurez-vous l’extension Goggle Translate pour votre navigateur - très utile lorsque vous avez besoin d’une traduction. 👍

Sorry for the translation, I use Google translate but I copied the wrong text.
thank you for your work

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...