All Activity
- Past hour
-
Ok I have the "group by code" for descriptions. So next step is a look up for layer name to match the description. The description look would have like CIV3D description keys. Any way thought I posted try "EXPORTTOAUTOCAD" a CIV3D command to do just that convert CIV3D objects to plain Autocad objects. Here is the file to do what you want, but try export first. @devitg give it a try. spagetti.lsp
- Today
-
Extracting data to excel from selected objects on different layers
kidznok replied to Hsanon's topic in AutoLISP, Visual LISP & DCL
Hi, I create dwg and xslx. I add hatch, circle, text, mtext and block. If someone have time and can help with that I will be grateful Date for lisp.dwgDate for lisp.xlsx -
Just tried it, I specified Charset parameter as "unicode" and it worked well, thanks!
-
How to stop flip action reversing offsets in dynamic block
jamami replied to jamami's topic in AutoCAD Drawing Management & Output
I think I am on top of this now, thank you for all you insightful comments . No need for additional code at this stage . -
@devitg the first two characters are already the identifiers, you can use @Lee Mac and Marco Ribar LM-MR:wcmatchx to extract it from the description. @BIGAL This is the reason why I'm trying to build this code library to avoid the export process in Civil 3D if you are doing a quick or small-scale projects since these will all end in a plain AutoCAD Template. By the way here is the complete flow of the process to create blocks and lines based on code description, I just cut the parts of Blocks and Lines Library cause it's too long. List of Line Groups here is simply a point list '(ENZ). That is why I'm trying to find other way to build a list of point groups then process it after all the csv lines are read. (if ; start the csv validation (and (setq fn (getfiled "\n" (getvar 'dwgprefix) "csv;txt;*" 16)) ; get csv file (setq cd (LM:readcsv fn)) ; read csv line thanks to @LeeMac ) ;and (progn (setq grd1 '() grd2 '() grd3 '() grd4 '() grd5 '() grd6 '() grd7 '() grd8 '() ; empty list for 8 simultaneous lines . ; and so on . . ) ;setq (foreach ln cd (if (= (length ln) 5) ; format = '( p e n z d ) (progn (setq ptn (nth 0 ln) ; point number des (nth 4 ln) ; point code plyr "0" ; default point/block layer if not in the code library tlyr "0" ; default annotation layer if not in the code library cs (/ 2.0 (getvar 'cannoscalevalue)) ; scale factor to be used for blocks hgt (/ 1.6 (getvar 'cannoscalevalue)) ; height factor to be used for annotation pt (list (atof (nth 1 ln)) (atof (nth 2 ln)) (atof (nth 3 ln))) ; insertion point ) ;setq (if (= 3 (length pt)) ; format = '( e n z ) to verify if 3D Point (setq pt (trans pt 1 0) ; convert point to ucs pt1 (list (car pt) (+ (cadr pt) (* hgt 0.6 (sqrt 2.5)))) ; text position (single line annotation) pt2 (list (car pt) (+ (cadr pt) (* hgt 0.95 (sqrt 2.5)))) ; text position (double line annotation) val (rtos (caddr pt) 2 2) ; text value based on description (default is elevation) mtp pt1 ; dummy string for annotation position ) ;setq ) ;if (cond ; First condition if Point Blocks ((= "BP" (TG:Read des "BP")) (setq plyr....)) ; If Match the Description set block preperties . ; and so on . . (t ; Else Lines ;;Start of Line List Group (cond ((or ; Set two conditions using LeeMac And Marco LM-MR:wcmatchx function (LM-MR:wcmatchx des "*@#*"....) ; Alpha-Numerical Combo (LM-MR:wcmatchx des "*@@*"....) ; Alphabet Combo ) (if (LM-MR:wcmatchx des "*L1*") ; If Match Description (progn (setq bn "HIDDEN"....) ; Set Block (Line End Points) and Line Propterties (setq grd1 (append (list pt) grd1)) ; Get Points for L1 Group ) ) (if (LM-MR:wcmatchx des "*L2*") ; If Match Description (progn (setq bn "HIDDEN"....) ; Set Block (Line End Points) and Line Propterties (setq grd2 (append (list pt) grd2)) ; Get Points for L2 Group ) ) . ; And so on . . ) (t ;Else if description is not found in the library (setq bn "HIDDEN" bs (* 0.5 cs) plyr "0" val "") ;Default Settings ) ;second T ) ;second cond ) ;first T ) ;first cond ; (if (/= val "") ; Annotation, Blocks and Lines Create if conditions are met (progn (tg:cr8mtx val tlyr hgt mtp) ; Call the function to generate annotations (tg:binsert bn pt bs ptn des plyr) ; Call the function to generate blocks ) (progn (tg:binsert bn pt bs ptn des plyr) ; Call the function to generate blocks (cond ((or ; Settings for Trigger to generate line groups (LM-MR:wcmatchx des "*L#A*") ; If Arc is ended (LM-MR:wcmatchx des "*L#C*") ; If Line is closed (LM-MR:wcmatchx des "*L#E*") ; If Line is ended ) (cond (((LM-MR:wcmatchx des "*L1*")) ; If L1 is called (TG:MKELN grd1 "GARDEN") ; Generate L1 Line List (setq grd1 '()) ; Reset L1 List after lines are generated ) ((=(LM-MR:wcmatchx des "*L2*")) ; If L2 is called (TG:MKELN grd2 "GARDEN") ; Generate L2 Line List (setq grd2 '()) ; Reset L2 List after lines are generated ) . ; And so on... . . ) ; inside cond ) ; GARDEN LINES GROUP ) ; first cond ) ; progn ) ; if val ) ; inside progn ) ; inside main ) ; foreach ln ) ; main progn ) ; main if csv ;; As of the moment (TG:MKELN LIST LAYER) Function is for Line Creation only, Arcs are not yet included since I'm still struggling on how to do it along the Line List Group. ;; What I'm trying to achieved is to create a list of point groups, if "S" or "E" or "A" is present in the code identifiers it will generate a new group of line points in the list. (setq mylist '( ("L1" '(pt1 pt2 p3....pn)) ; if Start or End is called create group ("L1" '(pt1 pt2 p3....pn)) ; if Arc is called create group ("L2" '(pt1 pt2 p3....pn)) ; another group for L2 if Start or End is called ("L1" '(pt1 pt2 p3....pn)) ; then another group for L1 if Start or End is called ) ) ;; Then process the list of lines and arcs after by calling the identifiers and corresponding group of points
-
-
How to stop flip action reversing offsets in dynamic block
BIGAL replied to jamami's topic in AutoCAD Drawing Management & Output
The idea is that you could break down the task to individual blocks and either have the five blocks or a dynamic block that sets the correct truss size visibilty but a say 10m would be 5 individual blocks, much easier to manipulate than have some 50 visibility states. Ok so just read the length match sizes if a size is 0 then don't add it to the draw trusses. I have also thought could save the build order in a different pattern say a 26m would be (26 "2x6" "1x2" "2x6") so the 2m truss would be in the middle. A 10 would be just (10 "2x5") its easy to convert the number of in a repeat. Re angle just insert the blocks and rotate all of them in one go. Yes needs new code which time permitting will do. - Yesterday
-
devitg started following Group list to make separate lines and Geometric center of open polyline, line
-
Geometric center of open polyline, line
devitg replied to maahee's topic in AutoLISP, Visual LISP & DCL
@Mahee , please give it a try , will work both for open and closed lwpolylines it get the Centroid from a temporary Region from a temporary closed polyline if poly is open get-center.LSP get-center.LSP get poly center.dwg -
@GLORY As I can get ,there are same point with same identifier (last text at csv line) Mybe you can add some new identification to group by it at same CSV Like this 1,21.188,19.762,0.000,L1S,pl1.1 4,32.984,30.378,0.000,L1,pl1.2 5,45.117,40.995,0.000,L1,pl1.3 8,57.587,50.937,0.000,L1E,pl1.4 2,31.804,7.629,0.000,L2S,pl2.1 3,44.106,18.077,0.000,L2,pl2.2 6,56.239,26.671,0.000,L2,pl2.3 7,68.878,36.782,0.000,L2E,pl2.4 9,49.168,65.549,0.000,L1S,pl3.1 10,43.612,72.164,0.000,L1,pl3.2 11,50.491,77.059,0.000,L1,pl3.3 12,55.253,70.179,0.000,L1C,pl3.4 13,41.363,59.993,0.000,L2S,pl4.1 14,34.616,68.460,0.000,L2,pl4.2 15,27.472,64.094,0.000,L2,pl4.3 16,33.954,55.495,0.000,L2C,pl4.4 Or state in a new csv which order belong to each polyline Say Line1 and 2 Group List- oredr + idfier.dwg
-
Sorry guys for the late reply. @devitgHere is an example of the drawing processed by the code I've been trying to work on for a while now. But it can only handle 2-Description at a time, either a combination of two different lines or a line and block combo. Let say, “L1E/L2S” or “L1S/BP” which is a point block and can no longer TRIGGER to read 3-Description csv line like “L1E/L2S/BP”, this kind of description can only plot the “BP”, it will not plot the "L1" lines calling “L1E” (the trigger) to plot L1 Group then start collection of L2 point groups. But upon checking the group list say for L1, the points are there inside that list but cannot trigger to plot the L1 group of points into lines since BP is already called in the first condition of the code. This is the reason I want to change the point collection list into groups and process the line list groups after reading all the lines in the csv. @BIGAL, thank you for your response. I also work in Civil 3D to process these kinds of data. The only problem is that you need to export it in plain AutoCAD format to arrange all the annotation etc., cause COGO are not easy to handle. Say aligning the annotation for block points to be aligned to lines or move it into desired location. Line1 and 2 Group List.dwg
-
Not sure about ZWCAD, but AutoCAD 2025 and newer now needs... (acet-load-expresstools) Do you have a link to specific LISP instructions for ZWCAD? Is there a LOFTNORMALS in ZWCAD?
-
How to stop flip action reversing offsets in dynamic block
jamami replied to jamami's topic in AutoCAD Drawing Management & Output
Thanks for this. How can the large size array be used ? does it need to be passed to a function ? -
Ok that is what you get in field survey using Total stations, GPS etc so you want to string the description. Yes I have something, working on it for Bricscad. I have spent over 45+ years doing civil work, so can see what you want, the simple answer is CIV3D or Civil Site Design or Carlson, etc that is civil software, When reading a points file it will string the points via a description, add blocks matching descriptions and more. I am working on the add blocks and line work on correct layer. Your csv processed. Happy to discuss further. But I don't intend to reinvent the wheel to much.
-
How to stop flip action reversing offsets in dynamic block
BIGAL replied to jamami's topic in AutoCAD Drawing Management & Output
I still think its easier to copy/array the dynamic block just setting the correct visibility state so that would be 2 3 4 5 6 only. No working out the dynamic pattern. Angle is not a problem. This is all your sizes up to length of 50 the pattern is length, how many 6s 5s 4s 3s 2s could do way more you can also change the way a length is made example 10 is 2x5 or a 6+4 ((51 8 0 0 1 0) (50 8 0 0 0 1) (49 7 1 0 0 1) (48 8 0 0 0 0) (47 7 1 0 0 0) (46 7 0 1 0 0) (45 7 0 0 1 0) (44 7 0 0 0 1) (43 6 1 0 0 1) (42 7 0 0 0 0) (41 6 1 0 0 0) (40 6 0 1 0 0) (39 6 0 0 1 0) (38 6 0 0 0 1) (37 5 1 0 0 1) (36 6 0 0 0 0) (35 5 1 0 0 0) (34 5 0 1 0 0) (33 5 0 0 1 0) (32 5 0 0 0 1) (31 4 1 0 0 1) (30 5 0 0 0 0) (29 4 1 0 0 0) (28 4 0 1 0 0) (27 4 0 0 1 0) (26 4 0 0 0 1) (25 3 1 0 0 1) (24 4 0 0 0 0) (23 3 1 0 0 0) (22 3 0 1 0 0) (21 3 0 0 1 0) (20 3 0 0 0 1) (19 2 1 0 0 1) (18 3 0 0 0 0) (17 2 1 0 0 0) (16 2 0 1 0 0) (15 2 0 0 1 0) (14 2 0 0 0 1) (13 1 1 0 0 1) (12 2 0 0 0 0) (11 1 1 0 0 0) (10 1 0 1 0 0) (9 1 0 0 1 0) (8 1 0 0 0 1) (7 0 1 0 0 1) (6 1 0 0 0 0) (5 0 1 0 0 0) (4 0 0 1 0 0) (3 0 0 0 1 0) (2 0 0 0 0 1)) - Last week
-
@GLORY Please upload a sample.dwg as you need it to be, at least 2 lines
-
GLORY started following Group list to make separate lines
-
Hello Everyone, I need some help; here is my list in csv 1,21.188,19.762,0.000,L1S 2,31.804,7.629,0.000,L2S 3,44.106,18.077,0.000,L2 4,32.984,30.378,0.000,L1 5,45.117,40.995,0.000,L1 6,56.239,26.671,0.000,L2 7,68.878,36.782,0.000,L2E 8,57.587,50.937,0.000,L1E 9,49.168,65.549,0.000,L1S 10,43.612,72.164,0.000,L1 11,50.491,77.059,0.000,L1 12,55.253,70.179,0.000,L1C 13,41.363,59.993,0.000,L2S 14,34.616,68.460,0.000,L2 15,27.472,64.094,0.000,L2 16,33.954,55.495,0.000,L2C And I want to make that list into something like this, (setq pt (list (nth 1 ln) (nth 2 ln) (nth 3 ln))) (setq mylist '( (("L1S" (list pt)) ("L1" (list pt))...("L1E" (list pt))) (("L2S" (list pt)) ("L2" (list pt))...("L2E" (list pt))) (("L1S" (list pt)) ("L1" (list pt))...("L1C" (list pt))) (("L2S" (list pt)) ("L2" (list pt))...("L2C" (list pt))) ) ) In order to plot the lines into groups by creating another set of group of points if the description has "S" or start at the end, say L1S for Line 1 Start. Thank you in advance.Line1 and 2 Group List.csv
-
lrm started following Geometric center of open polyline, line
-
Geometric center of open polyline, line
lrm replied to maahee's topic in AutoLISP, Visual LISP & DCL
The geometric center (a.k.a. centroid) of an open polyline is deteremined by summing the length of each line segment times the coordinates of the midpoint of the respective segment. The result is then divided by the total length of the polyline. It is NOT the average of the point locations. ; Calculates the centroid for an open lwpolyline ; lrm 8/9/2025 (defun c:pl_centroid (/ ss pt_lst sum_x sum_y sum_d n i d mid_pt centroid) (setq ss (entget (car (Entsel "\nSelect Open Polyline"))) pt_lst (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) ss) ) ) (setq sum_x 0 sum_y 0 sum_d 0.0 n (length pt_lst) i 0 ) (while (<= i (- n 2)) (setq d (distance (nth i pt_lst) (nth (+ i 1) pt_lst))) (setq mid_pt (mapcar '/ (mapcar '+ (nth i pt_lst) (nth (+ i 1) pt_lst)) '(2 2 2) ) ) (setq sum_x (+ sum_x (* (car mid_pt) d)) sum_y (+ sum_y (* (cadr mid_pt) d)) sum_d (+ d sum_d) i (+ i 1) ) ) (setq centroid (list (/ sum_x sum_d) (/ sum_y sum_d) ) ) (princ "\n Centroid at: ") (princ centroid) (command "_point" "_non" centroid) (princ) ) -
SELECT TEXTS OTHER THAN 3.5..HELP
Steven P replied to leonucadomi's topic in AutoLISP, Visual LISP & DCL
To enter the value into your selection set see below. In LISP the '( ... ) lists mean it is a static list, it is read exactly as it is written, (list ... ) means that CAD will create the list if for example variables are a part of the list, and (cons ... ), also used to create a list - in this case relevant to create a dotted pair. (setq MyThing 5) '(1 2 3 4 MyThing) is read as 1 2 3 4 MyThing - and an error since it is looking for MyThing to be a string, "MyThing" (list 1 2 3 4 MyThing) is read as 1 2 3 4 5 - list has been created by the LISP (cons 1 MyThing) is read as (1 . 5) So this might help... As above though you select the text with the selection set ss, but haven't done anything with it - if you are a part way through the LISP that is all good, but just put a report in so you can see it is working as it should as you go along perhaps (sslength SS) maybe. (Oh, just me, I also amended the indents, and added where commands end if over a few lines, I find it easier to read LISPs as below, that's all) (defun c:test (/ old_err EscVP StrScale2 TxtHt StrScale ss) (setq old_err *error*) (defun *error* ( a / ) ;; Add here return cmdecho to as it was, cmdecho 1 (princ "") (setq *error* old_err) (princ) ) ; End Error Defun (setvar "cmdecho" 0) ; perhaps record the state of cmdecho before here, and reset to that value at the end (if (and (setq EntVP (car (entsel "\Seleccione VIEWPORT: "))) (= (cdr (assoc 0 (entget EntVP))) "VIEWPORT") ) ; end and (progn (setq EscVP (vla-get-CustomScale (vlax-ename->vla-object EntVP))) (setq StrScale2 (rtos (* 3.5 (/ 1 EscVP)) 2 1)) (setq TxtHt (* 3.5 (/ 1 EscVP)) ) ; a number not a string ;; added this (setq StrScale (rtos (/ 1 EscVP) 2 2)) (setq vpnum (cdr (assoc 69 (entget EntVP )))) (vl-cmdf "_.mspace") (setvar "CVPORT" vpnum) (setq ss (ssget (list(0 . "TEXT") (-4 . "<>") (cons 40 TxtHt))) ) ;;What are you doing with ss now? (Prompt (strcat "\nLa escala de La Ventana es 1/" StrScale)) (princ "\nLos textos de 3.5 en el interior de la ventana deben ser de: ") (princ StrScale2) ) ; end progn ) ; end if (setvar "cmdecho" 1) (princ) );fin defun -
SELECT TEXTS OTHER THAN 3.5..HELP
GLAVCVS replied to leonucadomi's topic in AutoLISP, Visual LISP & DCL
Hi I think it would be easier to find the problem if you attached an example drawing. -
If your making layouts then do that then go into mspace pick the page details than pop back to pspace and fill in your title block not that hard. Yes a lisp. One of the things I have looked at is pick a point on dwg in Model space, select scale, select title block and make the layout. You could add pick the mtext for title block also. It will cost you a cup of coffee as have to hard code the title block details etc.
-
Geometric center of open polyline, line
BIGAL replied to maahee's topic in AutoLISP, Visual LISP & DCL
Not quite the middle of say 2 points. The red is the average answer. The green is gcen. so 4 answers. If the shape is say 4 points then you could force a close get the Gcen then do a undo. -
SELECT TEXTS OTHER THAN 3.5..HELP
leonucadomi replied to leonucadomi's topic in AutoLISP, Visual LISP & DCL
thanks, now I explain In the modelspace I have texts of different height in paperspace in the paperspace I have viewports of different scales If I use the chspace command and take those texts to paper space they should be 3.5 height I'm looking for a routine that helps me detect which texts do not meet that height in each viewport (defun c:test (/ EscVP StrScale2 StrScale) (setq old_err *error*)(defun *error* ( a / )(princ "") (setq *error* old_err)(princ)) (setvar "cmdecho" 0) (if (and (setq EntVP (car (entsel "\Seleccione VIEWPORT: "))) (= (cdr (assoc 0 (entget EntVP))) "VIEWPORT")) (progn (setq EscVP (vla-get-CustomScale (vlax-ename->vla-object EntVP))) (setq StrScale2 (rtos (* 3.5 (/ 1 EscVP)) 2 1)) (setq StrScale (rtos (/ 1 EscVP) 2 2) ) (setq vpnum (cdr (assoc 69 (entget EntVP ) ) ) ) (vl-cmdf "_.mspace") (setvar "CVPORT" vpnum) (setq ss (ssget '((0 . "TEXT") (-4 . "<>") (40 . 3.5))) ) (Prompt (strcat "\nLa escala de La Ventana es 1/" StrScale)) (princ "\nLos textos de 3.5 en el interior de la ventana deben ser de: ") (princ StrScale2) ) ) (setvar "cmdecho" 1) (princ) );fin defun I am looking to enter this calculated value here but it doesn't work -
Steven P started following SELECT TEXTS OTHER THAN 3.5..HELP
-
SELECT TEXTS OTHER THAN 3.5..HELP
Steven P replied to leonucadomi's topic in AutoLISP, Visual LISP & DCL
This (ssget '((0 . "TEXT") (-4 . "<>") (40 . 3.5))) should work. You can change "TEXT" to "*TEXT" to also capture MText Though looking at the code you have, I am assuming that is just a snippet of what you want to do. Here are a couple of hints: (defun c:pru ( / ss ) ;;Yup localised variables, C: prompt, all good (setq ss (ssget '((0 . "TEXT") (-4 . "<>") (40 . 3.5))) ) ;; ADDED (SETQ SS ... ) so that you can use the selection set later (princ (sslength ss)) ;; Added this in to show the result of the selection set (princ) ;;Exit quietly ) -
SELECT TEXTS OTHER THAN 3.5..HELP
leonucadomi replied to leonucadomi's topic in AutoLISP, Visual LISP & DCL
(defun c:pru2 ( / ss alturaColor colorNuevo) (setq alturaColor 3.5) ; Define la altura a verificar (setq colorNuevo 1) ; Define el color a aplicar (ej. rojo) (setq ss (ssget "X" '((0 . "TEXT,MTEXT")))) ; Selecciona todos los textos (if ss (progn (setq i 0) (while (setq en (ssname ss i)) (setq obj (vlax-ename->vla-object en)) (if (/= (vla-get-height obj) alturaColor) (vlax-put-property obj 'color colorNuevo) ; Cambia el color ) (setq i (1+ i)) ) ) ) (princ) ) This routine does what I need, but it has a problem that I cannot understand, I have objects in the paperspace that have a height of 3.5 and it recognizes them as if they did not have it and changes them to red. can someone help? thanks -
Dadgad started following SNAP mode hints
-
SNAP mode hints
Dadgad replied to Discus84's topic in AutoCAD 2D Drafting, Object Properties & Interface
LI & LU Layer isolate and Layer unisolate are extremely helpful, I concur. I also favor "all off" rather than "Fade". I am quite partial to the LAYERS 2 toolbar also.