Jump to content

uzunluk * yükseklik = tablo


black

Recommended Posts

Mr. Bigal
Thanks a lot. With the change you've written, the length * height is also complete
I'd appreciate it if you'd solve the problem with the selection when it's possible.
Once you've made the selections, the layers' knowledge comes to the screen. Don't let it come to the screen. Can we make a table before this comes?
Thanks

Link to comment
Share on other sites

  • Replies 33
  • Created
  • Last Reply

Top Posters In This Topic

  • black

    20

  • BIGAL

    14

Mr. Bigal, i.e.
I've made the change, but when the length*elevation runs, it's only calculated on one polyline. Not all polynis in the layer are calculated.
I think I changed the code wrong. Can you help with the change?

;;---------------------=={ Total Area }==---------------------;;
;;                                                            ;;
;;  Displays the total area of selected objects at the        ;;
;;  command line. The precision of the printed result is      ;;
;;  dependent on the setting of the LUPREC system variable.   ;;
;;------------------------------------------------------------;;
;;  Author: Lee Mac, Copyright © 2013 - www.lee-mac.com       ;;
;;------------------------------------------------------------;;

; Total area modified by Alanh to allow multiple pick by layer
; uses height in layer name for volume expect metric
; Nov 2019

;; Parse Numbers  -  Lee Mac
;; Parses a list of numerical values from a supplied string.
;;  Author: Lee Mac, Copyright © 2013 - www.lee-mac.com       ;;
;;------------------------------------------------------------;;

(defun LM:parsenumbers ( str )
    (   (lambda ( l )
            (read
                (strcat "("
                    (vl-list->string
                        (mapcar
                           '(lambda ( a b c )
                                (if (or (< 47 b 58)
                                        (and (= 45 b) (< 47 c 58) (not (< 47 a 58)))
                                        (and (= 46 b) (< 47 a 58) (< 47 c 58))
                                    )
                                    b 32
                                )
                            )
                            (cons nil l) l (append (cdr l) '(()))
                        )
                    )
                    ")"
                )
            )
        )
        (vl-string->list str)
    )
)

(defun ahmktable ( numr / colwidth numcolumns numrows rowheight sp vgad vgao vgms)
(vl-load-com)
(setq sp (vlax-3d-point (getpoint "select point for table")))
(Setq vgms (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))) ;
(setq numrows numr)
(setq numcolumns 5)
(setq rowheight 40)
(setq colwidth 200)
(setq objtable (vla-addtable vgms sp numrows numcolumns rowheight colwidth))
(vla-settext objtable 0 0 "KALIP METRAJ"); TABLE TITLE
(vla-settext objtable 1 0 "No") 
(vla-settext objtable 1 1 "LAYER") 
(vla-settext objtable 1 2 "TOTAL AREA")
(vla-settext objtable 1 3 "HEIGHT")
(vla-settext objtable 1 4 "VOL")
(vla-SetTextHeight Objtable (+ acDataRow acTitleRow acHeaderRow) 12)
(vla-Setcolumnwidth Objtable  0 35)
(vla-Setcolumnwidth Objtable  1 300)
(vla-Setcolumnwidth Objtable  2 200)
(vla-Setcolumnwidth Objtable  3 100)
(vla-Setcolumnwidth Objtable  4 200)
(princ)
)


(defun c:tvol ( / a i s ent lay ht objtable lst lst2)
(setq lst '())

(while (setq ent  (entsel "pick object for layer <Enter> to exit"))
    (setq lay (vla-get-layer (vlax-ename->vla-object (car ent))))
    (setq lst (cons (list lay ) lst))
)

(setq lst2 '())

(repeat (setq x (length lst))
    (setq lay (car (nth (setq x (- x 1)) lst)))
    (setq ht (/ (nth 0 (LM:parsenumbers lay)) 1000.0))
    (if (= (substr lay 1 1) "H")(setq ht (abs ht)))
                                  
    (setq s (ssget "X"  (list (cons 0  "LWPOLYLINE")(cons 8 lay))))
    	
    (if s
        (progn
            (setq a 0.0)
            (repeat (setq i (sslength s))
                (setq a (vlax-get (vlax-ename->vla-object (ssname s (setq i (1- i)))) 'Length))

                           )
            (alert (strcat "\nTotal Area for layer : " lay "  " (rtos a 2) "\n Total vol for height : " (rtos ht 2 3) "  " (rtos (* ht a) 2 2)))
	        )
    )
	(setq lst2 (cons (list  lay  a  ht) lst2))
  )

(ahmktable  (+ (length lst2) 3))

(setq voltot 0)
(setq no 1)
(setq row 2)
(setq i 0)
(repeat (setq x (length lst2))
(setq itlst (nth i lst2))
(vla-settext objtable  row 0 (rtos no 2 0))
(vla-settext objtable  row 1 (car itlst))
(vla-settext objtable  row  2 (rtos (cadr itlst) 2 3))
(vla-settext objtable  row  3  (rtos (caddr itlst) 2 3))
(vla-settext objtable  row  4  (rtos (*(cadr itlst)(caddr itlst)) 2 3))
(setq voltot (+ (*(cadr itlst)(caddr itlst)) voltot))
(setq row (+ row 1))
(setq i (+ i 1))
(setq no (+ no 1))
)
(vla-mergecells objtable (+ (length lst2) 2) (+ (length lst2) 2) 0 3)
(vla-settext objtable (+ (length lst2) 2) 0 "TOTAL Vol.")
(vla-settext objtable  (+ (length lst2) 2)  4 (rtos voltot 2 3))

(princ)
)
(vl-load-com) (princ)
(c:tvol)

 

Edited by black
Link to comment
Share on other sites

  • black changed the title to Lee Mac lenght * height = table

Can you please check this now just window the area of interest.

 

;;---------------------=={ Total Area }==---------------------;;
;;                                                            ;;
;;  Displays the total area of selected objects at the        ;;
;;  command line. The precision of the printed result is      ;;
;;  dependent on the setting of the LUPREC system variable.   ;;
;;------------------------------------------------------------;;
;;  Author: Lee Mac, Copyright © 2013 - www.lee-mac.com       ;;
;;------------------------------------------------------------;;

; Total area modified by Alanh to allow multiple pick by layer
; uses height in layer name for volume expect metric
; Nov 2019

;; Parse Numbers  -  Lee Mac
;; Parses a list of numerical values from a supplied string.
;;  Author: Lee Mac, Copyright © 2013 - www.lee-mac.com       ;;
;;------------------------------------------------------------;;

(defun LM:parsenumbers ( str )
    (   (lambda ( l )
            (read
                (strcat "("
                    (vl-list->string
                        (mapcar
                           '(lambda ( a b c )
                                (if (or (< 47 b 58)
                                        (and (= 45 b) (< 47 c 58) (not (< 47 a 58)))
                                        (and (= 46 b) (< 47 a 58) (< 47 c 58))
                                    )
                                    b 32
                                )
                            )
                            (cons nil l) l (append (cdr l) '(()))
                        )
                    )
                    ")"
                )
            )
        )
        (vl-string->list str)
    )
)

(defun ahmktable ( numr / colwidth numcolumns numrows rowheight sp vgad vgao vgms)
(vl-load-com)
(setq sp (vlax-3d-point (getpoint "select point for table")))
(Setq vgms (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))) ;
(setq numrows numr)
(setq numcolumns 5)
(setq rowheight 40)
(setq colwidth 200)
(setq objtable (vla-addtable vgms sp numrows numcolumns rowheight colwidth))
(vla-settext objtable 0 0 "KALIP METRAJ"); TABLE TITLE
(vla-settext objtable 1 0 "No") 
(vla-settext objtable 1 1 "LAYER") 
(vla-settext objtable 1 2 "TOTAL LENGTH")
(vla-settext objtable 1 3 "HEIGHT")
(vla-settext objtable 1 4 "AREA")
(vla-SetTextHeight Objtable (+ acDataRow acTitleRow acHeaderRow) 12)
(vla-Setcolumnwidth Objtable  0 35)
(vla-Setcolumnwidth Objtable  1 300)
(vla-Setcolumnwidth Objtable  2 200)
(vla-Setcolumnwidth Objtable  3 100)
(vla-Setcolumnwidth Objtable  4 200)
(princ)
)


(defun c:tvol ( / a i s ent lay ht objtable lst lst2)

(prompt "select plines")
(setq s (ssget  (list (cons 0  "LWPOLYLINE"))))

(setq lst '())
(repeat (setq x (sslength s))
(setq  ent (ssname s (setq x (- x 1))))
(setq ent (entget ent))
(setq lay (cdr (assoc 8 ent)))
(setq lst (cons lay lst))
)
(setq lst (vl-sort lst  '(lambda (x y) (< x y))))

(setq lst3 '())
(setq x 0)
(repeat (-(length lst) 1)
(if (= (nth x lst)(nth (setq x (+ x 1)) lst))
(princ )
(setq lst3 (cons (nth (- x 1) lst) lst3))
)
)
(setq lst3 (cons (nth (-(length lst) 1) lst) lst3))

(setq lst2 '())
(repeat (setq x (length lst3))
    (setq lay  (nth (setq x (- x 1)) lst3))
    (setq ht (/ (nth 0 (LM:parsenumbers lay)) 1000.0))
    (if (= (substr lay 1 1) "H")(setq ht (abs ht)))
    (setq s (ssget "X"  (list (cons 0  "LWPOLYLINE")(cons 8 lay))))
    (if s
        (progn
            (setq a 0.0)
            (repeat (setq i (sslength s))
                (setq a (+ a (vla-get-length (vlax-ename->vla-object (ssname s (setq i (1- i)))))))
            )
        )
    )
   (setq lst2 (cons (list  lay  a  ht) lst2))
)

(ahmktable  (+ (length lst2) 3))

(setq voltot 0)
(setq no 1)
(setq row 2)
(setq i 0)

(repeat (setq x (length lst2))
(setq itlst (nth i lst2))
(vla-settext objtable  row 0 (rtos no 2 0))
(vla-settext objtable  row 1 (car itlst))
(vla-settext objtable  row  2 (rtos (cadr itlst) 2 3))
(vla-settext objtable  row  3  (rtos (caddr itlst) 2 3))
(vla-settext objtable  row  4  (rtos (abs (*(cadr itlst)(caddr itlst))) 2 3))
(setq voltot (+ (abs (*(cadr itlst)(caddr itlst))) voltot))
(setq row (+ row 1))
(setq i (+ i 1))
(setq no (+ no 1))
)

(vla-mergecells objtable (+ (length lst2) 2) (+ (length lst2) 2) 0 3)
(vla-settext objtable (+ (length lst2) 2) 0 "TOTAL Area.")
(vla-settext objtable  (+ (length lst2) 2)  4 (rtos voltot 2 3))

(princ)
)
(vl-load-com) (princ)
(c:tvol)

 

Link to comment
Share on other sites

Mr. Bigal
Thank you very much. It's exactly what I want.
When I choose, can he process the lengths of the polylines I choose, not the entire length of that layer?

Edited by black
Link to comment
Share on other sites

Go back to the very 1st code provided, mix and match can be done. Your changing the request as we go along.

 

I have provided a couple of ways of doing it.So at this point the doing it for free stops. As its getting more and more complex involving selection choices.

 

So a good time to learn lisp and have a go.

Link to comment
Share on other sites

  • black changed the title to uzunluk * yükseklik = tablo

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