All Activity
- Today
-
I didn't know you could do that! Still need to add the tabs \t to the base list, but you'd get a better result I think
-
Lee Mac started following Gap Dcl in Block list
-
Use the DCL tabs attribute and prefix the list items with a tab character ("\t").
-
I tried that also it doesn't give any difference @Steven P
-
Looking at this one, if I substitute "DWG to PDF.PC3" instead of your Foxit plotter, your PDF1 code will recognise the plotter, so might be an error in the name or if it is saved in the correct location. Does it do anything if you use one of the default CAD PDF writers rather than 3rd party PDF?
-
Steven P started following Gap Dcl in Block list
-
One way, might be the easiest is to change the list that populates 'Block List', adding spaces to the nested block So you might have a line like this in your LISP: (start_list "lst" 3)(mapcar 'add_list BlockList)(end_list) Where BlockList is your list of block, might be (setq BlockList (list "BLOCK-1" "BLK-1" "BLK-2"... "BLOCK-2")) Which you could change to be (setq BlockList (list "BLOCK-1" " BLK-1" " BLK-2"... "BLOCK-2")) I don't think you can do the indenting with DCL, has to be done before then.
-
sachindkini started following Gap Dcl in Block list
-
Hi Sir, how to gap betwwen main block and nested block in dcl ;----------------------------------------------- (cond ((null (setq lst (vl-sort lst '<))) (princ "\nNo blocks found in drawing.") ) ((null (and (setq tmp (vl-filename-mktemp nil nil ".dcl")) (setq des (open tmp "w")) (foreach line (list (strcat "blockpreview : dialog { label = \"" datetitle "\";") ;; Title with date-time " spacer;" " : row {" " : boxed_column { label = \"Block List\"; width = 35; fixed_width = true;" " : list_box { key = \"lst\"; height = 15; fixed_height = true; }" " }" " spacer;" " : boxed_column { label = \"Preview\"; width = 35; fixed_width = true;" " : image { key = \"img\"; height = 15; fixed_height = true; }" " }" " }" " spacer;" " : image { color = 30; width = 50; height = 0.5; alignment = centered; }" ;; Orange line " spacer;" " : boxed_column { label = \"Block Tools\";" ;; Single box around ALL buttons " : row {" " : button { key = \"cbp_btn\"; label = \"Change Base Point\"; }" " : button { key = \"cbpr_btn\"; label = \"Change Base Point (Ref)\"; }" " }" " spacer;" " : row {" " : button { key = \"rename_btn\"; label = \"Rename\"; is_default = true; }" " : button { key = \"select_btn\"; label = \"Select Block\"; }" " : button { key = \"cancel\"; label = \"Cancel\"; is_cancel = true; }" " : button { key = \"about\"; label = \"About\"; }" " }" " }" " spacer;" " : text { label = \"Author: XYZ | https://abcd.com/\"; alignment = centered; }" "}" ) (write-line line des) ) (not (setq des (close des))) (< 0 (setq dcl (load_dialog tmp))) (new_dialog "blockpreview" dcl) ) ) (princ "\nUnable to load dialog.") ) ;------------------------------------------------
-
Tapered Offset/Stretch closed polyline shape
pkenewell replied to SLW210's topic in AutoLISP, Visual LISP & DCL
I've played with ElpanoxEvgeniy's original code and made a working version. It;s fine on straight segments but can be a little unpredictable on curved segments @GLAVCVS code is a bit more stable on curved segments. -
Tapered Offset/Stretch closed polyline shape
dexus replied to SLW210's topic in AutoLISP, Visual LISP & DCL
Has anyone tried the code, got it working and find it useful? -
Forward Visibility Lisp - DXF issue
SLW210 replied to CivilTechSource's topic in AutoLISP, Visual LISP & DCL
Nice video. The OP could use civil site design, is it better than the one in Civil 3D? Autodesk Civil 3D Help | To Calculate Sight Distance Along a Corridor | Autodesk Help | To analyze sight distance | Autodesk for InfraWorks. I know about about forward visibility, the question was... I would surmise there are objects to select as a reference. The LISP has "Select Polyline" but shows... (cons 0 "*POLYLINE,ARC,SPLINE") Also would like to know why the OP thought the original was not drawing the lines correct. I am back at my work computer, so I might do a little more checking, though without a real drawing from the OP, I will be guessing or have to take extra time to make something. Maybe this LISP works better... Lisp routine to show visibilty splays Or... Maximum Stopping Sight Distance Lisp - AutoLISP, Visual LISP & DCL - AutoCAD Forums -
when i try to run it on a multileader it says: ActiveX Server returned an error: Parameter not optional
-
Forward Visibility Lisp - DXF issue
BIGAL replied to CivilTechSource's topic in AutoLISP, Visual LISP & DCL
If I understand correctly the idea is to check a drivers visibility by producing a set of plines and then you can visibly check does it touch something. have a look at this -
How to deploy list of Lisps to everyone in the organisation - AutoCAD LT
BIGAL replied to CivilTechSource's topic in AutoLISP, Visual LISP & DCL
I have used just a lisp name not a path in the autoload. All our customisation was in one directory on a server, it did though have sub directory's lisp blocks icons etc. Yes if you have Acad need to add trusted paths. (if (> (vl-string-search "BRICSCAD" (strcase (getvar 'product))) 0) (princ "Bricscad not found") (progn (setq oldtrust (getvar 'trustedpaths)) (if (wcmatch oldtrust "*XXX*") (princ) (setvar 'trustedpaths (strcat oldtrust ";" "c:\\XXX-CAD-TOOLS")) ) ) ) (command "workspace" "save" "" "y") ; a good idea is have a new workspace say user name (alert "\nSupport and trusted paths added") - Yesterday
-
Forward Visibility Lisp - DXF issue
SLW210 replied to CivilTechSource's topic in AutoLISP, Visual LISP & DCL
I use this for layer 0 at the end of a LISP. (command "_.LAYER" "_Set" "0" "") Error: Bad DXF group: (10) means that the application has attempted to create an entity with wrong vertices (a polyline with a single vertex, identical endpoints for a line, etc.). https://www.cadforum.cz/en/error-bad-dxf-group-10-tip9081 I think you could be passing 2D points when a 3D points are expected, but I won't be able to take a better look until Monday sometime. Most likely in the... ;----- Function to create Forward Visibility Polylines P.S. Just for the record, what exactly is this LISP supposed to do? Can you post an example drawing? P.S.S. Do you have a link or a copy of the original LISP? -
How to deploy list of Lisps to everyone in the organisation - AutoCAD LT
Steven P replied to CivilTechSource's topic in AutoLISP, Visual LISP & DCL
I've never used that BigAl, do the LISP files need to be in trusted locations or is there a setting to specify your own folders maybe a network drive or similar? -
Hamood joined the community
-
karl.sch joined the community
-
KD-Trees are amazingly powerful, and most always overlooked because of their complexity to create and use. I’m always guilty of using brute-force tactics before forcing myself into using a better algorithm. Hopefully Point2dTree and Point3dTree will remove most of the complexities, make them more accessible The particular tree (nanoflann) is more geared towards point clouds, very fast. Should do 10^7 points in the blink of an eye
- Last week
-
Forward Visibility Lisp - DXF issue
BIGAL replied to CivilTechSource's topic in AutoLISP, Visual LISP & DCL
Ignoring the code for the moment, "Civil Site Design" has check site lines and it checks against the terrain model and the vertical alignment, not just a 2D answer. Looks at the drivers eye height and target height which is part of the check for us here in AUS. -
Very interesting, did something similar, I made a "where are they" map, it had a grid over the office floor so had a big staff list Bigal lev 5, A 1. I used the phone number as a link to an image of each staff member, so their picture appeared on their desk I simply saved each staff image as the extension number. It was reasonably fast making the new dwg inserting around 100 photo's per floor we worked in a 5 story building.
-
How to deploy list of Lisps to everyone in the organisation - AutoCAD LT
BIGAL replied to CivilTechSource's topic in AutoLISP, Visual LISP & DCL
In lisp there is a function AUTOLOAD that does just that loads a lisp based on a command typed on the command line. So you just need a single lisp that has all the autoload commands in it. That custom lisp is loaded on startup in my case its Appload and add to Startup suite. I called my lisp "Autoload.lsp" Here is sample code. You may need to add the start defun name (c:Yourlisp) as last line in the lisp that is loaded, as the load command can be anything and not necessarily the command to run it. eg ZZZ (autoload "COPY0" '("COPY0")) (autoload "COPYCOMMAND" '("ZZZ")) (autoload "COVER" '("COVER")) (autoload "DIMFLIP" '("DIMFLIP")) (autoload "DRAWXFALL" '("DRAWXFALL")) (autoload "DRAWPIPE" '("DRAWPIPE")) (autoload "EDITRL" '("EDITRL")) -
Forward Visibility Lisp - DXF issue
GLAVCVS replied to CivilTechSource's topic in AutoLISP, Visual LISP & DCL
Hi Like @Stevenp, I can't verify exactly what this is about either: I'm not in front of a PC. But it looks like the last SPoint is 'nil' because '(+ Counter ForwardVisDistance)' is a number greater than the length of 'selPline'. There are a few lines of code that are unnecessary, but they don't prevent your routine from working, so just try changing (while (< Counter SelPline_Length) to (while (and (setq EPoint (vlax-curve-getPointAtDist SelPline (+ Counter ForwardVisDistance))) (setq SPoint (vlax-curve-getPointAtDist SelPline Counter))) It looks like you used AI to do this, but you should still be able to remove the excess code after making these changes. -
Steven P started following Forward Visibility Lisp - DXF issue
-
Forward Visibility Lisp - DXF issue
Steven P replied to CivilTechSource's topic in AutoLISP, Visual LISP & DCL
Sounds like on the last run through the while loop SPoint is having an error... if you look at (setq SPoint (vlax-curve-getPointAtDist SelPline (+ Counter inc))) - do you need this line since at the start of the next loop you are setting SPoint again and before it is used. -
How to deploy list of Lisps to everyone in the organisation - AutoCAD LT
Steven P replied to CivilTechSource's topic in AutoLISP, Visual LISP & DCL
After your question I resurrected half a script, this one below will search through each .lsp file in folders (folder names are coded in the LISP just for now.. up date as you want), and will create a .lsp file (saved in temporary files folder), opening it to allow you to save it where convenient. The .lsp file created loads on demand .lsp files as and when they are called. If you run this to create a file, that file is all the users need to load when pressing the CUI button - can be quicker loading on demand if you have a lot of / big LISPs that are not all used all the time. If this file is saved in a central location - all users access it - all you need to do is update this 1 file. Some failings: It is searching for (Defun 123 ( abc / def) at the start of each line. - If the defun is indented it will skip past it (so as to avoid sub functions which are usually indented) - If the variable definition (abc / def) is on another line it will cause errors - If the variable definition is 'nil' (some LISPs do that), then it will also cause errors - '123' can be for example c:ALisp or MyLisp, doesn't need the 'c' prompt so it picks up utility LISPs common to many LISPs - File it creates is 0_OpenOnDemand, the '0' is so it loads first, any function that this file creates that is in another file, loaded after, then the file loaded 2nd takes precedence. Folder paths are entered here twice, once with just a double '\\' and one with a double-double '\\\\' - a fix for later but lazy programming to make it work on a Friday afternoon ... needs a little more work to make it a lot more user friendly of course! (defun c:listlisps ( / LispFolder MyLisps MyLispFiles LispList acount fo fn ML n) ;;NOTES: ;;Will fail if the defun lines are not 'ideal': "(Defun abc ( / )" format ;;will fail if variable (global / local) not defined eg defun 'c:abc nil' - wants 'c:abc ( / )' ;;Will fail if subfunctions are not indented ;;Will fail if main functions are indented (won't be found) ;;Filepath is hardcoded ;;Variables (setq MyLisps (list)) (setq OOD_File "0_OpenOnDemand.lsp") ; open on demand file name (setq fo (open (setq fn (strcat (getvar "TEMPPREFIX") OOD_File)) "w")) ; create empty OOD_File (close fo) ;;LISP Folders (setq LispFolderList (list "C:\\\\AutoCAD\\\\AutoCAD LISPS" ;;Folder 1 "C:\\\\AutoCAD\\\\AutoCAD LISPS\\\\Block LISPs" ;; folder 2... can add more )) (setq MyFolderList (list "C:\\AutoCAD\\AutoCAD LISPS" ;;Folder 1 "C:\\AutoCAD LISPS\\Block LISPs" ;; Folder 2... can add more )) ;;while loop from here (setq acount 0) (while (< acount (length MyFolderList)) (setq LispFolder (nth acount LispFolderList)) (setq MyFolder (nth acount MyFolderList)) (setq MyLispFiles (vl-directory-files MyFolder "*.lsp" 1)) (vl-remove OOD_File MyLispFiles) (setq MyLisps (listlisps MyFolder MyLispFiles)) (setq fo (open (setq fn (strcat (getvar "TEMPPREFIX") OOD_File)) "a")) (foreach ML MyLisps (if (or (member OOD_File ML) ; ignore this file (member "SIMPLELISP.lsp" ML) ; ignore this file ) ; Endor (progn ) (progn (foreach n (car (cdr ML)) (if (wcmatch n "*(*") ;;Change so that zxy(abc / ) -> zxy ( abc / ) - spaces (write-line (vl-string-subst " " " " (strcat "(Defun " n " / )")) fo) ;; if there is a ( (write-line (vl-string-subst " " " " (strcat "(Defun " n " ( / )")) fo) ;; if there isn't a (. Note might not catch function fully ) ; end if (write-line (vl-string-subst ")" " )" (strcat " (Load \"" LispFolder "\\\\" (car ML) "\") (" (vl-string-subst " " " " (vl-string-subst " " "(" n)) ")(princ)")) fo) (write-line (strcat ")") fo) ) ; end foreach ) ; end progn ) ; end if ) ; end foreach (close fo) (setq acount (+ acount 1)) ) ; end while (startapp "notepad" fn) (alert (strcat "Just check this:" "\nCheck list file to make sure Defun format is followed" "\n <cr>(Defun fnc ( abc / xyz).... with variable definitions" ) ) (princ) ) (defun listlisps ( MyFolder MyLispFiles / MyLisps f) (defun LM:GetSyntax ( file / _GetSyntax line syntax ) ;;modify to make dotted pair list, (path\\filename . LISP) (defun _GetSyntax ( p s / x ) (if (setq x (vl-string-search p s)) (cons (substr (setq s (substr s (+ x 1 (strlen p)))) 1 (setq x (car (vl-sort (vl-remove 'nil (mapcar (function (lambda ( d ) (vl-string-position d s))) ;; '(32 9 40 41) ) ) '< ) ) ; end setq '(9 47 41) ) ) '< ) ) ; end setq ; numbers are character codes ) ) ; end cons, Substr (if x (_GetSyntax p (substr s (1+ x)))) ) ) ; end if ) ; end defun (if (setq file (open file "r")) (apply 'append (progn (while (setq line (read-line file)) (if (or (= (substr line 1 1) ";") (= line nil) ) ; remove commented out lines & blank lines () (progn ;;remove ignored items ;; (if (wcmatch (Strcase line) "(DEFUN C:*") ;if line contains (defun c: (if (wcmatch (Strcase line) "(DEFUN *") ;if line starts with (Defun (progn (setq splittext (LM:str->lst line ";")) ; ignore anything after ';' (setq line (nth 0 splittext)) (setq splittext (LM:str->lst line (chr 34))) ; ignore strings '"' (setq line "") (setq count 0) (while ( < count (length splittext)) (setq line (strcat line (nth count splittext))) (setq count (+ count 2)) ) ; end while ;; (setq syntax (cons (_GetSyntax "(DEFUN C:" (strcase line)) syntax)) ;; No 'C:' (setq syntax (cons (_GetSyntax "(DEFUN " (strcase line)) syntax)) ;; Keep the 'C:' ) ; end progn ) ; end if ) ) ) (setq file (close file)) (reverse syntax) ) ) ) ) ; end defun LM:Getsyntax ;; (setq MyLispFiles (vl-directory-files MyFolder "*.lsp" 1)) (princ (strcat (rtos (length MyLispFiles) 2 0) " *.LSP Files. ")) (setq MyLisps (list)) ; blank list (foreach f MyLispFiles (setq MyLisps (append MyLisps (list (cons f (list (LM:GetSyntax (strcat MyFolder "\\" f))))))) ) ; end foreach (princ (strcat (rtos (length MyLisps) 2 0) " LISP Routines. ")) MyLisps ; return the list ) -
Hi I found this Forward Visibility Lips online but it was drawing the forward vis line slightly wrong so I have modified it now. It works okay, but when I was debugging it at the end of the routine it would through an error message (See image). The lisp however does complete everything as required apart from setting Layer 0 at the end. I am looking to address that error. (vl-load-com) (defun C:CTS-ForwardVis () ;Set the Layer for the New Polylines (if (not (tblsearch "LAYER" "CTS-Forward Visibility")) (command "-LAYER" "_M" "CTS-Forward Visibility" "_C" "True" "255,100,0" "CTS-Forward Visibility" "" "")) (command "clayer" "" "CTS-Forward Visibility" "") ; Predefined variables (setq ForwardVisDistance 15.0) ; Default forward visibility distance (setq inc 2.0) ; Default increment/resolution ; Prompt user to accept/change defaults (initget "Yes No") (if (= (getkword (strcat "\nUse default settings? [Yes/No] <Yes>: ")) "No") (progn (setq ForwardVisDistance (getdist (strcat "\nEnter default visibility distance <" (rtos ForwardVisDistance 2 2) ">: "))) (setq inc (getdist (strcat "\nEnter default increment/resolution <" (rtos inc 2 2) ">: "))) ) ) (princ (strcat"\nSelect Polyline:")) (while (not (setq js (ssget "_+.:E:S" (list (cons 0 "*POLYLINE,ARC,SPLINE") (cons 67 (if (eq (getvar "CVPORT") 2) 0 1)) (cons 410 (if (eq (getvar "CVPORT") 2) "Model" (getvar "CTAB"))) (cons -4 "<NOT") (cons -4 "&") (cons 70 112) (cons -4 "NOT>") ) ) ) ) ) ;----- Assign the Selected Polyline to a VLA-Object and get its Length and other properties (setq SelPline (vlax-ename->vla-object (ssname js 0)) SelPline_Length (vlax-curve-getDistAtParam SelPline (vlax-curve-getEndParam SelPline)) Counter 0.0 SPoint nil EPoint nil ) ;----- Check Forward Visi Distance and Increment against the Length of the Selected Polyline (while (>= ForwardVisDistance SelPline_Length) (if (>= ForwardVisDistance SelPline_Length) (princ "\nDistance execeded length of Selected Polyline")) ) (while (>= inc SelPline_Length) (if (>= inc SelPline_Length) (princ "\nDistance execeded length of Selected Polyline")) ) ;----- Function to create Forward Visibility Polylines (while (< Counter SelPline_Length) (setq EPoint (vlax-curve-getPointAtDist SelPline (+ Counter ForwardVisDistance))) (setq SPoint (vlax-curve-getPointAtDist SelPline Counter)) (entmake (append '( (0 . "LWPOLYLINE") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "CTS-Forward Visibility") (62 . 256) (6 . "ByLayer") (370 . -2) (100 . "AcDbPolyline") (90 . 2) ) (list (cons 10 SPoint)) (list (cons 10 EPoint)) '((210 0.0 0.0 1.0)) ) ) (setq SPoint (vlax-curve-getPointAtDist SelPline (+ Counter inc))) (setq Counter (+ Counter inc)) ) (command "clayer" "" "0" "") ) Thank you!!
-
How to deploy list of Lisps to everyone in the organisation - AutoCAD LT
CivilTechSource replied to CivilTechSource's topic in AutoLISP, Visual LISP & DCL
Thank you everyone so much! I decided to go with two options! One will be the CUI button will run a Load command to load the lisp and the call the command. This way only lisp that are required are loaded. However, the reason I was exploring option to load automatically is because some users like to type commands rather than click on Buttons. So I will add one button to the CUI that will run LOAD ALL lisp as per @BIGAL post. This way both users who click or type can have a smooth experience. -
Just quick checking BigAl, I think I use the file extension, .pc3, in my PDF routines, though you might be right and mine works by luck (these were the first LISPs I wrote, so lot of what they do are luck!). For OP, you might need to go through it step by step to see where it isn't working, see what is reported in command line from (PC3Exists pc3name)
-
Danielm103 started following KD-Tree in Python for AutoCAD
-
I incorporated nanoflann( https://github.com/jlblancoc/nanoflann) wrappers into PyRx. Although other efficient KD-Tree implementations exist in Python, such as pykdtree, the wrapper is specifically designed for AcGePoint2d/AcGePoint3d, eliminating the need for type conversions. How can these structures be beneficial in CAD? in this example, we search for a phone within a certain radius of each computer. Additionally, we can identify computers that do not have phones. We could also do something like, search all MTexts on the Layer "Employee" to determine whether they are near a chair, phone, or computer. import traceback from pyrx import Ap, Ax, Db, Ed, Ge, Gi, command # radiusSearch @command def doit(): db = Db.curDb() phones, computers = getBlocks(db) result = [] # create the tree of phone locations phonePoints = Ge.Point3dArray() for phone in phones: phonePoints.append(phone[1]) phoneTree = Ge.Point3dTree(phonePoints) # search for nerby phones for computer in computers: idxs, _ = phoneTree.radiusSearch(computer[1], 50 * 50)# sqrd if len(idxs) == 0: print("no phone") continue for idx in idxs: result.append((computer, phones[idx])) for cpu, phn in result: Ed.Core.grDraw(cpu[1], phn[1], 2, 0) # helper, store the id and position def getBlocks(db: Db.Database): phones = [] computers = [] model = Db.BlockTableRecord(db.modelSpaceId()) refs = [Db.BlockReference(id) for id in model.objectIds(Db.BlockReference.desc())] for ref in refs: if ref.getBlockName() == "COMPUTER": computers.append((ref.objectId(), ref.position())) elif ref.getBlockName() == "FNPHONE": phones.append((ref.objectId(), ref.position())) return phones, computers