All Activity
- Past hour
-
- Today
-
Steven P started following The result of the difference of two columns with numbers
-
The result of the difference of two columns with numbers
Steven P replied to Nikon's topic in AutoLISP, Visual LISP & DCL
I haven't looked at the example - weekend and CAD is off, but how many rows do you have to calculate and on how many drawings? Reason I ask is I often find that the rule a LISP operates with are often not perfect and don't accommodate every situation - If the operation I need to do is not excessive then I refer to do it be select row text 1, row 1 text 2 and then place the result, repeat with row 2, and so on Things to also consider is an overkill on the texts to assess to remove duplicates, check that any mtexts are 1 line texts, text 1 or 2 are strings and not numbers, texts are not text or mtext (attributes, blocks, rtexts (they happen), mtexts don't cover both columns, texts don't cover both columns... and many more things that can stop the routine from completing or making a miss match from one column to the next. -
Here is a drawing with some lines and the bevel symbols that are just made from lines and dimensions. Which I created with a wblock as requested. I hope this is as you requested, Please correct me if it's not the way you wanted. block.dwg
-
The result of the difference of two columns with numbers
GLAVCVS replied to Nikon's topic in AutoLISP, Visual LISP & DCL
Hi There's a problem with n1 and n2: they're likely referring to texts that are next to each other. But that's unlikely to happen because it depends on the order in which they are found in the database. You should create a function that: 1) compares the texts in the two columns 2) relates each pair of texts because they both have the same x coordinate (with a maximum range of 1/2 the height of both texts) 3) creates a list for each columns sets with the texts in order from highest Y to lowest. Then modify your 'repeat' to iterate over the members of both lists: (nth ind lstColumn1) will always be in the same row as (nth ind lstColumn2) -
RANSONNEIL joined the community
-
Convert multy txt files - Update an old code
mhy3sx replied to mhy3sx's topic in AutoLISP, Visual LISP & DCL
I try your code. Ithink it works. I will test more. Thanks GLAVCVS -
Convert multy txt files - Update an old code
GLAVCVS replied to mhy3sx's topic in AutoLISP, Visual LISP & DCL
PS: Try it. I haven't done it. -
Convert multy txt files - Update an old code
GLAVCVS replied to mhy3sx's topic in AutoLISP, Visual LISP & DCL
The main function, modified, could be like this: (defun c:test (/ FF FFN TXT TXTS ab d lst rpta) (if (setq d (getfiled "Select file " "" "txt" 0)) (progn (while (not (member (setq rpta (strcase (getstring (strcat "\nConvert Only \'" (setq ab (vl-filename-base d)) ".txt\'? <Only>/All directory: ")))) '("" "O" "A"))) (princ "\n* Invalid option * Try again (ENTER, O or A) ...") ) (if (= rpta "A") (setq lst (vl-directory-files (vl-filename-directory d) "*.txt")) (setq lst (list (strcat ab ".txt"))) ) (foreach ffn lst (setq ff (open (setq ffn (strcat (vl-filename-directory d) "\\" ffn)) "r") txts nil ) (while (setq txt (read-line ff)) (setq txts (cons txt txts)) ) (close ff) (setq txts (mapcar '(lambda (x) (STD-STRSPLIT x "\t,; ")) (reverse txts))) (setq txts (mapcar '(lambda (x) (vl-remove-if '(lambda (y) (and (not (equal "0" y)) (zerop (atof y)))) x ) ) txts ) ) (setq ff (open (strcat (substr ffn 1 (- (strlen ffn) 3)) "pl") "w")) (foreach item txts (write-line (strcat (cadr item) "," (caddr item)) ff) ) (close ff) ) (startapp "explorer" (vl-filename-directory (strcat (vl-filename-directory d) "\\"))) ) ) (princ) ) -
The result of the difference of two columns with numbers
Nikon posted a topic in AutoLISP, Visual LISP & DCL
I need to select two columns with numbers and get the result (difference) in the third column. This code sometimes misidentified the difference, I can't figure out what the reason is. (defun c:Df2Column ( / col1 col2 n1 n2 p1 p2 p3 basept dy txt1 txt2 i ent1 ent2) (princ "\nSelect the texts of the first column: ") (setq col1 (ssget '((0 . "TEXT,MTEXT")))) (if (not col1) (progn (princ "\nThe objects of the first column are not selected.") (exit)) ) (princ "\nSelect the texts of the second column: ") (setq col2 (ssget '((0 . "TEXT,MTEXT")))) (if (not col2) (progn (princ "\nThe objects of the second column are not selected.") (exit)) ) (if (/= (sslength col1) (sslength col2)) (progn (princ "\nThe number of objects in the columns does not match.") (exit)) ) (princ "\nSpecify the insertion point of the third column: ") (setq basept (getpoint)) ;; Defining the step by Y between the elements of the second column (setq ent2a (ssname col2 0)) (setq ent2b (ssname col2 1)) (setq y1 (cadr (cdr (assoc 10 (entget ent2a))))) (setq y2 (cadr (cdr (assoc 10 (entget ent2b))))) (setq dy (- y2 y1)) (setq i 0) (repeat (sslength col1) (setq ent1 (ssname col1 i)) (setq ent2 (ssname col2 i)) (setq txt1 (cdr (assoc 1 (entget ent1)))) (setq txt2 (cdr (assoc 1 (entget ent2)))) (setq n1 (atof txt1)) (setq n2 (atof txt2)) (if (and n1 n2) (progn (setq p3 (list (car basept) (+ (cadr basept) (* i dy)) 0.0)) (entmakex (list (cons 0 "TEXT") (cons 8 (cdr (assoc 8 (entget ent2)))) (cons 10 p3) (cons 40 (cdr (assoc 40 (entget ent2)))) (cons 1 (if (> (- n1 n2) 0) (strcat "+" (rtos (- n1 n2) 2 3)) (rtos (- n1 n2) 2 3))) )) ) ) (setq i (1+ i)) ) (princ) ) difference.dwg -
Convert multy txt files - Update an old code
GLAVCVS replied to mhy3sx's topic in AutoLISP, Visual LISP & DCL
Hi You simply need to get the list of files in that directory with 'vl-directory-files' and create a loop so the code repeats for each file. -
Hi. I use this lisp code to convert the form of a txt file from this 0 299153.24 4218596.34 1 299163.21 4218607.51 2 299163.99 4218607.02 3 299176.94 4218599.90 4 299207.37 4218583.27 5 299220.70 4218575.98 6 299242.94 4218563.71 7 299253.41 4218557.75 8 299256.14 4218556.19 9 299253.94 4218553.77 10 299251.66 4218551.25 11 299248.52 4218547.79 12 299244.81 4218549.59 13 299235.68 4218554.00 14 299218.39 4218562.90 15 299197.46 4218573.57 16 299177.72 4218583.74 17 299164.10 4218590.73 18 299153.87 4218596.07 19 299153.24 4218596.34 to 299153.24,4218596.34 299163.21,4218607.51 299163.99,4218607.02 299176.94,4218599.90 299207.37,4218583.27 299220.70,4218575.98 299242.94,4218563.71 299253.41,4218557.75 299256.14,4218556.19 299253.94,4218553.77 299251.66,4218551.25 299248.52,4218547.79 299244.81,4218549.59 299235.68,4218554.00 299218.39,4218562.90 299197.46,4218573.57 299177.72,4218583.74 299164.10,4218590.73 299153.87,4218596.07 299153.24,4218596.34 The code works fine but convert only one file a time. Is it possible to update the code to convert all *.txt files in the folder to *.pl at once . The code I use is (defun c:test (/ FF FFN TXT TXTS) (setq ffn (getfiled "Select file " "" "txt" 0) ff (open ffn "r") txts nil ) (while (setq txt (read-line ff)) (setq txts (cons txt txts))) (close ff) (setq txts (mapcar '(lambda (x) (STD-STRSPLIT x "\t,; ")) (reverse txts))) (setq txts (mapcar '(lambda (x) (vl-remove-if '(lambda (y) (and (not (equal "0" y)) (zerop (atof y)))) x)) txts ) ) (setq ff (open (strcat (substr ffn 1 (- (strlen ffn) 3)) "pl") "w")) (foreach item txts (write-line (strcat (cadr item) "," (caddr item)) ff)) (close ff) (princ) ) ;;; The order of chars in delim is not important. ;;; keeping null tokens, not as with std-strtok. ;;; Might be renamed to std-string-split ;;; by Vladimir Nesterowsky (defun STD-STRSPLIT (s delims / len s1 i c lst) (setq delims (vl-string->list delims) ; fixed len (strlen s) s1 "" i (1+ len) ) (while (> (setq i (1- i)) 0) (setq c (substr s i 1)) (if (member (ascii c) delims) (if (/= i len) ; "1,2," -> ("1" "2") and not ("1" "2" "") (setq lst (cons s1 lst) s1 "" ) ) (setq s1 (strcat c s1)) ) ) (cons s1 lst) ; ",1,2" -> ("" "1" "2") ) I upload some txt files to test the code Thanks 1.txt 2.txt 3.txt
-
hoangvinhthien joined the community
-
mhy3sx changed their profile photo
-
You can read and write direct to Excel. Not sure as to what info you want, it may be simply achieved or very time consuming. You need to look at one task at a time and what are the rules for that task, a recent one is get info 2 blocks, that have same attribute value and say connecting length. Can you post a dwg with individual tasks and expected results in a Excel.
-
Auto lisp for AutoCAD LT 2026 - to convert numerical values in text or Mtext in MM to Meters
BIGAL replied to xpapillon's topic in AutoLISP, Visual LISP & DCL
As it’s @lee-mack code he may want to comment. -
Extracting data to excel from selected objects on different layers
BIGAL replied to Hsanon's topic in AutoLISP, Visual LISP & DCL
Yes is answer but you need to add object type into the cond which at moment only looks at line and pline. You need more defund dohatch., doblock. in some other code I make a big list of all objects and values, then look at how many items in each value of the list find maximum and that is used for number of columns. Yes do have something for blocks, any blocks and a table is made, data is sorted and common items counted. Small fee is applicable, would need more code for hatches, lines & plines. -
Can you post me a sample of the bevels use wblock. I tested on random lines and it worked, all 4 quadrants. That is all that is needed some lines.
-
Aotomatic cogo point import from csv file
BIGAL replied to benlconstructors's topic in AutoLISP, Visual LISP & DCL
Re open civ3D database you can use a check of current version and it corresponds to say a Acad year the number for a particular year may be 24. But as it’s LT doubtful that you can access database anyway, the code though should work in LT as it uses a cond to compare version number with a Civ3D version number, they are different. On iPad else would post code. Import points, string via code and create surface, re YMG triangulation lisp. Desired task. Importing points is easy but needs a lookup library, string points under development should work in LT2024+. If someone wants to have a go with LT try the code @SLW210 and I posted. Please let me know how it goes.- 13 replies
-
- lisp
- cogo points
-
(and 2 more)
Tagged with:
-
Doing bundles is pretty straight forward when you have an example to look at, that is for Autocad, Bricscad is different. Hence next method. Whilst not an exe I got around it by using a install.lsp, it looks for a zip file with all your stuff in it, Yes lisp can be used to unzip to a nominated directory, part 2 is that the lisp loads custom menu,s sets support paths. So ready to go, for multiple users email the zip and lisp, save the zip somewhere and run the lisp. Happy to provide more info.
- Yesterday
-
Danielm103 started following install lisps, DCLs, Cuix
-
I like INNO, the only issue is that it generates a .EXE file You will want to create a .bundle package and have INNO put the package in %APPDATA%\Autodesk\ApplicationPlugins\\myapp.bundle https://help.autodesk.com/view/OARX/2025/ENU/?guid=GUID-5E50A846-C80B-4FFD-8DD3-C20B22098008 PackageContents.xml would have an entry for your cui as well https://help.autodesk.com/view/OARX/2025/ENU/?guid=GUID-40F5E92C-37D8-4D54-9497-CD9F0659F9BB
-
Aotomatic cogo point import from csv file
SLW210 replied to benlconstructors's topic in AutoLISP, Visual LISP & DCL
If time allows next week, I'll continue with exploring Map 3D, I haven't used it in a couple of years now. I might redo my LISP to add them to a specific layer (or create it), but I had hard coded it, I want to ask for the name next time. I did have it drawing a pline, but it was on all points ( in order), I only needed a pline between certain points (they all had the same identifier description). Main purpose was to place the points as 2D with just the text for Z and add in information as text as well (maybe add the option for 3D points and text locations). Does COGO create 3D? I cannot recall and didn't even think to try Map 3D for this job. The engineer heading this up has 2025 LT, was hoping to have it so he could update the drawing, but alas, the LISP doesn't work in LT. Maybe the option for PNEZD or PENZD?- 13 replies
-
- lisp
- cogo points
-
(and 2 more)
Tagged with:
-
Aotomatic cogo point import from csv file
troggarf replied to benlconstructors's topic in AutoLISP, Visual LISP & DCL
Maybe so, but as a fly on the wall, I have been enjoying learning from you two as you share knowledge and experience- 13 replies
-
- lisp
- cogo points
-
(and 2 more)
Tagged with:
-
Custom Application Setup Solved: How to load a .lsp file using C#? - Autodesk Community
-
MALIKFAIZAN joined the community
-
hello guys does anybody know how can i install my Lisps ,DCL, Cuix files by .EXE file ? is inno setup about it? does anything already exist?
-
hwagun0610 joined the community
-
Silver joined the community
-
Aotomatic cogo point import from csv file
SLW210 replied to benlconstructors's topic in AutoLISP, Visual LISP & DCL
Nice @BIGAL On further review for the OP, doesn't Civil 3D already have the ability to import CSV with the data to COGO point. Maybe you need to explain a little more what you are looking to accomplish. It seems the OP has gone AWOL.- 13 replies
-
- lisp
- cogo points
-
(and 2 more)
Tagged with:
-
I am working on electral planing for building equipment and calculation, so I make data extractions of dwg files very often. For this reason I´ve made a block database with over 500 blocks that have informations like romm-number, distribution, power consumption, and so on. I do the following calculations of drawn plans with the data export in CAD or for example trimble nova (electrical). I know how to manage the export files in excel from CAD-Programs or Trimble Nova. In CAD every block has a unique number and same attributes, which is nice to filter and sum them up for different zones in the plan or in general. Sometimes excel feels a bit to clunky and its complicate to filter out distances (from distrubutor to power cunsuming parts) and if the export does not follow my system like in Nova I cannot use predefined excel sheets for it and have to make them individually every time. Do you know a tool thats makes the management of the output visually more intuitive and with possibility for setting up programs such as finding blocks with same distributors and calculate x/y distances, for cable lengths, to sum them up. Autodesk Revit for example has good opportunitys to sum up informations within rvt-files and use informations that are in the underlaying ifc-buildings, combine the informations and calculate with them. I can combine this informations in excel by hand very nice too, I just wanted to ask if you know alternatives or know good programs for this. Best case would be excel import and export, direct dwg input and a intuitive workspace to write in little programs to combine and calculate with the data.
-
Hey Big Al, I tried creating that layer and also try changing it and neither one worked. I get the same error message.
-
Switch/Activate to an Open Drawing - Part of a Larger Routine
ILoveMadoka replied to ILoveMadoka's topic in AutoLISP, Visual LISP & DCL
It's the simple things... Solution: (Command "Pasteclip" "0,0") Sheesh!! I will mess with the other code to see what they do.. Thank you all so very much!!