All Activity
- Today
-
Attributes be added to factor the outcome of Incremental numbers
BIGAL replied to u4ea2u2's topic in AutoLISP, Visual LISP & DCL
I used Battman and changed the attribute order that way my default sort and count worked. using Battman can move attribute order not actual position in block. Ok part 2 is to add a number to each block where attributes are the same that is a new step in my program, but have something. getting way more complicated. The auto number would be based on the "1st sort order attribute" so a 1000=1, 1100=2 and so on not based on position in dwg is that ok ? -
Jim Clayton started following Place Device Based on Room Tag
-
Hello. I’m fairly new to Revit so I’m probably going to butcher this question. Is it possible to place different devices throughout a floor plan, based solely on the Room Tag. For instance, if there was a schedule that contained all of the different room names, could I go through that line by line and for a classroom, insert device A, for a kitchen, insert device B. Then when I opened up the floor plan, all of those devices would be there and I would just have to fine tune their location. Hopefully that made sense.
-
Excel link - Sanity check please
Danielm103 replied to swanny89's topic in AutoLISP, Visual LISP & DCL
Yeah, that was LT-Extender https://www.lt-extender.com/LT-Extender/englisch/default.htm I can’t see how companies could buy a cad package that does not have a robust API. There’s a lot of competition in this space these days. - Yesterday
-
"Was an AutoCAD LT expert" there was lisp enabler and pretty sure Autodesk legal team shut them down. It was produced way back around 2005. It was called LT-Extender. Google can find some info about it.
-
Did you try changing 57.40259411 not sure bigger or smaller needed, not tested.
-
- 1 reply
-
- 1
-
-
Copy and paste error (blocks changes!)
rlx replied to X11start's topic in AutoLISP, Visual LISP & DCL
You can try if this works better. No dbx in this version Start app , make selection , select drawing you want to paste in later. This drawing is shortly opened (not sure if it works if drawing is already open) List with blocknames is created and drawing is closed. Blocknames are compared and if duplicates are found message is displayed. You can choose 1- Stop , 2 - Rename the blocks in drawing you made the selection set (not the other drawing), or 3 - copy / paste as it is. Only thing left to do is select your basepoint (or replace 'pause' with "0,0" in the code) and selection set is placed on clipboard , ready to paste. ;;; check before paste - rlx 2025-10-22 (defun c:cbp ( / this-dwg ss other-dwg blocknames-in-selectionset blocknames-in-other-dwg duplicate-blocknames dbx-doc) (setq this-dwg (vla-get-ActiveDocument (vlax-get-acad-object))) (if (and (setq ss (ssget)) (setq other-dwg (getfiled "Drawing to check before you paste" "" "dwg" 0))) (progn (if (vl-consp (setq blocknames-in-selectionset (Get_SS_BlockNames ss))) (setq blocknames-in-selectionset (mapcar 'strcase blocknames-in-selectionset))) (if (vl-consp (setq blocknames-in-other-dwg (Get_EX_Blocknames other-dwg))) (setq blocknames-in-other-dwg (mapcar 'strcase blocknames-in-other-dwg))) (setq duplicate-blocknames (compare_block_names blocknames-in-selectionset blocknames-in-other-dwg)) (if (vl-consp duplicate-blocknames) (progn (dplm duplicate-blocknames "Duplicated block names : ") (setq inp (cfl (list "1 - I'm not gonna paste" "2 - Rename blocks before pasting" "3 - I'm gonna paste anyway"))) (cond ((or (void inp) (wcmatch inp "1*")) (alert "Copybase aborted")) ((wcmatch inp "2*")(foreach b duplicate-blocknames (rename_block_definition b)) (princ "\nBlocks are renamed - select your basepoint now") (command "_copybase" pause ss "")) ((wcmatch inp "3*") (princ "\nBlock names unchanged - select your basepoint now")(command "_copybase" pause ss "")) (t (princ"\nBite me...")) ) ) (progn (princ "\nNo duplicate block names found - select your basepoint")(command "_copybase" pause ss "")) ) ) ) (princ) ) ;;; get block names active doc - vanilla (defun _bl ( / b l ) (while (setq b (tblnext "BLOCK" (null b))) (if (zerop (boole 1 21 (cdr (assoc 70 b)))) (setq l (cons (cdr (assoc 2 b)) l)))) l) (defun Get_EX_Blocknames (other-dwg / fn l) (if (and (eq (type other-dwg) 'STR)(setq fn (findfile other-dwg)) (setq doc (vla-open (vla-get-documents (vlax-get-acad-object)) fn))) (progn (setq l (GetDocBlockNames doc))(vla-close doc)(vlax-release-object doc))) l) ;;; test (setq lst (GetDocBlockNames (vla-get-ActiveDocument (vlax-get-acad-object)))) (defun GetDocBlockNames ( d / b n l) (vlax-for b (vla-get-blocks d) (if (and (= :vlax-false (vla-get-isxref b)) (= :vlax-false (vla-get-islayout b)) (not (vl-string-search "*" (setq n (vla-get-name b)))))(setq l (cons n l)))) l) (defun create_unique_blockname ( $bn / i bn) (setq i 0)(while (tblsearch "block" (setq bn (strcat $bn "_" (itoa (setq i (1+ i))))))) bn) (defun rename_block_definition ( $bn / bc bn ) (setq bc (vla-get-blocks (vla-get-ActiveDocument (vlax-get-acad-object)))) (if (and (not (void $bn)) (tblsearch "block" $bn)) (vla-put-name (Collection-Member $bn bc)(setq bn (create_unique_blockname $bn)))) bn) (defun compare_block_names (a b / c) (and (vl-consp a) (vl-consp b) (foreach item a (if (member item b) (setq c (cons item c))))) c) (defun Get_SS_BlockNames ( ss / n l) (foreach o (ss->ol ss)(if (and (setq n (block-n o))(not (member n l)))(setq l (cons n l)))) l) (defun SS->OL (ss / i l)(setq i 0)(repeat (sslength ss)(setq l (cons (vlax-ename->vla-object (ssname ss i)) l) i (1+ i))) l) (defun void (x) (or (eq x nil)(and (listp x)(not (vl-consp x)))(and (eq 'STR (type x))(eq "" (vl-string-trim " \t\r\n" x))))) (defun block-n (o)(if (and (= 'vla-object (type O))(eq (vla-get-objectname O) "AcDbBlockReference")) (if (vlax-property-available-p o 'EffectiveName) (vla-Get-EffectiveName o) (vla-Get-Name o)) nil)) (defun Collection-Member (m c / r) (if (vl-catch-all-error-p (setq r (vl-catch-all-apply 'vla-item (list c m)))) nil r)) ;;; display list (plus message) (defun dplm (l m / f p d w) (and (vl-consp l) (setq l (mapcar 'vl-princ-to-string l)) (setq w (+ 5 (apply 'max (mapcar 'strlen l)))) (setq p (open (setq f (vl-filename-mktemp ".dcl")) "w")) (princ (strcat "cfl:dialog{label=\"" m "\";:list_box {key=\"lb\";" "width="(itoa w)";}ok_only;}") p)(not (setq p (close p)))(< 0 (setq d (load_dialog f)))(new_dialog "cfl" d)(progn (start_list "lb") (mapcar 'add_list l)(end_list)(action_tile "accept" "(done_dialog)")(start_dialog)(unload_dialog d)(vl-file-delete f)))) ;; choose from list (cfl '("1""2""3")) (defun cfl (l / f p d r) (and (setq p (open (setq f (vl-filename-mktemp ".dcl")) "w")) (princ "cfl:dialog{label=\"Choose\";:list_box{key=\"lb\";width=40;}ok_cancel;}" p) (not (setq p (close p)))(< 0 (setq d (load_dialog f)))(new_dialog "cfl" d) (progn (start_list "lb")(mapcar 'add_list l)(end_list)(action_tile "lb" "(setq r (nth (atoi $value) l))(done_dialog 1)") (action_tile "accept" "(setq r (get_tile \"lb\"))(done_dialog 1)")(action_tile "cancel" "(setq r nil)(done_dialog 0)") (start_dialog)(unload_dialog d)(vl-file-delete f))) (cond ((= r "") nil)(r r)(t nil))) edit : just had an idea , why not open the 'to be pasted' drawing after you made your selection. Also tried if it was a bad thing if both drawings were already open and yes , that's bad... but then I'm a bad bad dragon (it still opens but as read only) Because I use vla-activate at the end , all lisp stops (obviously) Once drawings is activated you can copypaste / ctrl-V yourself (I'm sure as hell not comming to do that for you ) You decide what make you happy... ;;; check before paste 2 : after selection open the 'to be pasted' drawing - rlx 2025-10-22 (defun c:cbp2 ( / acDoc *docs* ss dbDoc blocknames-in-selectionset blocknames-in-dbDoc duplicate-blocknames inp do-it) (setq acDoc (vla-get-ActiveDocument (vlax-get-acad-object)) *docs* (vla-get-documents (vlax-get-acad-object))) (if (and (setq ss (ssget)) (setq dbDoc (getfiled "Drawing to check before you paste" "" "dwg" 0))) (progn (if (vl-consp (setq blocknames-in-selectionset (Get_SS_BlockNames ss))) (setq blocknames-in-selectionset (mapcar 'strcase blocknames-in-selectionset))) (if (vl-consp (setq blocknames-in-dbDoc (Get_EX_Blocknames dbDoc))) (setq blocknames-in-dbDoc (mapcar 'strcase blocknames-in-dbDoc))) (setq duplicate-blocknames (compare_block_names blocknames-in-selectionset blocknames-in-dbDoc)) (if (vl-consp duplicate-blocknames) (progn (dplm duplicate-blocknames "Duplicated block names : ") (setq inp (cfl (list "1 - I'm not gonna paste" "2 - Rename blocks before pasting" "3 - I'm gonna paste anyway"))) (cond ((or (void inp) (wcmatch inp "1*")) (alert "Copybase aborted")) ((wcmatch inp "2*")(foreach b duplicate-blocknames (rename_block_definition b)) (princ "\nBlocks are renamed - select your basepoint now") ;|(command "_copybase" pause ss "")|; (setq do-it t)) ((wcmatch inp "3*") (princ "\nBlock names unchanged - select your basepoint now") ;|(command "_copybase" pause ss "")|; (setq do-it t)) (t (princ"\nBite me...")) ) ) (progn (princ "\nNo duplicate block names found - select your basepoint") ;|(command "_copybase" pause ss "")|; (setq do-it t)) ) ) ) (if do-it (do_it)) ) (defun do_it ( / f d) (command "_copybase" pause ss "")(and (eq (type dbDoc) 'STR) (setq f (findfile dbDoc))(setq d (vla-open *docs* f)))(vla-activate d)) ;;; get block names active doc - vanilla (defun _bl ( / b l ) (while (setq b (tblnext "BLOCK" (null b))) (if (zerop (boole 1 21 (cdr (assoc 70 b)))) (setq l (cons (cdr (assoc 2 b)) l)))) l) (defun Get_EX_Blocknames (dbDoc / fn l) (if (and (eq (type dbDoc) 'STR)(setq fn (findfile dbDoc)) (setq doc (vla-open (vla-get-documents (vlax-get-acad-object)) fn))) (progn (setq l (GetDocBlockNames doc))(vla-close doc)(vlax-release-object doc))) l) ;;; test (setq lst (GetDocBlockNames (vla-get-ActiveDocument (vlax-get-acad-object)))) (defun GetDocBlockNames ( d / b n l) (vlax-for b (vla-get-blocks d) (if (and (= :vlax-false (vla-get-isxref b)) (= :vlax-false (vla-get-islayout b)) (not (vl-string-search "*" (setq n (vla-get-name b)))))(setq l (cons n l)))) l) (defun create_unique_blockname ( $bn / i bn) (setq i 0)(while (tblsearch "block" (setq bn (strcat $bn "_" (itoa (setq i (1+ i))))))) bn) (defun rename_block_definition ( $bn / bc bn ) (setq bc (vla-get-blocks (vla-get-ActiveDocument (vlax-get-acad-object)))) (if (and (not (void $bn)) (tblsearch "block" $bn)) (vla-put-name (Collection-Member $bn bc)(setq bn (create_unique_blockname $bn)))) bn) (defun compare_block_names (a b / c) (and (vl-consp a) (vl-consp b) (foreach item a (if (member item b) (setq c (cons item c))))) c) (defun Get_SS_BlockNames ( ss / n l) (foreach o (ss->ol ss)(if (and (setq n (block-n o))(not (member n l)))(setq l (cons n l)))) l) (defun SS->OL (ss / i l)(setq i 0)(repeat (sslength ss)(setq l (cons (vlax-ename->vla-object (ssname ss i)) l) i (1+ i))) l) (defun void (x) (or (eq x nil)(and (listp x)(not (vl-consp x)))(and (eq 'STR (type x))(eq "" (vl-string-trim " \t\r\n" x))))) (defun block-n (o)(if (and (= 'vla-object (type O))(eq (vla-get-objectname O) "AcDbBlockReference")) (if (vlax-property-available-p o 'EffectiveName) (vla-Get-EffectiveName o) (vla-Get-Name o)) nil)) (defun Collection-Member (m c / r) (if (vl-catch-all-error-p (setq r (vl-catch-all-apply 'vla-item (list c m)))) nil r)) ;;; display list (plus message) (defun dplm (l m / f p d w) (and (vl-consp l) (setq l (mapcar 'vl-princ-to-string l)) (setq w (+ 5 (apply 'max (mapcar 'strlen l)))) (setq p (open (setq f (vl-filename-mktemp ".dcl")) "w")) (princ (strcat "cfl:dialog{label=\"" m "\";:list_box {key=\"lb\";" "width="(itoa w)";}ok_only;}") p)(not (setq p (close p)))(< 0 (setq d (load_dialog f)))(new_dialog "cfl" d)(progn (start_list "lb") (mapcar 'add_list l)(end_list)(action_tile "accept" "(done_dialog)")(start_dialog)(unload_dialog d)(vl-file-delete f)))) ;; choose from list (cfl '("1""2""3")) (defun cfl (l / f p d r) (and (setq p (open (setq f (vl-filename-mktemp ".dcl")) "w")) (princ "cfl:dialog{label=\"Choose\";:list_box{key=\"lb\";width=40;}ok_cancel;}" p) (not (setq p (close p)))(< 0 (setq d (load_dialog f)))(new_dialog "cfl" d) (progn (start_list "lb")(mapcar 'add_list l)(end_list)(action_tile "lb" "(setq r (nth (atoi $value) l))(done_dialog 1)") (action_tile "accept" "(setq r (get_tile \"lb\"))(done_dialog 1)")(action_tile "cancel" "(setq r nil)(done_dialog 0)") (start_dialog)(unload_dialog d)(vl-file-delete f))) (cond ((= r "") nil)(r r)(t nil))) -
See what this does. https://www.cadtutor.net/forum/topic/14213-lisp-to-create-polyline-between-polylines/#findComment-117973
-
CharlieDFW started following Lee Mac
-
agung sitepu joined the community
-
Karel joined the community
-
Bishop2009 joined the community
-
Thanks, @lrm It seems your method relies on there being pairs of points close together between both polylines. But when several points accumulate on one of them and don't find a corresponding point on the other, the calculated axis deviates from the center, and the method loses consistency. To keep these cases under control, I think it is best to manage them using a Lisp. But maybe I'm wrong
-
Copy and paste error (blocks changes!)
X11start replied to X11start's topic in AutoLISP, Visual LISP & DCL
... in fact, ALL (CFD CFLD CAPFD) give me an error: I don't know what I did the first time I used the first file, it even worked on GStarCAD. If I remember correctly, I ran the command with the selection in progress... who knows (!) apparently I bypassed something... but now I can't replicate those steps. -
ilhom1002 joined the community
-
lrm started following Hybrid parallel
-
Here's a simpe solution that doesn't use LISP. Change the elevation of one of the polylines to 1.0 then use the loft command to create asurface. Section the resulting surface with an XY plane at 0,0,0.5.
-
Copy and paste error (blocks changes!)
rlx replied to X11start's topic in AutoLISP, Visual LISP & DCL
I'm a little confused , you say the first lisp gives a warning about duplicate block names in the second drawing and that's also dbx , so maybe its the renaming part that uses commands not supported by GStarCad? -
Copy and paste error (blocks changes!)
GLAVCVS replied to X11start's topic in AutoLISP, Visual LISP & DCL
If you have a debugger (for GStarCAD, VS Code I suppose), the ideal would be to put a breakpoint in the code at the end of this line: "(setq acApp (vlax-get-acad-object) acDoc (vla-get-ActiveDocument acApp))" and this: "(setq dbx (vl-catch-all-apply 'vla-getinterfaceobject (list acApp (dbx_ver))))" And then run it again If the code runs up to the first breakpoint and then continues execution and doesn't stop again at the next breakpoint because the error occurs first, the problem is access to DBX -
Copy and paste error (blocks changes!)
GLAVCVS replied to X11start's topic in AutoLISP, Visual LISP & DCL
Then it is possible that your version of GStarCAD does not have access to DBX from Lisp. -
like i said its not really the avg per say because its missing data points. should probably use the larger/longer poly to pull points from (or maybe both and avg it out). The blue line is suffering from not enough detail since its only calculating off the vertex. i can't test right now but see if the selecting order changes anything. Also change the following and should get a better path. tho it will create a poly with 10x the vertex of selected one. (setq i (+ i 0.1))
-
Objects move away from Basepoint with Move Parameter (and they shouldn't)
CyberAngel replied to ColinPearson's topic in AutoCAD 2D Drafting, Object Properties & Interface
Is this a dynamic block? If not, that might be the way to handle this situation. -
Thanks again for your code, @mhupp It seems that the differences in the turning zones between the resulting geometry and the expected geometry persist. I must say that the goal is to obtain an axis that remains equidistant from the reference polylines at all times. I thought this problem would easily find a solution here. Maybe I was wrong
-
Copy and paste error (blocks changes!)
X11start replied to X11start's topic in AutoLISP, Visual LISP & DCL
... I tried replacing 'objectdbx.axdbdocument' with 'GStarX.axdbdocument': it keeps giving me the error VLA-OBJECT #<%catch-all-apply-error%> -
Precisely selecting with a window
SLW210 replied to Discus84's topic in AutoCAD 2D Drafting, Object Properties & Interface
Then you need to upgrade or follow my recommendation on searching the web for workarounds. I gave you a start with two relevant links. -
That's an Express Tool not available in AutoCAD LT. I was going to suggest the Excel Macro method. Maybe a Script can be used. Was an AutoCAD LT expert around here that did all kinds of customizations, including using Excel, before LT had AutoLISP function. @steven-g IIRC.
-
How can I modify this LISP routine to use millimeters instead? ;; CAB 05.12.09 ;; Draw Electric Wire (defun c:ew (/ ew_layer p1 p2 msg) (setq ew_layer "Wire") ; layer name (defun draw-ew (p4 p1 lay / p2 p3) (setq p2 (polar p1 (- (angle p1 p4) (/ pi ) 57.40259411) p3 (polar p4 (+ (angle p4 p1) (/ pi ) 57.40259411) ) (entmakex (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 8 lay) (cons 90 4) '(70 . 0) ; 1 for closed 0 overwise (cons 10 p1) '(40 . 0.0) '(41 . 0.0) '(42 . 0.198912) (cons 10 p2) '(40 . 0.0) '(41 . 0.0) '(42 . 0.0) (cons 10 p3) '(40 . 0.0) '(41 . 0.0) '(42 . 0.198913) (cons 10 p4) '(40 . 0.0) '(41 . 0.0) '(42 . 0.0) ) ) ) (setq p1 (getpoint "\nPick start point (Draw clockwise")) (setq msg "\nPick next point clockwise.") (while (setq p2 (getpoint p1 msg)) (draw-ew p1 p2 ew_layer) (setq p1 p2) ) (princ) ) (prompt "\nElectric Wire loaded, Enter EW to run.") (princ)
-
syketchupls2 joined the community
-
Tengo un lisp que pone grilla en un viewport, funciona bien, pero solo en viewport que no estan rotados, no se mucho de lisp, casi nada, pero buscando por aqui y alla, lo logre contruir. el caso es que ya no pude hacer que ponga la grilla si esta rotado, otra cosa es que si el viewport no es completamente rectangular o cuadrado, se sale del limite del viewport, aqui esta grilla v2.lsp
-
pedro 47 joined the community
-
mhupp started following Excel link - Sanity check please
-
attout and attin?
-
Ok a few comments, Lets start, as mentioned when they added lisp to LT they decided to leave the smart stuff out, typical Autodesk, so you can not talk direct to Excel, Full Acad, or Bricscad, plus I believe a few others no problem. Just a side comment can also use Libre Calc. From Cad, yes can get range used," so get a list of all "A" column values no user input. Then find the one your looking for this will give you a row value. So put the attributes values into a cell. I have "Alan Excel.lsp" which is a lot of defuns that do different tasks I have saved the latest version in the download section. I have acknowledged those that have helped in putting it together the extra defuns, I keep adding to it depending on task. One thing you can do is check (setq xlApp (vlax-get-or-create-object "Excel.Application")) if it errors or returns NIL that would occur in LT. Please let me know. If its a simple nil then do the export to csv and use say (alert "Run the macro to import the csv file"), as a side note pretty sure in full version could call the macro, so one common code only. There is one little glitch when you need to go to Excel to do something user wise you must click on Excel window, but I did find a way around it using Powershell that is called from the CAD so it auto jumps to Excel. Should be able to do same in excel jump back to cad. Just google about your Excel macro questions there is huge amount of info out there use VBA answers and convert to Lisp sometimes.
- Last week
-
Precisely selecting with a window
Discus84 replied to Discus84's topic in AutoCAD 2D Drafting, Object Properties & Interface
HI, I'm running version 12, Regards, Lu