Search the Community
Showing results for tags 'lisp routines'.
Found 15 results
Lisp Routine to make boundaries of selected objects
xxfaxx posted a topic in AutoLISP, Visual LISP & DCLHello I am new in this website. By new i mean it is the first time i make an account. I have been visiting this website for around 3 or 4 (maybe 5) years. I dont remember. After using autocad for over 8 years (starting in with autocad 2009) i sometimes start to think that i can not learn any more. But everytime i see a new lisp routine, and my lack of knowledge to code them, i feel that i have so much to learn. Anyways, enough chit chat. I am looking for two things and i hope some good person can help me pointing me in the right direction. First i would love to learn how to code those lisp routines because at my work (real state and urbanism) there are a thousand ways that i can make it faster with lisp routines. Second, i was looking exactly for a lisp routine that makes boundaries out of the selected objects. Imagine a urban block (a closed polyline) , and now imagine the divisions between its lots (they can be polylines, lines or arcs) . I need to make one boundary in each lot. I can do it with the "boundary" command, but the thing is that sometimes we have around 10k lots (500 urban blocks), so that is a lot of clicking. I use autocad architecture 2016 and windows 10 if that helps somehow I hope i made myself clear. Sorry if not. English is my second language Atte. Francisco
How to get this LISP to add an additional 90 degrees to its rotate
msirois posted a topic in AutoLISP, Visual LISP & DCLHi there, You'll have to forgive my ignorance and I'm new to the whole LISP routine area. My work has this old LISP routine for rotating text which I modified to include MTEXT and blocks. I was hoping to change it solely for block rotation in another lisp routine. The way we have our blocks setup, I would need this LISP routine to add an additional 90 degrees to the matching rotation of the line. Could anyone please help me go about doing this? Every attempt at it has failed so far. Here is the code (defun rottxt_err (s) (if (/= s "Function cancelled") (princ (strcat "\nError: " s)) ) (setq *error* old_error) (princ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun rot () (setq leng (sslength txt_set) n 0 ) (while (/= n leng) (setq ent (entget (ssname txt_set n)) n (1+ n) ent (subst (cons 50 ang) (assoc 50 ent) ent ) ) (entmod ent) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun chk () (cond ((= ent nil) (princ "\nNothing found there.\nSelect a \"LINE\" to align. ") (setq ent (entsel)) (chk) ) ((/= (cdr (assoc 0 (entget (car ent)))) "LINE") (princ "\nNo \"LINE\" found there.\nSelect a \"LINE\" to align. ") (setq ent (entsel)) (chk) ) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun rottxt () (princ "\nSelect a \"LINE\" to align. ") (setq ent (entsel)) (chk) (setq ang (angle (cdr (assoc 10 (entget (car ent)))) (cdr (assoc 11 (entget (car ent)))) ) ) (rot) (setq ans (getstring "\nOK like this? y/n <y> ")) (if (= (strcase ans) "N") (progn (setq ang (+ ang pi)) (rot) ) ) (princ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun c:rottxt () (setq old_error *error* *error* rottxt_err ) (princ "\nSelect TEXT to rotate. ") (setq txt_set (ssget '((0 . "TEXT,MTEXT")))) (if txt_set (rottxt) (alert "No \"TEXT\" found.") ) (setq *error* old_error old_error nil txt_set nil leng nil ent nil ang nil ans nil n nil ) (princ) )
Lisp to add prefix to Layer State layers
thefootyguru posted a topic in AutoCAD Drawing Management & OutputHi all I need a lisp that adds a prefix to all layer state layers. So here is my situation, I work at a civil engineering consultancy who design mostly residential subdivisions. We have standard layers set up to keep everything consistent ie 'd driveway' or 'd back of kerb' ect and I have created a series of layer states for a range of of our standard drawings, ie 'set out plan' or 'detail plan'. My problem is these layer states will not work because when the drawing is xref'd in the layers now carry the prefix of the drawing name ie 'monbulk design xref/ d back of kerb'. As these layers are standard for every job we do I need a lisp that will either allow the layer state to ignore the drawing name prefix or will add the drawing name prefix to the layer state layer names. Thank you to everyone who stops by and reads this post. Any help will be very much appreciated.
Slope calculations in plan view
bmw1789 posted a topic in AutoCAD LTI am sure there is a way, whether it be lisp routine, or feature already within autocad, but I have yet to find it. What I want to do is be able to take a point that represents a grade and determine the elevation along a line to another point representing a lower or higher grade. Typically I would get the measurement between the points and just do the math. It would be great if you could select a point..be prompted to select (+ or -) and then enter a percentage, and then when you end the line it gives you a + number or a -number in which represents the rise or fall from point A to B. To take it a step further, not that I really need it, but would be cool, is if you could select points along that line and it give you an elevation for that point. Does anyone have any suggestions, or know of a lisp routine that does exactly this, and something similar. It would be huge in my career if such thing exists or can exist. Please point me in the right direction if you you of anything!!! Thank you, Matt
find and replace text inside dynamic blocks (lisp routine)
djeetn069 posted a topic in AutoLISP, Visual LISP & DCLI'm trying to find a lisp routine that searches the current drawing for a certain string and replaces that with the string of a variable already defined by the user (in this case the text to look for is "****" and the variable is called "offerte"). Not only in the Text, Mtext but also in the Blocks, Dynamic blocks, attributes and fields... Following code gets the job done but only for normal Text and Mtext. (defun tekstreplace (/ tss tdata) (setq tss (ssget "X" (list (cons 1 "****")))) (repeat (sslength tss) (setq tdata (entget (ssname tss 0)) tdata (subst (cons 1 offerte) (assoc 1 tdata) tdata) ) (entmod tdata) (ssdel (ssname tss 0) tss) ) ) Thanx in advance for any comments!
Lisp to plot multiple lines from a text file of start/end coordinates?
ktd27 posted a topic in AutoLISP, Visual LISP & DCLWe often collect ground penetrating radar data in a somewhat irregular grid of traverses at 90 degrees to each other (loosely east and north) and then put the information on a client's CAD basemap of the site. Our field notes consist of a line position and start and stop position for each line, so that I have a text file arranged as: LINE START STOP 50E 10N 40N 55E 12.5N 40N change direction 0N 50E 55E 5N 55E 50E I'd like to use the text file of these coordinates to automatically plot line segments. Right now, I'm using the line command to specify that my first point is 50,10 and my second point is 50,40...this is fine with small grids, but I just finished a project that consisted of 515 transverses and there must be something more efficient than what I'm doing! I assume it will require a lisp, which I have never attempted to write..any advice? This is my very first forum post, although I've found the community resources to be pretty much a lifesaver in previous projects. I tried a search for similar problems but haven't had much luck beyond finding a routine for auto plotting points. If I've miscategorized, or if this question has already been asked and answered, please let me know!
help using a pickbox to place blocks
mitchy_v posted a topic in AutoLISP, Visual LISP & DCLI have seen this done in the past at other firms. I am trying to insert a block on a wall using only a pickbox (one step). I am fairly new to lisp routines. I can get the block to insert fine, but I then am having trouble with the rotation. I would like the pickbox to determine the rotation automatically based off of the side of the line I pick, I currently have it asking for the rotation. If I pick on top of a line, the block faces up, if I pick the bottom, the block faces down.
Lisp routine to inert tag number text on to drawing in a box or rectangle
arbrier posted a topic in AutoLISP, Visual LISP & DCLI need a lisp routing which does the following: -Pick a point -Draw a leader to a 2nd point -Draw a rectangle or preferable a box with rounded ends in which I can insert text -Maximum of 15 characters (based on current text settings) -Leader will go any direction depending on 2nd point, but text is always same orientation -Do a WIPEOUT behind text box It would also be nice if the text is editable. Allen Brier
Automatic Rename Block with 'Part Ref decription'
lladoog posted a topic in AutoLISP, Visual LISP & DCLHello, I have been a lurker on these parts for a while, now i need help with a problem of my own. (I use autocad mechanical 2013) I have a cad drawing which contains 1000's of blocks, each with its own part reference within. As we use autodesk Vault and cad's design centre in tandem both the block name and partref description need to match. At present many block do not. What I am investigationg a a lisp type routine which will automatically rename all blocks in a drawing with its part reference description. As I am a novice with lisp I would like the forums help with this. Kind Regards, lladoog
LISP to Grab Layer from a block
rwsice9 posted a topic in AutoLISP, Visual LISP & DCLHey guys. I have a LISP I wrote this morning that asks for an insertion point, grabs the layer of the object, then draws a MLEADER on an associated layer. I have it working completely, except when a block is selected. Can anyone take a look at the code and help out? Thanks in advance! (defun c:wtags (/ p1 ) (setq oldlayer (getvar "clayer")) (setq os (getvar "osmode")) (setvar "osmode" 531) (setq p1 (getpoint "\nSelect wire to tag: ")) (setq ent (entget (car (nentselp p1)))) (setq wlayer (cdr (assoc 8 ent))) (if (= wlayer "F-ALRM-WIRE")(setvar "clayer" "F-ANNO-TAGS")) (if (= wlayer "F-ALRM-WIRE-SPKR")(setvar "clayer" "F-ANNO-TAGS-SPKR")) (if (= wlayer "F-ALRM-WIRE-INDC")(setvar "clayer" "F-ANNO-TAGS-INDC")) (if (= wlayer "F-ALRM-WIRE-DTCT")(setvar "clayer" "F-ANNO-TAGS-DTCT")) (if (= wlayer "F-ALRM-WIRE-PWR")(setvar "clayer" "F-ANNO-TAGS-PWR")) (if (= wlayer "F-ALRM-WIRE")(SETQ TAG "")) (if (= wlayer "F-ALRM-WIRE-SPKR")(SETQ TAG "S")) (if (= wlayer "F-ALRM-WIRE-INDC")(SETQ TAG "V")) (if (= wlayer "F-ALRM-WIRE-DTCT")(SETQ TAG "M")) (if (= wlayer "F-ALRM-WIRE-PWR")(SETQ TAG "P")) (command "_MLeader" p1 pause tag) (setvar "osmode" os) (setvar "clayer" oldlayer) )
How to become lisp-fluent?
hcostanzo posted a topic in AutoLISP, Visual LISP & DCLI'm posting this thread in the General Forum because I'm not sure where else to put it and being new to Cadtutor I'm still learning protocol. If I'm in the wrong area please let me know! Thank you! On to my question then. I've been reading through a large number of threads, not looking for anything in particular, just reading to learn new things (and learn I have!). I've noticed there almost always answers involving lisp routines. I understand what the lisp does but I know nothing about writing or launching them. Can anyone give me a recommendation of where to go to begin reading up on them? Please and thank you and much appreciation for any help.
Loading Layer State Manager with a lisp
ADSK2007 posted a topic in AutoLISP, Visual LISP & DCLHello all I have a lisp routine which will load Layer states and I have assigned it's command to a button - each layer state is assigned to a unique name and a button is created for it - The lisp routine loads a specific .las file into the drawing. For that, I have created a folder with all *.las files stored in it. The problem is that when I click on a button to turn on a layer state, it will apply the layer state to all viewports. How can I apply a layer state to only one viewport and not affect all viewports in all tabs? below is what I have (DEFUN C:d105 () (command "Layer" "A" "I" "J:/AutoCAD 2010/Lman/Development/105.las" "R" "105" "" "" "")) Thank you for helping
Automate running lisp on folder of files
laurell posted a topic in AutoLISP, Visual LISP & DCLHello, I'm an AutoLISP newbie and I need to iterate through a folder of .DWG files, running a lisp on each file one at a time with no prompts to the user. Can this be done in AutoLISP? Here is the lisp that will be run on each file: ;delete_layers_except (vl-load-com) ;(defun c:demo (/ aDoc name) (setvar 'Clayer "0") (repeat 4 (vla-purgeall (setq aDoc (vla-get-ActiveDocument (vlax-get-acad-object))))) (vlax-for itm (vla-get-layers aDoc) (if (and (not (wcmatch (setq name (vla-get-name itm)) "*|*")) (not (eq name "0")) (not (member name '("Fixture-Shapes" "CHECKLANE" ;"Arch-Wall-Interior (Construction)" ;"Arch-Wall-Interior" ;"Arch-Wall-Exterior" )))) (progn (vla-put-lock itm :vlax-false) (vl-cmdf "_.-laydel" "_N" name "" "_Y")) ) ) (repeat 4 (vla-purgeall aDoc)) (princ) ; ) ;explode_all ;(defun c:explodeall () (setvar "draworderctl" 0) (setvar "qaflags" 1) (command "._explode" (ssget "X" )"") (setvar "qaflags" 0) ; ) ;erase_hatch ;(defun c:nohatch () ;(if (or (ssget '((0 . "HATCH"))) (ssget "_X" '((0 . "HATCH")))) (setq ss1 (ssget "X" '((0 . "HATCH")))) (command "_.erase" ss1 "") ; ) ;plot ;(defun c:pp () (command "-plot" "no" "Layout1" "previous plot" "DWG to PDF" "" "" "") (princ) ; ) Thank you!!
LISP to move selected objects to a specified layer?
Dan Kitchens posted a topic in AutoLISP, Visual LISP & DCLHi peoples, I've got a new challenge: Is there a Lisp that moves selected objects to an exisitng, specified layer? I want to be able to select objects on the screen, type in a short command, and they automatically go to a certain layer (let's call it "Layer 1"). Having looked everywhere on the net, I can't find anything similar, and I don't know enough AutoLISP to be able to write it myself... Thank you in advance! Dan
Document control system
DebbieO posted a topic in AutoCAD GeneralI am trying to develop a document control system for my drawings. I am currently using AutoCAD 2011 but will soon move over to 2012. My previous employer had a great system using an excel spread sheet to input details that would then be updated into the drawings' annotated title block using a .csv file and the 'update' command to complete the job. How can I create this same system, can anyone help me please?