Search the Community
Showing results for tags 'autolisp'.
-
Im beginner, I have this: (setq p1 (getpoint "\nPunto Inicial:")) (setq p2 (polar p1 (* 1.5 pi) 0.5)) (entmakex (list '(0 . "line") (cons 10 p1) (cons 11 p2) '(62 . 2))) So, the line I drawn is the yellow one below in the image. And, the text I want put is the magenta one. how can I do this? Thanks for your help
-
how to change a color of a line previusly drawn with Autolispp
danyra posted a topic in AutoLISP, Visual LISP & DCL
Im a begginer, I drawn a line in autolisp with this "code": (setq p1 (getpoint "\nPunto Inicial:")) (setq p2 (polar p1 (* 1.5 pi) 0.18)) (command "line" p1 p2 "") but, how can I change the color of this line?? For example I want yellow Thanks for your help. -
Assigning and Custom Drawing Property to a variable
juicyorange posted a topic in AutoLISP, Visual LISP & DCL
Hey guys, I'm looking to assign a custom property to a variable and I have no idea how to do it. In the 0 custom prop I put a testvalue Here is the code I have so far: (vl-load-com) (defun c:test (/) (setq acadObject (vlax-get-Acad-Object) acadDocument (vla-get-Activedocument acadObject) ;; set existing custom properties to dProps dProps (vlax-get-property acadDocument 'Summaryinfo) ) ;; get the value at the specifed index in the dProps and assign it to location (vla-GetCustomByIndex dProps 0 "IMPCSVLOC" location) ) I can't find any documentation on the "vla-GetCustomByIndex" so I don't really know how to use tbh. I've attached a file that has the custom property setup. All insight and help is appreciated. Thanks, JT testfile.dwg- 6 replies
-
- autolisp
- custom proerties
-
(and 2 more)
Tagged with:
-
Hello, I am looking for a lisp that will allow me to increment an attribute in a block from one block to the next by doing a window selection. The lisp that I have now that I got from Chaitanya Chikkala (see below) works great, but I have to select each block individually. With 2000+ blocks it is easy to make a mistake. When I window select with it, it numbers them as they were added to the drawing. This does not work for me because multiple people work on drawings and then are combined into a master drawing so the order is wrong. Is there a way for a direction to be added, even if it is just along the x or y axis? Or is there a lisp that already does this? Any help is very much appreciated. (defun c:incr (/ ent obj x i ST_STR) (command "._undo" "_be") (SETQ ST_STR1 (GETSTRING "\nENTER STARTING NUMBER OF THE SEQUENCE(ANY ALPHABET/WORD)")) (SETQ ST_STR (GETSTRING "\nENTER STARTING NUMBER OF THE SEQUENCE(ANY INTEGER)")) (vl-load-com) (setq i 0) (prompt "\nSelect blocks one at a time and in order") (SETQ BLOCK_LIST (SSGET)) (SETQ BLOCK_LIST (FORM_SSSET BLOCK_LIST)) (while (< I (LENGTH BLOCK_LIST)) (SETQ ST_STR (STRCAT "" ST_STR)) (SETQ TEMP_ELE (NTH 0 (ATTRIBUTE_EXTRACT (NTH I BLOCK_LIST)))) (SETQ TEMP_ATTRIBUTE (STRCAT ST_STR1 ST_STR)) (SETQ TEMP_TAG (NTH 0 TEMP_ELE)) (MODIFY_ATTRIBUTES (NTH I BLOCK_LIST) (LIST TEMP_TAG) (LIST TEMP_ATTRIBUTE)) (SETQ ST_STR (ITOA (+ (ATOI ST_STR) 1))) (setq i (+ i 1)) ) (command "._undo" "_e") (princ)) (DEFUN FORM_SSSET (SSSET / I TEMP_ELE LIST1) (SETQ I 0) (SETQ TEMP_ELE NIL) (SETQ LIST1 NIL_) (WHILE (< I (SSLENGTH SSSET)) (SETQ TEMP_ELE (SSNAME SSSET I)) (SETQ LIST1 (CONS TEMP_ELE LIST1)) (SETQ I (+ I 1)) ) (REVERSE LIST1) ) (DEFUN ATTRIBUTE_EXTRACT (ENTNAME / ENT_OBJECT SAFEARRAY_SET I LIST1) (SETQ SAFEARRAY_SET NIL) (SETQ ENT_OBJECT ENTNAME) (SETQ ENT_OBJECT (VLAX-ENAME->VLA-OBJECT ENT_OBJECT)) (IF (= (VLAX-GET-PROPERTY ENT_OBJECT "HASATTRIBUTES") :VLAX-TRUE) (PROGN (SETQ SAFEARRAY_SET (VLAX-SAFEARRAY->LIST (VLAX-VARIANT-VALUE (VLAX-INVOKE-METHOD ENT_OBJECT "GETATTRIBUTES") ) ) ) (SETQ I 0) (SETQ LIST1 NIL) (WHILE (< I (LENGTH SAFEARRAY_SET)) (SETQ LIST1 (CONS (LIST (VLAX-GET-PROPERTY (NTH I SAFEARRAY_SET) "TAGSTRING") (VLAX-GET-PROPERTY (NTH I SAFEARRAY_SET) "TEXTSTRING") ) LIST1 ) ) (SETQ I (+ I 1)) ) (SETQ LIST1 (REVERSE LIST1)) (SETQ LIST1 (SORT_FUN LIST1 0 0))) (SETQ LIST1 NIL) )LIST1 ) (DEFUN MODIFY_ATTRIBUTES (ENTNAME IDENTIFIER VALUE / TEMP_ELE ENT_OBJECT SAFEARRAY_SET I J) (SETQ SAFEARRAY_SET NIL) (SETQ ENT_OBJECT ENTNAME) (SETQ ENT_OBJECT (VLAX-ENAME->VLA-OBJECT ENT_OBJECT)) (IF (= (VLAX-GET-PROPERTY ENT_OBJECT "HASATTRIBUTES") :VLAX-TRUE) (PROGN (SETQ SAFEARRAY_SET (VLAX-SAFEARRAY->LIST (VLAX-VARIANT-VALUE (VLAX-INVOKE-METHOD ENT_OBJECT "GETATTRIBUTES") ) ) ) (SETQ I 0) (SETQ J 0) (SETQ LIST1 NIL) (WHILE (< I (LENGTH SAFEARRAY_SET)) (SETQ TEMP_ELE (VLAX-GET-PROPERTY (NTH I SAFEARRAY_SET) "TAGSTRING")) (IF (/= (VL-POSITION TEMP_ELE IDENTIFIER) NIL) (PROGN (VLAX-PUT-PROPERTY (NTH I SAFEARRAY_SET) "TEXTSTRING" (NTH (VL-POSITION TEMP_ELE IDENTIFIER) VALUE)) )) (SETQ I (+ I 1)) ) ))) (DEFUN SORT_FUN (LIST1 FLAG1 FLAG2 /) (IF (= NIL (VL-CONSP (CAR LIST1))) (PROGN (SETQ LIST1 (INDEX_ADD LIST1)) (SETQ LIST1 (VL-SORT LIST1 '(LAMBDA (X Y) (< (CADR X) (CADR Y))) ) ) (SETQ LIST1 (MAPCAR '(LAMBDA (X) (CADR X)) LIST1)) ) (PROGN (IF (NOT (ATOM (NTH FLAG1 (NTH 0 LIST1)))) (SETQ LIST1 (VL-SORT LIST1 '(LAMBDA (X Y) (< (NTH FLAG2 (NTH FLAG1 X)) (NTH FLAG2 (NTH FLAG1 Y))) ) ) ) (PROGN (SETQ LIST1 (VL-SORT LIST1 '(LAMBDA (X Y) (< (NTH FLAG2 X) (NTH FLAG2 Y))) ) ) ) ) ) ) LIST1 )
-
takes out the coordinates of several polylines with a .txt file
asra posted a topic in AutoLISP, Visual LISP & DCL
Hello is it possible to make lisp to extract coordinates from several polyline lines and their titles in the form of a .txt file? I have an example of the attachment below, I hope someone can help me, thank you. OUTPUT.txt MASTER CROSS SECTION.dwg -
Export Enhanced Attributes Editor Values to Excel
MajorTom posted a topic in AutoLISP, Visual LISP & DCL
Hi, I'm new around here so, I couldn't find the solutions please don't mad me if this request already written by someone else. And also sorry about my grammer either The thing what I want to do : I have a folder and this folder is include many dwg files. And these dwg files contetnts one or more layouts. I'm using Enhanced Attribute Editor for keep data like; <drawing number>, <drawing name>, <date>, <revision no> etc. So I need a lisp for export these data to an excel file . thanks in advance for any help Truly Regards -
Autolisp: Comment between square brackets?
eengebruiker posted a topic in AutoLISP, Visual LISP & DCL
I just discovered that I can put a line in my lispfile like this: [Some notes]. When I load the lispfile the line is ignored. In other words it acts like comment. Comes in handy because I can use another type of comment, But . . . . . . Do I rely on a rule here or will I get into trouble later when using the code? Thanks in advance, André -
Hello everyone, I have been developing some routines for the pas 6 months, so my knowledge is not very high. Normally I manage to find answers online, thanks to all of you who share their knowledge, it's so helpful. I am writing a routine which would: Compare the XREF name on the drawing and the XREF 'real' file name and match them (on the drawing) if different. After the code checks if the XREF name matches a specific formatting and if it does creates a layer based on it (if the layer does not already exist). The final step is to change the XREF layer to that one, and here is where I am getting an error. I tried with different ways to do this and always got an error. I guess I could try to get this done without using vl code but this is really puzzling me and I would like to know why is actually not working, I dont see where the code could have gone wrong. The example names of my XREFs: which are used to compare with the wcmatch "*_*_*_*" XREF_TGLMTE_PRO_INTER_BASSINS_01 XREF_TGLMTE_PRO_INTER_RESEAUX_HS_2025_01 XREF_TGLMTE_PRO_TRC_V5_IND_D I used different lines of code to try to achieve this, as you can see on my commented lines on the code. I am currently using a (vlax-put-property it2 'layer strcalq) inside a vlax-for getting the following error: (defun c:xrcalque (/ AcadObj AcadAct LyAct it2 xrobjectname strcalq) (vl-load-com) (setq *error* ABD:Error) (setq AcadObj (vlax-get-Acad-Object)) (setq AcadAct (vla-get-ActiveDocument AcadObj)) (setq LyAct (vla-get-layers AcadAct)) ;get layers from Active document (xrn AcadObj AcadAct); runs the subroutine to change XREF name on drawing to match XREF file name (vlax-for it2 (vla-get-blocks AcadAct) (setq ind1 3) (setq ind2 0) (setq ind3 0) (if (= (vla-get-isxref it2) :vlax-true) (progn (setq xrobjectname (vl-filename-base (vla-get-name it2))) (if (wcmatch xrobjectname "*_*_*_*"); (progn (repeat ind1 (setq ind3 (+ ind2 1)) (setq ind2 (vl-string-position (ascii "_") xrobjectname ind3));gets firs position of "_" character ) (print xrobjectname) (setq ind2 (+ ind2 2)) (print ind2) ; ind2 is the position of the ind1 "_" element (3rd) to count from there to have the layer name (setq ind4 (vl-string-position (ascii "_") xrobjectname nil T)); last "_" position (setq ind5 (vl-string-position (ascii "-") xrobjectname nil T)); last "-" position (if (> ind4 ind5)(setq indlst ind4)(setq indlst ind5)) ;check which one is bigger (setq indlst (+ 1 indlst)) (setq strcalq (strcat "SF-XREF_"(substr xrobjectname ind2 (- indlst ind2)))) ;Create layer with string from ind2 position to ind4 or ind5 position (strcalq) (print strcalq) (if (not (tblsearch "LAYER" strcalq));checks non existance of layer (progn (vla-add LyAct strcalq) (print "Layer has been created") ) (progn ;(vla-put-layer it2 "0") ; (print "this is a test4") (print "layer exists") ;if layer exists put object on layer ) );if (print strcalq) ;(vla-put-layer it2 "0") ;(vla-put-layer xrobjectname strcalq) ;(vla-put-layer (vla-get-name it2) strcalq) ;(vlax-put it2 'Layer "0") ;(vlax-put (vlax-ename->vla-object (vla-get-name it2)) 'Layer "0") (vlax-put-property it2 'layer strcalq);############ ERROR############### );progn (print "wcmatch xref name not matching") );if );progn );if ;(vlax-put (vlax-ename->vla-object xrtemp) 'Layer strcalq) );vlax for (print "highly recommended to purge layers") ;add code to purge automatically the layers? (princ) );defun ;;;======================================= Error function ++++++++++++++++++++++++++++++++++++++++;;; (defun ABD:Error (st) (if (not (member st (list "Fonction annulée" "quitter / sortir abandon"))) (vl-bt) );if ;(princ "Merci d'envoyer vos commentaires ou report d'erreurs à ") (princ);clean exit ? );defun error ;;;======================================= function xrn +++++++++++++++++++++++++++++++++++++++++++;;; (defun xrn (AcadObj AcadAct / item xrobjectnamexrn xrfilenamexrn) (vlax-for item (vla-get-blocks AcadAct) (if (= (vla-get-isxref item) :vlax-true) (progn (setq xrobjectnamexrn (vl-filename-base (vla-get-name item))) (setq xrfilenamexrn (vl-filename-base (vla-get-path item))) (if (/= xrobjectnamexrn xrfilenamexrn) (progn (vla-put-name item xrfilenamexrn) (vla-reload item) ) ) ) ) ) );defun xrn If someone could explain why this is not working, and please share a way to achieve my goal would be awesome! Thank you in advance, Alan
-
Insert Block in-between two Points using Autolisp
subodh_gis posted a topic in AutoLISP, Visual LISP & DCL
Many a times it requires to show the same block with different angle and scale. Rotating each block to a required angle, and scaling it as required will take a lot of time so can we Insert Block in-between two Points in the angle and scale of points selection using Autolisp . I am using AutoCAD 2004. Thank You ! -
-
Hei, Can enyone make autolisp to annotate 3d point z value! Best, MRe
-
Hello. I am a student and I need your help. My task is to write a program in AutoLISP that draws parts but I have no idea how to do it. The program in the simplest version which is only possible - I know that for some of you it's a bit of a job, so if it was possible, I would ask for help. I will try to repay somehow . Greetings. Sorry for my English.
-
FYI: Steve Johnson has an article about this new lisp function called (inspector), in BLADE, for inspecting objects.
-
I am creating an excel worksheet from autolisp to populate with all of my fuse information from autocad electrical 2011. Everything works fine except that I cannot figure out how to change the width of the columns in the excel spreadsheet from autolisp. Any assistance would be greatly appreciated. This is what I have on the spreadsheet: (setq xl (vlax-create-object "excel.application")) (setq wb-collection (vlax-get xl "workbooks")) (setq workbook (vlax-invoke-method wb-collection "add")) (setq sheets (vlax-get workbook "sheets")) (setq sheet1 (vlax-get-property sheets "item" 1)) (setq mywb(vlax-get-property xl "ActiveWorkbook")) (setq *excel-cells* (vlax-get sheet1 "cells")) (vlax-put xl "visible" 1) ;;****************insert header info into spreadsheet********************** (setq fuse_cell (strcat "A" (itoa in))) (setq cat_cell (strcat "B" (itoa in))) (setq mfg_cell (strcat "C" (itoa in))) (setq rating1_cell (strcat "D" (itoa in))) (setq class_cell (strcat "E" (itoa in))) (setq a (vlax-get-property xl 'Range fuse_cell)) (setq b (vlax-get-property xl 'Range cat_cell)) (setq c (vlax-get-property xl 'Range mfg_Cell)) (setq d (vlax-get-property xl 'Range rating1_cell)) (setq e (vlax-get-property xl 'Range class_cell)) (vlax-put-property a 'Value2 "FUSE") (vlax-put-property b 'Value2 "PART NUMBER") (vlax-put-property c 'Value2 "MANUFACTURER") (vlax-put-property d 'Value2 "RATING") (vlax-put-property E 'Value2 "CLASS") (setq in 2); sets row in spreadsheet ;*****************************populate excel sheet**************************************** (repeat (length fuse_name) (setq fuse_cell (strcat "A" (itoa in))) (setq cat_cell (strcat "B" (itoa in))) (setq mfg_cell (strcat "C" (itoa in))) (setq rating1_cell (strcat "D" (itoa in))) (setq class_cell (strcat "E" (itoa in))) (setq a (vlax-get-property xl 'Range fuse_cell)) (setq b (vlax-get-property xl 'Range cat_cell)) (setq c (vlax-get-property xl 'Range mfg_Cell)) (setq d (vlax-get-property xl 'Range rating1_cell)) (setq e (vlax-get-property xl 'Range class_cell)) (vlax-put-property a 'Value2 (nth in_lst fuse_name)) (vlax-put-property b 'Value2 (nth in_lst fuse_Cat)) (vlax-put-property c 'Value2 (nth in_lst fuse_mfg)) (vlax-put-property d 'Value2 (nth in_lst fuse_rating1)) (vlax-put-property e 'Value2 (nth in_lst fuse_class)) (setq in_lst (1+ in_lst))(princ) (setq in (1+ in))(princ) )
-
save excel workbook to new location from autolisp
Mickey the Gr8 posted a topic in AutoLISP, Visual LISP & DCL
I need to know how to save a new excel workbook to a location of my choosing. I want to be able to open a new workbook, add data, and then save it in a folder in my project folder. I can do everything but save it to the new location. This is what I have so far. (vl-load-com) (setq FilePath "T:\\reference material\\fuse_list_template.xls") (setq ExcelApp (vlax-get-or-create-object "Excel.Application")) (vla-put-visible ExcelApp :vlax-true) (vlax-put-property ExcelApp "DisplayAlerts" :vlax-false) (setq Wbk (vl-catch-all-apply 'vla-open (list (vlax-get-property ExcelApp "WorkBooks") FilePath))) From here I am adding data from autocad electrical 2011 which works fine. My problem is I want to save this to a location that is not the same as the original filepath. I cannot find the code to do a "save as" to the excel workbook. Any help would be appreciated. It should not be this complicated. Thanks. -
Help modifying a modified divide lisp from Cadalyst website
dughug posted a topic in AutoLISP, Visual LISP & DCL
Hi all: I like using Lisps, but don't know how to write code for them. I like this particular lisp created by Mosad Elewa and posted on Cadalyst.com. When trying the lisp on a polyline, it did not work. Seems to only work on a "line". Here's the code: ---------------------------------------------------------------------------------------------------- ;;;CADALYST 02/07 Tip 2180: DIV.LSP Modify Divide © 2007 Mosad Elewa ;DIV.LSP BY MOSAD H. ELEWA (1996) (defun C:DIV () (setq ent (entget (car (entsel "\nSelect object to divide")))) (setq etype (cdr (assoc 0 ent))) (if (eq etype "LINE") (progn (cond ( (setq m (getint "\nNumber of segments")) (setq pt1 (cdr (assoc 10 ent))) (setq pt2 (cdr (assoc 11 ent))) (setq ang (angle pt1 pt2)) (setq dist (distance pt1 pt2)) (setq dd (/ dist m)) (setq pt3 (polar pt1 ang dd)) (setq ang2 (+ ang 1.5708)) (setq pt4 (polar pt3 ang2 (/ dd 4))) (setq ds (distance pt1 pt3)) (command "line" pt3 pt4 "") (setq pt5 (polar pt3 ang2 (/ dd )) (command "move" "l" "" pt4 pt5) (setq d 0) ; (setvar "cmdecho" 0) (command "copy" "l" "" "m" pt1) (repeat (- m 2) (command (polar pt1 ang (setq d (+ d ds))))) (command ""))) )) (if (eq etype "ARC") (progn (setq n (getint "\Number of segments")) (setq ang (cdr (assoc 50 ent))) (setq ang2 (cdr (assoc 51 ent))) (setq ang3 (- ang2 ang)) (setq ang4 (/ (* ang3 180.0) pi)) (setq cp (cdr (assoc 10 ent))) (setq r (cdr (assoc 40 ent))) (setq pt1 (polar cp ang r)) (setq pt2 (polar cp ang (/ r 4))) (setq pt3 (polar cp ang (/ r )) (command "line" cp pt2 "") (command "move" "l" "" pt3 pt1) (command "array" "l" "" "p" cp (+ n 1) ang4 "y") )) (if (eq etype "CIRCLE") (progn (setq n (getint "\Number of segments")) (setq cp (cdr (assoc 10 ent))) (setq r (cdr (assoc 40 ent))) (setq pt1 (polar cp 0 r)) (setq pt2 (polar cp 0 (/ r 4))) (setq pt3 (polar cp 0 (/ r )) (command "line" cp pt2 "") (command "move" "l" "" pt3 pt1) (command "array" "l" "" "p" cp n "360" "y") )) (princ) )[/CODE] ----------------------------------------------------------------------------------------------------- -
How to unlock table cell after removing datalink using AutoLISP.?
Ashish123 posted a topic in AutoLISP, Visual LISP & DCL
Hello, I have 5000 drawings that contains three specific tables. All these tables are linked to external Excel using data links. The main issue i have is, after the data link is removed the cell content of all three tables remain locked. Is there any way to unlock the cells using lisp??. I know i can do it manually but i don't want to go that route unless it is the only the way to do so. Please take a look at the drawing & lsp file. Trial.dwg Thank you very much. Regards, A AUTOCAD AUTOMATION.LSP- 3 replies
-
- script
- table lisp
-
(and 1 more)
Tagged with:
-
Adding custom properties to objects in the design tab
micromachines posted a topic in AutoLISP, Visual LISP & DCL
Hi, I am running a version of autocad architecture with a plugin that adds some custom properties to AEC objects such as doors that can be viewed under the design tab of the property palette. I want to make a macro that changes these properties but I don't know how to access them via lisp. When I use the inspect window in the visual lisp viewer the custom properties don't come up and when I use the vla-dump-object function, the custom properties are not listed also. Does anyone have any idea if/how these properties are accessible? Also, can custom property fields be added via autolisp? -
Hello everyone, everything good. First apologies for my pessimo ingles. (defun c:Test0008 (/ p1 oFile sFile tmp Separator i ;|Functions|; GetFormatFile aux:SelectFile grdx ) ;;_________________________________________________ (defun GetFormatFile (/ lsts) (or *Format* (setq *Format* "csv")) (setq lsts '(("csv" ";" "[<Csv>/Txt/Xls]") ("txt" " " "[Csv/<Txt>/Xls]") ("xls" "\t" "[Csv/Txt/<Xls>]"))) (setq mens (last (assoc *Format* lsts))) (initget "Csv Txt Xls _csv txt xls") (if (setq tmp (getkword (strcat "\nFormat file;" mens ": "))) (setq *Format* tmp) ) (setq Separator (cadr (assoc *Format* lsts))) ) ;;_________________________________________________ (defun aux:SelectFile ( Extension / ff) (if (setq ff (getfiled "Select File" (if *TmpRutaFile* *TmpRutaFile* "") Extension 1)) (setq *TmpRutaFile* (strcat (vl-filename-directory ff) "\\")) );c.if ff );c.defun ;;_________________________________________________ ; grdx - graphic cross utility (defun grdx (p col size / h) (setq h (/ (getvar "viewsize") size)) (grdraw (list (- (car p) h) (- (cadr p) h)) (list (+ (car p) h) (+ (cadr p) h)) col 0) (grdraw (list (- (car p) h) (+ (cadr p) h)) (list (+ (car p) h) (- (cadr p) h)) col 0) p );c.defun ;;--------------------- MAIN ----------------- (or *Prec* (setq *Prec* 4)) (setq p1 (getpoint "\nPick first point: ")) (while p1 (grdX p1 213 125) (setq lstFile (cons p1 lstFile)) (setq p1 (getpoint " >> Pick Next point: ")) ) (cond (lstFile (initget (+ 4)) (if (setq tmp (getint (strcat "\nPrecisión;<" (itoa *Prec*) ">: "))) (setq *Prec* tmp) ) (GetFormatFile) (setq sFile (aux:SelectFile *Format*)) (cond (sFile (setq i 1) (setq oFile (open sFile "w")) (write-line "COORDINATES OF POINTS" oFile) (write-line (strcat "#" Separator "X" Separator "Y" Separator "Z") oFile) (mapcar (function (lambda (pt) (write-line (strcat (itoa i) Separator (rtos (car pt) 2 *Prec*) Separator (rtos (cadr pt) 2 *Prec*) Separator (rtos (last pt) 2 *Prec*) ) oFile) (setq i (1+ i)) ) ) lstFile );c.mapcar (close oFile) (alert (strcat "File: \n\n[" sFile "]\n\nhas been created.")) ;;(startAPP (strcat "notepad.exe " sFile)) (command "shell" (strcat "start " sFile)) ) ) ) );c.cond (princ) ) (princ) I use this routine that exports coordinates, from points clicked to excel, in Csv / Txt / Xls but the exports in descending order _the last point I clicked is the first_ Can anyone reverse this? Are the points imported in the order they are clicked? --------------------------------------------------------------------------------------- Another thing, the great Lee-mac created a subroutine that would help me a lot if it were attached to the program. this link http://www.lee-mac.com/grtext.html has the subroutine, and here is the demo. (defun c:demo2 ( / *error* pnt str ) (defun *error* ( m ) (princ m) (redraw) (princ)) (while (= 5 (car (setq pnt (grread nil 13 0)))) (redraw) (setq str (mapcar 'rtos (trans (cadr pnt) 1 0))) (LM:DisplayGrText (cadr pnt) (LM:GrText (strcat "X=" (car str) "\nY=" (cadr str))) 3 15 -31) ) (redraw) (princ) ) This subroutine would work as a preview, so I know if I'm clicking the correct location. I thank the help of all you.
-
Hi, I have several drawings with thousands of individual circles (not blocks) of same radius. All of them I am supposed to change to the equilateral triangle of base & sides length = 10mm. Is it possible to write a program to do this automatically? Thanks in advance.
-
Inserting Dynamic Blocks along the points of Polyline using LISP
sanetmunde posted a topic in AutoLISP, Visual LISP & DCL
Hi, I want a LISP routine which can insert blocks along the polyline. I have two dynamic blocks. They are 'Straight Duct' and 'Elbow90'. Consider I draw a polyline with three XY coordinates i.e. (1,1) , (1,2) and (2,2) and insert rectangular block with desired 'Width'. Here are list of things I want from LISP program: 1. I want 'Straight Duct' to be inserted at mid-points of '(1,1) & (1,2)' and '(1,2) & (2,2)'. 2. Also, those inserted blocks should be rotated with an angle made by those points with horizontal so that 'Straight Duct' remains along the line. Example, Angle made by line joining points '(1,1) & (1,2)' with horizontal is 90 Deg. Hence, Dynamic Block should be rotated by 90 degree about midpoint. 3. Move the grip of 'Straight Duct' (which facing to open end of polyline) to the open end of polyline. Move other grip of 'Straight Duct' to the length of (150+ Width/2) mm less than the intersection point. 4. Insert 'Elbow90' at the point with polar angle 45 Degree to point of intersection and polar radius (150 + Width/2) mm. Also, the grip of elbow should be moved so that width of 'Elbow90' should be as same as that of 'Straight Duct'. Pls refer the attached file for understanding the problem. Can anyone help me out? HVAC Dynamic Blocks 24.04.2018.dwg- 8 replies
-
- autolisp
- block attribute
-
(and 2 more)
Tagged with:
-
I have created Dynamic Block with grips and Attribute linked to the parameter. Now I override that attribute value to a manual value through a program and change the parameter. Now, when I move the grips of dynamic block, the attribute value linked to it doesn't change and remains as manual value. Is there any way/ program to retrieve the relation between attribute and parameter value? Pls find attached Program and Dynamic Block. You can override linked values of "WIDTH" & "LENGTH" by 'double-clicking' on block and entering manual value. Upload & Run the program with command "DChange". This will change the shape of block as per manual value. After this, when you will stretch the grips of block, it will change the shape; but, the attribute value "WIDTH" & "LENGTH" will not change. Can this linking between Attribute & Parameter revived so that attribute values will change with moving grips? Straight Duct.dwg DChange.lsp
-
Lisp to create and name layouts and restore views by reading excel or notepad file?
bkirtland posted a topic in AutoLISP, Visual LISP & DCL
Hi everyone, I'm new to using macros/lisps in AutoCAD, though I do have a small programming background in some other programs. To give you some background on what I'm trying to do: I have a big .dwg file that shows all of the roads in a particular city in the USA, and I have created views of all of the intersections that have crosswalks. All of these intersections have their own intersection IDs, which have a format such as BRI1, BRI2A, BRI3B, BRI4, BRI5, etc., through BRI170. I have already created all of the views from these intersections, and now, in the same .dwg, I am trying to quickly create layouts from a template that show only one view each. I have a .dwt set up for this, and the name of the layout for this template is EB124. I want the layout tabs to be named corresponding to an intersection ID, and then have the viewport show that same view. So, I want layout 1 to be renamed BRI1, and have the viewport view restored to the named view BRI1, and so on for all of the named views. Here are the commands that I used to create a macro for this using the Action Recorder: -layout > t > [select template from file] > EB124 -layout > set > EB124 -layout > rename > EB124 > [ASK FOR USER INPUT, example BRI1] [select the viewport in the new layout and unlock the display] MSPACE -view > restore > [ASK FOR USER INPUT, example BRI1] PSPACE [select the viewport and lock the display] This macro works great, except that I have to press play and enter the intersection ID twice per layout tab. I'm wondering if its possible to create a lisp that does this routine but reads an excel (or other) file and loops through and creates all the layout tabs in one fell swoop? Thanks in advance for all of your help! -
Hello all, I've posted on SEVERAL forums trying to get an answer to this problem, I've compiled so many different Lisp routines that I've lost count, but none have quite been able to do what i want. i've attached a dwg with two blocks in it, the scope of what I'm trying to accomplish is at the bottom of this code: (defun BKVZ ( / blk idx obj sel vis ) (setq blk "WELD DETAIL" ;; Block Name vis "EQUAL WELD" ;; New Visibility State ) (if (setq sel (ssget "_X" (list '(0 . "INSERT") (cons 2 (strcat "`*U*," blk))))) (repeat (setq idx (sslength sel)) (if (= (strcase blk) (strcase (LM:blockname (setq obj (vlax-ename->vla-object (ssname sel (setq idx (1- idx)))))))) (LM:SetVisibilityState obj vis) ) ) ) (princ) ) ;; I would like the visibility state of several different dynamic blocks ;; to reference a text field within the drawing, and the blk variable to be used for several different dynamic ;; blocks within my drawing. for example in this drawing i have two dynamic blocks, and two text fields that ;; represent the visibility states that i want to use for the blocks (this value will change so i want to use it as a ;; variable to change the db viz prop) . I would like to be able to use this code to change the vis states of ;; several blocks within the same dwg, each of which would have a text field that will display the present vis state. ;; if i have to use setq blk1, blk2, blk3, etc to represent each block that is fine, but with several different possible ;; vis states, i would like that varible to reference the text field. so as the text field changes, so does the vis state of the ;; dynamic block. ANY HELP WOULD BE APPRECIATED. THANK YOU!! NEW-LISP-TRIAL.dwg
- 26 replies
-
- dynamic blocks
- autolisp
-
(and 1 more)
Tagged with:
-
select multiple polylines and convert straight to arc segments
jntm226 posted a topic in AutoLISP, Visual LISP & DCL
this lisp convert polyline segments to arcs . work one line for time . i need select 1000 polylines for times. I'm new in autolisp and i do know what change in the code : (defun c:lwsegs2arced ( / massoclst nthmassocsubst v^v unit _ilp doc lw enx gr enxb p1 p2 p3 b i n ) (vl-load-com) (defun massoclst ( key lst ) (if (assoc key lst) (cons (assoc key lst) (massoclst key (cdr (member (assoc key lst) lst))))) ) (defun nthmassocsubst ( n key value lst / k slst p j plst m tst pslst ) (setq k (length (setq slst (member (assoc key lst) lst)))) (setq p (- (length lst) k)) (setq j -1) (repeat p (setq plst (cons (nth (setq j (1+ j)) lst) plst)) ) (setq plst (reverse plst)) (setq j -1) (setq m -1) (repeat k (setq j (1+ j)) (if (equal (assoc key (member (nth j slst) slst)) (nth j slst) 1e-6) (setq m (1+ m)) ) (if (and (not tst) (= n m)) (setq pslst (cons (cons key value) pslst) tst t) (setq pslst (cons (nth j slst) pslst)) ) ) (setq pslst (reverse pslst)) (append plst pslst) ) (defun v^v ( u v ) (mapcar '(lambda ( s1 s2 a b ) (+ ((eval s1) (* (nth a u) (nth b v))) ((eval s2) (* (nth a v) (nth b u))))) '(+ - +) '(- + -) '(1 0 0) '(2 2 1)) ) (defun unit ( v ) (mapcar '(lambda ( x ) (/ x (distance '(0.0 0.0 0.0) v))) v) ) (defun _ilp ( p1 p2 o nor / p1p p2p op tp pp p ) (if (not (equal (v^v nor (unit (mapcar '- p2 p1))) '(0.0 0.0 0.0) 1e-7)) (progn (setq p1p (trans p1 0 (v^v nor (unit (mapcar '- p2 p1)))) p2p (trans p2 0 (v^v nor (unit (mapcar '- p2 p1)))) op (trans o 0 (v^v nor (unit (mapcar '- p2 p1)))) op (list (car op) (cadr op) (caddr p1p)) tp (polar op (+ (* 0.5 pi) (angle '(0.0 0.0 0.0) (trans nor 0 (v^v nor (unit (mapcar '- p2 p1)))))) 1.0) ) (if (inters p1p p2p op tp nil) (progn (setq p (trans (inters p1p p2p op tp nil) (v^v nor (unit (mapcar '- p2 p1))) 0)) p ) nil ) ) (progn (setq pp (list (car (trans p1 0 nor)) (cadr (trans p1 0 nor)) (caddr (trans o 0 nor)))) (setq p (trans pp nor 0)) p ) ) ) (or doc (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))) (vla-startundomark doc) (if (and (setq lw (entsel "\nPick LWPOLYLINE...")) (= (cdr (assoc 0 (setq enx (entget (car lw))))) "LWPOLYLINE") ) (progn (setq i (fix (vlax-curve-getParamAtPoint (car lw) (vlax-curve-getClosestPointToProjection (car lw) (trans (cadr lw) 1 0) '(0.0 0.0 1.0)) ) ;_ vlax-curve-getParamAtPoint ) ;_ fix p1 (vlax-curve-getPointAtParam (car lw) i) p3 (vlax-curve-getPointAtParam (car lw) (1+ i)) lw (car lw) ) (setq enxb (massoclst 42 enx)) (while (= 5 (car (setq gr (grread t)))) (setq p2 (_ilp (trans (cadr gr) 1 0) (mapcar '+ (trans (cadr gr) 1 0) '(0.0 0.0 1.0)) p1 (cdr (assoc 210 (entget lw))))) (setq b ((lambda (a) (/ (sin a) (cos a))) (/ (- (angle (trans p2 0 lw) (trans p3 0 lw)) (angle (trans p1 0 lw) (trans p2 0 lw))) 2.0) ) ) (setq n -1) (foreach dxf42 enxb (setq n (1+ n)) (if (= n i) (setq enx (nthmassocsubst n 42 b enx)) (setq enx (nthmassocsubst n 42 (+ (cdr dxf42) b) enx)) ) ) (entupd (cdr (assoc -1 (entmod enx)))) ) ) (prompt "\n Nothing selected or picked object not a LWPOLYLINE ") ) (vla-endundomark doc) (princ) )