black Posted October 28, 2019 Posted October 28, 2019 (edited) Merhaba, forumun yeni bir üyesi olacağım. Senden bir ricam var. 1-Elimdeki aynı katmanda çizilen polillerin uzunlukları, bana bir tablodaki sonucu verecek olan yükseklik ile çarpılacaktır. Tabloda bir sayı bölümü olacak ve bu sayılar çoklu çizgiye yazılacak ve kontrol edilecektir. 2- Elimdeki kapalı polilin alanları, belirleyeceğim ve sonuçları bir tablo halinde vereceğim yükseklikle çarpılacaktır. Tabloda bir sayı bölümü olacak ve bu sayılar çoklu çizgiye yazılacak ve kontrol edilecektir. İşlem sırası: 1- Polyline'ı seçin. 2- Yükseklik değerini isteyin ve klavyeden girin. 3- Tablonun gerçekleşeceği yeri tıklayın Ekli resimler bu konuda yardımcı olacaktır.İngilizcem için özür dilerim test.dwg Edited October 28, 2019 by black Quote
SLW210 Posted October 28, 2019 Posted October 28, 2019 This is the translation. Quote Hello I'm going to be a new member of the forum. I have a request from you. 1- The length of the polyls drawn in the same layer in my hand will be multiplied by the height that will give me the result in a table. There will be a number section in the table and these numbers will be written and checked on multiple lines. 2- The closed polyline areas in my hand will be multiplied by the height I will determine and the results will be as a table. There will be a number section in the table and these numbers will be written and checked on multiple lines. Order of operation: 1- Select Polyline. 2- Ask for the height value and enter from the keyboard. 3- Click where the table will take place Attached pictures will help with this. I'm sorry for my English Quote
black Posted October 28, 2019 Author Posted October 28, 2019 (edited) Forgive me. I wrote it without translating. Here's the original Hello, i'm going to haveI'm a new member of the forum. I have a request from you.1-The lengths of polylines drawn in the same layer in my hand will be multiplied by the height that will give me the result in a table. There will be a number section in the table, and these numbers will be written on the polyline and checked.2- The areas of the closed polylines in my hand will be multiplied by the height that I will determine and give the result in a table. There will be a number section in the table, and these numbers will be written on the polyline and checked.Order of operation:1- Choose polyline.2- Ask for the height value and enter it from the keyboard.3- Click where the table will occurThe attached images will help with the issue.I'm sorry for my English test.dwg Edited October 28, 2019 by black Quote
Emmanuel Delay Posted October 28, 2019 Posted October 28, 2019 Here is most of what you want. Command EPL There are a few problems though. - The order. If you want the same order as the numbers you wrote next to the polylines, then you must pick them one by one, in that same order - The circle is a bit of a problem. I think only returns half its length. Maybe better not use circles. - units. My table will return the same values as you can see in the properties. You divide by a factor 100 for some reason. I don't. (vl-load-com) (defun inserttable (lst pt / ht htc tab i j row tb acObj acDoc space width_cols) ;; settings, text height, cel height (setq ht 12.0) (setq htc 30.0) (setq width_cols (list 80.0 270.0 110.0 120.0 160.0 )) ;; document, model space, ... (setq acObj (vlax-get-acad-object) acDoc (vla-get-activedocument acObj) space (vlax-get acDoc (if (= 1 (getvar 'cvport)) 'PaperSpace 'ModelSpace)) ) (setq tab (vla-addtable space (vlax-3d-point pt) (length lst) (length (cadr lst)) (* 1.1 ht) (* 10.0 ht) )) ;; (vla-SetTextHeight tab 1 ht) (vla-SetTextHeight tab 2 ht) (vla-SetTextHeight tab 4 ht) (vla-put-VertCellMargin tab (* 0.3 ht)) (vla-put-HorzCellMargin tab (* 0.3 ht)) (setq i 0) (repeat (length lst) ;; iterates the rows (vla-setrowHeight tab i htc) (setq row (nth i lst)) (setq j 0) (repeat (length row) ;; iterates the cols in the row ;; (textbox (list (cons 1 (to_string x)) (cons 7 (getvar 'textstyle)) (cons 40 ht) )) (vla-SetColumnWidth tab j (nth j width_cols) ) (vla-SetText tab i j (nth j row) ) (setq j (+ j 1)) ) (setq i (+ i 1)) ) ;; default Autocad expects a title row. If the first row has more than 1 cel, let's unmerge this row (if (> (length (nth 0 lst)) 1) (vla-unMergeCells tab 0 0 0 0) ) ;; Merge last row, to show total ;; MergeCells minRow, maxRow, minCol, maxCol (vla-MergeCells tab (- (length lst) 1) (- (length lst) 1) 0 3) tab ) ;; test of inserttable (defun c:ila ( / ) (inserttable (list (list "P.NO" "EASTING" "NORTHING" "ELEV." "REMARKS") (list "P1" "20.5" "30.5" "40.5" "Hello") (list "P2" "50.5" "60.5" "70.5" "World!") ) (getpoint "\nInsert point of table: ") ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; length of polyline, or most other (curved) lines, spline, ... (defun length_curve (ent / ) (vlax-curve-getdistatparam ent (vlax-curve-getendparam ent)) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Export Polyline Lengths (defun c:EPL ( / plines i pline data lay len hei tot total) (setq hei (getreal "\nHeight: ")) (setq plines (ssget (list (cons 0 "LWPOLYLINE,POLYLINE,CIRCLE")))) (setq data (list (list " ") ;; Empty Title (list "NO" "Layer" "Length" "Height" "Total") ;; column titles ) ) (setq i 0) (setq total 0.0) (repeat (sslength plines) (setq pline (ssname plines i)) ;;(setq lst (vlax-get (vlax-ename->vla-object pline) 'coordinates)) ;;(if (= "AcDb2dPolyline" (vla-get-ObjectName (vlax-ename->vla-object pline))) ;; polyline or 2D polyline ? ;; (setq pts (3d-coord->pt-lstrjp lst)) ;; (setq pts (2d-coord->pt-lst lst)) ;;) (setq len (length_curve pline)) (setq tot (* len hei)) (setq lay (cdr (assoc 8 (entget pline)))) (setq data (append data (list (list (itoa (+ i 1)) ;; number lay ;; Layer (rtos len 2 3) ;; length (rtos hei 2 3) ;; height (rtos tot 2 3) ;; total ) ))) (setq total (+ total tot)) (setq i (+ i 1)) ) (setq data (append data (list (list "Total" "" "" "" (rtos total 2 3) ;; total ) ))) (inserttable data (getpoint "\nInsert point of table: ") ) ) 1 Quote
black Posted October 28, 2019 Author Posted October 28, 2019 Mr. Emmanuel; Thank you for your help. I tried the code you sent me. Lisp is working perfectly right now. I'm waiting for your help with the following matters. 1-The numbers in the table need to be on the polylines. The order of the numbers doesn't matter. It could also be in a mixed order in the table. What's important is that your procedure on that number can be checked. So polyline needs to throw the numbers on to lispin, not me. 2-I'm doing polylines with the code you sent. I also requested the field in the Dwg case. Can you help with the field with the same logic? Quote
BIGAL Posted October 28, 2019 Posted October 28, 2019 (edited) Emmanuel The order. Make a list ( (num entityname)(num entityname)(num entityname).. then sort on number then process the list An old bit of code below changed to include the sort. ; area using bpoly based on text inside a closed object circle ok. ; By Alan H Oct 2019 (defun AH:table_make (numcolumns txtsz / numrows curspc colwidth numcolumns numrows rowheight sp doc) (vl-load-com) (setq sp (vlax-3d-point (getpoint "Pick top left"))); or use getpoint (setq doc (vla-get-activedocument (vlax-get-acad-object) )) (if (= (vla-get-activespace doc) 0) (setq curspc (vla-get-paperspace doc)) (setq curspc (vla-get-modelspace doc)) ) (setq numrows 2) (setq rowheight (* 2.0 txtsz)) (setq colwidth 50) (setq tobj (vla-addtable curspc sp numrows numcolumns rowheight colwidth)) (vla-settext tobj 0 0 "TABLE title") (vla-SetTextHeight tObj (+ acDataRow acTitleRow acHeaderRow) txtsz) (princ) ) (defun c:ahobjarea ( / ins txt obj2 objid lay x lst ent area ss) (setq obj (vlax-ename->vla-object (car (entsel "pick text")))) (setq lay (vla-get-layer obj)) (princ "\nPick all text") (setq ss (ssget (list (cons 0 "text")(cons 8 lay)))) (setq lst '()) (repeat (setq x (sslength ss)) (setq ent (entget (ssname ss (setq x (- x 1))))) (setq ins (cdr (assoc 10 ent))) (setq txt (atoi (cdr (assoc 1 ent)))) (setq lst (cons (list txt ins ) lst)) ) (setq lst (vl-sort lst '(lambda (x y) (< (car x)(car y))) )) (AH:table_make 3 5) (setq x -1) (repeat (length lst) (setq ent (nth (setq x (+ x 1)) lst )) (setq objid (rtos (car ent ) 2 0)) (setq ins (cadr ent)) (command "bpoly" ins "") (setq obj2 (vlax-ename->vla-object (entlast))) (setq area (rtos (vla-get-area obj2) 2 2)) (command "erase" (entlast) "") (setq rownum (vla-get-rows tobj)) (vla-InsertRows tobj rownum (vla-GetRowHeight tobj (- rownum 1)) 1) (vla-settext tobj rownum 0 objid) (vla-settext tobj rownum 1 area) ) ) (c:ahobjarea) Edited October 29, 2019 by BIGAL Quote
black Posted October 28, 2019 Author Posted October 28, 2019 Mr. Bigal, i.e. I tried the lispi you sent. It works well. But it's not what I want it to be. I want the pose numbers in the table to be printed with lisp on polyline. Quote
BIGAL Posted October 29, 2019 Posted October 29, 2019 Understand its a different method that can be used in Emmanuels code. Yes it needs the table part to be added. Quote
black Posted October 29, 2019 Author Posted October 29, 2019 Thank you for your attention. I guess I wanted something hard. When the poses were printed on polyline, the account could be checked. Mr. Emmanuel length has done most of my work. You need to do the area account in the same way. Thanks.. Quote
black Posted October 29, 2019 Author Posted October 29, 2019 Mr. bigal You're close to what I want. But he has to write down the pose numbers inside the enclosed spaces. The same numbers will be on the table. The order of the numbers doesn't matter. Quote
BIGAL Posted October 29, 2019 Posted October 29, 2019 (edited) Post sample dwg, with table, it does label polygon. Edited October 29, 2019 by BIGAL Quote
black Posted October 29, 2019 Author Posted October 29, 2019 I'm using the code that Mr. Emmanuel im wrote. Can we multiply the total polyline length with height and get the result, as in the file I sent in the appendix? It'll be simpler. Regards.. Quote
CAD_Noob Posted October 18, 2022 Posted October 18, 2022 (edited) On 10/28/2019 at 9:46 PM, Emmanuel Delay said: Here is most of what you want. Command EPL There are a few problems though. - The order. If you want the same order as the numbers you wrote next to the polylines, then you must pick them one by one, in that same order - The circle is a bit of a problem. I think only returns half its length. Maybe better not use circles. - units. My table will return the same values as you can see in the properties. You divide by a factor 100 for some reason. I don't. (vl-load-com) (defun inserttable (lst pt / ht htc tab i j row tb acObj acDoc space width_cols) ;; settings, text height, cel height (setq ht 12.0) (setq htc 30.0) (setq width_cols (list 80.0 270.0 110.0 120.0 160.0 )) ;; document, model space, ... (setq acObj (vlax-get-acad-object) acDoc (vla-get-activedocument acObj) space (vlax-get acDoc (if (= 1 (getvar 'cvport)) 'PaperSpace 'ModelSpace)) ) (setq tab (vla-addtable space (vlax-3d-point pt) (length lst) (length (cadr lst)) (* 1.1 ht) (* 10.0 ht) )) ;; (vla-SetTextHeight tab 1 ht) (vla-SetTextHeight tab 2 ht) (vla-SetTextHeight tab 4 ht) (vla-put-VertCellMargin tab (* 0.3 ht)) (vla-put-HorzCellMargin tab (* 0.3 ht)) (setq i 0) (repeat (length lst) ;; iterates the rows (vla-setrowHeight tab i htc) (setq row (nth i lst)) (setq j 0) (repeat (length row) ;; iterates the cols in the row ;; (textbox (list (cons 1 (to_string x)) (cons 7 (getvar 'textstyle)) (cons 40 ht) )) (vla-SetColumnWidth tab j (nth j width_cols) ) (vla-SetText tab i j (nth j row) ) (setq j (+ j 1)) ) (setq i (+ i 1)) ) ;; default Autocad expects a title row. If the first row has more than 1 cel, let's unmerge this row (if (> (length (nth 0 lst)) 1) (vla-unMergeCells tab 0 0 0 0) ) ;; Merge last row, to show total ;; MergeCells minRow, maxRow, minCol, maxCol (vla-MergeCells tab (- (length lst) 1) (- (length lst) 1) 0 3) tab ) ;; test of inserttable (defun c:ila ( / ) (inserttable (list (list "P.NO" "EASTING" "NORTHING" "ELEV." "REMARKS") (list "P1" "20.5" "30.5" "40.5" "Hello") (list "P2" "50.5" "60.5" "70.5" "World!") ) (getpoint "\nInsert point of table: ") ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; length of polyline, or most other (curved) lines, spline, ... (defun length_curve (ent / ) (vlax-curve-getdistatparam ent (vlax-curve-getendparam ent)) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Export Polyline Lengths (defun c:EPL ( / plines i pline data lay len hei tot total) (setq hei (getreal "\nHeight: ")) (setq plines (ssget (list (cons 0 "LWPOLYLINE,POLYLINE,CIRCLE")))) (setq data (list (list " ") ;; Empty Title (list "NO" "Layer" "Length" "Height" "Total") ;; column titles ) ) (setq i 0) (setq total 0.0) (repeat (sslength plines) (setq pline (ssname plines i)) ;;(setq lst (vlax-get (vlax-ename->vla-object pline) 'coordinates)) ;;(if (= "AcDb2dPolyline" (vla-get-ObjectName (vlax-ename->vla-object pline))) ;; polyline or 2D polyline ? ;; (setq pts (3d-coord->pt-lstrjp lst)) ;; (setq pts (2d-coord->pt-lst lst)) ;;) (setq len (length_curve pline)) (setq tot (* len hei)) (setq lay (cdr (assoc 8 (entget pline)))) (setq data (append data (list (list (itoa (+ i 1)) ;; number lay ;; Layer (rtos len 2 3) ;; length (rtos hei 2 3) ;; height (rtos tot 2 3) ;; total ) ))) (setq total (+ total tot)) (setq i (+ i 1)) ) (setq data (append data (list (list "Total" "" "" "" (rtos total 2 3) ;; total ) ))) (inserttable data (getpoint "\nInsert point of table: ") ) ) Sorry for bumping this post... How can i change the unit to Meters? EDIT : I managed to Edit the units by following @mhupp instruction here : except for the TOTAL, I still cannot change the units. Edited October 19, 2022 by CAD_Noob Quote
CAD_Noob Posted October 19, 2022 Posted October 19, 2022 On 10/29/2019 at 11:51 PM, black said: I'm using the code that Mr. Emmanuel im wrote. Can we multiply the total polyline length with height and get the result, as in the file I sent in the appendix? It'll be simpler. Regards.. Agree with this, hope someone will edit the code... Quote
Emmanuel Delay Posted October 19, 2022 Posted October 19, 2022 Depends what exactly you mean. What you should do is set the units of your dwg meters, then draw stuff so that 1 unit in Model is 1 meter long. Then in the Layout (paper space) you set a scale on the viewport, so that you can print in a certain scale. Let's start over, can you re-upload a drawing? I'm not sure if we're talking about the same thing anymore. It's been a while Quote
marko_ribar Posted October 19, 2022 Posted October 19, 2022 Ne znam za Erdogana, ali zasto koristite u leksikonu "Turkey lenguage" reccu "var"? Quote
Recommended Posts
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.