Search the Community
Showing results for tags 'autolisp'.
-
Hello all you CAD Guru's out there! I am currently having trouble creating a lisp and am in desperate need of experienced guidance. I am trying to make a command such as (defun C:lo () (command "layer" "on" "*" "t" "*" "")) which turns all layers on, however i need the layers Circuit-1 through Circuit-12 to be untouched. For example if i have circuits 5 through 12 turned off, frozen, whatever state they may be in needs to not be affected by the command to turn all layers on. Basically I would like to make a command that turns all layers on with the exception of layers Circuit-1 through Circuit-12 I started to write a code based on layer groups which I though may be the way to accomplish this task. I.E. make a layer group of all layers EXCLUDING or removing Circuit 1-12 and thaw or turn on all of that layer group. I am unsuccessful in thawing the "new layer filter" using code. (I can however right click on the group and change its visibility to thawed and that works.) (defun c:TESTER (/) (COMMAND "-LAYER" "FILTER" "NEW" "GROUP" "" "*" "NEW LAYER FILTER" "") (COMMAND "-LAYER" "FILTER" "EDIT" "NEW LAYER FILTER" "DELETE" "CIRCUIT-1" "DELETE" "CIRCUIT-2" "DELETE" "CIRCUIT-3" "DELETE" "CIRCUIT-4" "DELETE" "CIRCUIT-5" "DELETE" "CIRCUIT-6" "DELETE" "CIRCUIT-7" "DELETE" "CIRCUIT-8" "DELETE" "CIRCUIT-9" "DELETE" "CIRCUIT-10" "DELETE" "CIRCUIT-11" "DELETE" "CIRCUIT-12" "") (command "-layer" "t" "new layer filter" "")) Where have I gone wrong?
-
Hello, Im using AutoCAD, AutoCAD Mechanical 2009 and Mechanical Desktop 2009 I have parts that have a material assigned to them through the 'MASSPROPS' dialog box. When assigning the material to a part, material properties associated with that part are assigned as well. Is there a way to either remove the material assignment or create a "dummy" material with material property values set to 0 and assign this new material to the part using AutoLISP? If not AutoLISP, is it possible using any other code type?
-
Routine to read Excel with unknown number of lines
undermustang posted a topic in AutoLISP, Visual LISP & DCL
Hey guys, I am writting a routine to read a excel file that contains a column with the number of the element, a column with the x's coordinate and a column with the y's coordinate. I need a way of making a loop to read whatever elements are filled by the excel's user and get this values in vectors so they can be used after. Is there anyway of doing that? Thank you very much! -
Hello, Could anyone help me let this LISP work. The lisp should go to the layer you choose (by pressing 1 or 2) when in a *DIM* command. After placing the dimension the layer should go back to the layer it was before selecting a *DIM* command. This is the code now. ; AFKORTINGEN VAN DE VARIABELEN ; ADDL Automatic dimension layer ;**************************************************************************** (defun CommandReactor:Start () (or *CommandReactor* (setq *CommandReactor* (vlr-command-reactor nil '( (:vlr-commandcancelled . CommandReactor:CommandEnded) (:vlr-commandended . CommandReactor:CommandEnded) (:vlr-commandfailed . CommandReactor:CommandEnded) (:vlr-commandwillstart . CommandReactor:CommandWillStart) ) ) ) ) (prompt "\nCommand reactor loaded. ") (princ) ) ;**************************************************************************** (defun CommandReactor:CommandEnded (rea cmd) (if (and *OldClayer* (wcmatch (strcase (car cmd)) "*DIM*") ) (progn (setvar 'clayer *OldClayer*) (setq *OldClayer* nil) ) ) ) ;**************************************************************************** (defun CommandReactor:CommandWillStart (rea cmd) (if (wcmatch (strcase (car cmd)) "*DIM*") (progn (setq *OldClayer* (getvar 'clayer)) (vla-add (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) ; Kiezen van de DIM layer (setq ADDL 0) (while (or (< ADDL 1) (> ADDL 2)) (setq ADDL (getint "\nInput the DIM layer: Dim. (1), Dim. front (2): "))) ) ; end while ;ADDL = 1, Dimension layer (if (= ADDL 1) (progn (command "_layer" "_m" "S-DIMENSIONS" "_c" "3" "" "") ); progn ); if (=ADDL 1) ;ADDL = 2, Dimension front layer (if (= ADDL 2) (progn (command "_layer" "_m" "S-DIMENSIONS front" "_c" "3" "" "") ); progn ); if (=ADDL 2) (setvar 'clayer *OldClayer*) ) ) ) ;**************************************************************************** (CommandReactor:Start) (princ) ;**************************************************************************** ;**************************************************************************** ;**************************************************************************** ;**************************************************************************** Please help! Thanks!
-
Trouble with xyz coordinate import LISP
philnesterovic posted a topic in AutoCAD 2D Drafting, Object Properties & Interface
Hi all, I am using the attached lisp to import xyz (PNEZD) coordinates into Autocad 2015 with their points numbers and descriptions. The lisp works great, the only problem is that when all the points are put in, I can't change the colour and layer of the attached descriptions and elevations. The points themselves will change colour and layer, but we can't get the writing to move to those same layers. I'm not sure if this requires working on the lisp itself, or if it is something that can be fixed in a setting in Autocad, but I'm definitely stuck! Any help would be greatly appreciated. Thanks! pointsin-v1.0.13.zip- 2 replies
-
- lisp
- coordinates
-
(and 3 more)
Tagged with:
-
Hello All, This is my first post on CADTutor forum. This is a pretty extensive request, however I am looking to essentially do this exact routine: https://www.youtube.com/watch?v=FLOif87iLMw This automated process of creating the stepped boundaries to angled polylines based on the size of a panel, as well as automatically drawing panels into the drawn boundaries, etc, is everything that I need. Creating profile views, cross sections, etc. The question is, are there any AutoCAD commands that would expediate this programming or do I need to brute force this and essentially create a lisp routine from scratch? The more basic the steps, the easier I would be able to understand because I am relatively new to AutoCAD in general. In general where do I start? Thank you in advance for any help!
- 2 replies
-
- cross sections
- automation
-
(and 2 more)
Tagged with:
-
I am trying to write an autolisp program to insert a row of 20 blocks in a drawing, (one over the other), then insert attributes for each from a row in an Excel file. I am using Jeffrey Sanders' "GetCells" function. The Excel file is "RO-16.xlsx" Here's what I have done so far: (defun Addenters ( / cnt yval) (setq cnt 1) (setq yval 0) (setvar "osmode" 0) (load "getcells.lsp") (while ( ( (setq *doc* (vla-get-activedocument (vlax-get-acad-object))) (command "insert" "C:\\07509\\BD" (strcat "0," (itoa yval))"1" "1" "04" (getCellsFunction "C:\\07509\\RO-16.xlsx" "ALLOCATED" "K2") ) (setq cnt (1+ cnt)) (setq yval (+ 8 yval)) ) ) ) So the first attribute, "PLC" is read from cell K2 in the Excel file. There are 7 attributes altogether. Is there a more compact way to do this (with a list or array). I want to avoid having a long line (which is answering to the Autocad prompt for block attributes) which looks like: (getCellsFunction "C:\\07509\\RO-16.xlsx" "ALLOCATED" "L2"), (getCellsFunction "C:\\07509\\RO-16.xlsx" "ALLOCATED" "M2") and so on.
-
I keep getting an error when I use getpoint. When I look at SPT or EPT it's nil (defun c:STUD15 (/ SPT EPT Wallth Ceilinghg) (setq SPT (getpoint "\nPick start of wall.....")) (setq EPT (getpoint "\nPick end of wall....."));at this point I get...error: bad argument type: 2D/3D point: nil (setq Wallth (distance spt ept));length of wall (setq Ceilinghgt 96.0) (setq UnflrBeamhgt (+ Ceilinghgt 0.5)); Can someone explain what I am doing wrong. Thanks
-
Generate mutiple AutoCAD drawings from data stored in an Excel file.
Berbero posted a topic in AutoLISP, Visual LISP & DCL
Dear smarties I read a few articles here and there regarding a way to generate multiple drawings from an excel file, but no one had explained step by step on how to do it. So, I am lost half way. I am very new to this kind of things, but I will try to follow, so please go slow on me. here is what I want to fix: 1. I need to automatically generate 10 drawings both in dwg and pdf copied into a folder. 2. All the variables (VAR1 to VAR3) are stored in an excel file. refer to the attached files as an example. 3. I only need to create one original drawing, which will be used to generate all the 10 drawings. Please help EXCEL-VAR.xls ORIGINAL-DWG.dwg -
I’m in the process of updating nearly 400 blocks. I have to change the layer and override the color of one attribute. My test on the first block failed. It's just been a while and I can't remember what I'm missing. My attempt for changing the first one: (progn (setq e (car (entsel )) d (entget e) n_e (entnext e) n_d (entget n_e))) un_d (subst (cons 8 "SYM") (assoc 8 n_d) n_d) un_d (append un_d (list un_d (cons 62 141))) ) (entmod un_d) (entupd (cdr (assoc 330 un_d))) ) I've also tried: (command "_.attsync" "_select" n_e "" )"_Yes") note: as I step through the block entities I will be testing to insure I've got the right block with: (and (= (cdr (assoc 0 n_d)) "ATTRIB") (= (cdr (assoc 2 n_d)) "SIZE") (/= (cdr (assoc 8 n_d)) "SYM") )
-
Very usefull tool to transform 3D Faces To Solid ! ...or a 3D terrain model to a sectionable solid http://www.sharedengineering.com/index.php/13-download/autolisp/20-autolisp-to-transform-3d-faces-to-solid >>> http://www.sharedengineering.com
-
DXF 2 doesn't match block name in properties window
WPerciful posted a topic in AutoLISP, Visual LISP & DCL
I tested the code below by selecting one type of block, but instead of returning the name it returned *U36 (cdr (assoc 2 (entget (car (entsel "\nSelect a buble: "))))) -
Hello everybody! Few programmers (including myself) decided to create a website with free (for now) AutoLisp programs and scripts for Autocad. Well, we have few questions to define where to start. Your answers would really help. - Do you use programs (scripts) in your work? - Which program (script) you would use but do not have. Best regards, ... PS Link to website asap
-
Hi all I really do not have much experience with AutoLISP but I would like to write a script that allows me to: 1. Create a new DWG 2. Draw a line from a set of existing coordinates from a .txt file 3. Save this drawing in a specified location 4. Close the drawing 5. Rinse and repeat until all of the .txt files have been drawn. Basically this will be used for hundreds of .txt files containing coordinates to draw the cross-sections of a tunnel. Is this something that can be done? As after hours of research I have only managed to be able to draw one cross-section using a batch file but haven't been able to close the drawing or save it. Thanks in advance for any help
- 13 replies
-
- autolisp
- autocad 14
-
(and 2 more)
Tagged with:
-
I have thousands of sketches in autocad and need to calculate the weight for each sketch. The sketches are all in 2D format. The sketches are of shafts with different diameters and lengths. Each shaft has a major diameter and then a varying number of steps each with its own diameter and length. The dimensions of most of the sketches are associated to objects in the sketch; however, there are some sketches with non-associative dimensions. Is it possible to write an AutoLisp program to go through all of these sketches and pull the diameter & length of each shaft (including each diameter and length of each journal step) and then use the information to calculate volume and weight. Currently, I have an excel program that will calculate the weight if I type in all the length and diameter dimensions of the objects. The task is repetitive and time consuming. Writing a program may help expedite the task. Any advice would be helpful. Thanks
- 6 replies
-
- properties
- autolisp
-
(and 1 more)
Tagged with:
-
Hi, I am new to this forum, can anybody suggest a good autolisp tutorial for beginners??? thanks in advance
-
Lisp to draw a polyline around the extents of a set of polylines
acheok24 posted a topic in AutoLISP, Visual LISP & DCL
Hello everyone, This is my first post on here so please forgive my ignorance if this is posted somewhere else. I am trying to create a lisp that will draw a polyline around a set of polylines, essentially connecting all start points and all endpoints. I just started writing lisps last week so I'm pretty new to this stuff, but the way I'm thinking about doing this is selecting all the polylines, filter out closed polylines that could be in the set, run a while loop to create a list of start points and end points, use repeat to draw a line from start point 1 to start point 2 to start point 3 etc. and then doing the same with the endpoints, and finally join all these lines into one polyline. Let me know what you all think. Thanks in advance. -
Hello everybuddies, I am new to lisp, so please for your advise. I want to pick an existing multi-segment polyline and use it as a selection fence (ssget "_F") As far as I understand I miss a simple piece of code that lists the points of the polyline in a way that ssget can accept them as a list of points to define the fence. (setq POLY (entsel "\n Pick a Fence Line crossing your beloved entities:")) ****POLY---->(please help!)----->POINTLIST**** (setq ss (ssget "_F" POINTLIST ) ) Thanx in advance
- 13 replies
-
- points list
- fence
-
(and 2 more)
Tagged with:
-
Centre of Gravity of a group of Open or Closed Polylines
neodesigner posted a topic in AutoLISP, Visual LISP & DCL
I work as a boat designer and often require calculating total length of polyline & centre of gravity (both open & closed polylines). I have a snippet below to show the sample code I am currently using - this only works with a group of lines - it doesnt work with polylines. Currently everytime I have to calculate the CG, I have to copy the polyline over, explode it & select the lines to calculate the CG. The logic is as follows - assuming we have 3 segments on the polyline(A,B,C) : Centre of Gravity of Polyline = (Len of A multiplied by Centroid of A + Len of b multiplied by Centroid of B + Len of C multiplied by Centroid of C) divided by Total Length of polyline I am new to LISP & although have some background in other programming languages, find it is relatively difficult to write the code, the syntax being very different. I found a similar code ( TotalADD Total Addition by Andrea Andreetti & modified to come to the below code). It would be ideal if I can select a group of polylines (using select similar) and run the command to get a text table in autocad with CG & total length calculated for set of polylines on different layers. But I am not sure how this can be achieved. Would you be able to help or am I asking for too much ? any guidance will be much appreciated. (if (eq (vla-get-objectname n) "AcDbLine") (progn (setq itemlinelength (+ itemlinelength (vla-get-length n))) (setq StartPoint(vlax-safearray->list (vlax-variant-value (vla-get-startpoint n)))) (setq x1 (car Startpoint)) (setq y1 (cadr Startpoint)) (setq EndPoint(vlax-safearray->list (vlax-variant-value (vla-get-endpoint n)))) (setq x2 (car endpoint)) (setq y2 (cadr endpoint)) (setq xmid (* (+ x1 x2) 0.5)) (setq ymid (* (+ y1 y2) 0.5)) (setq xmom (* xmid (vla-get-length n))) (setq ymom (* ymid (vla-get-length n))) (setq itemxmoment (+ itemxmoment xmom)) (setq itemymoment (+ itemymoment ymom)) ) ) (setq totxcg (/ itemxmoment itemlinelength)) (setq totycg (/ itemymoment itemlinelength)) (setq tlength (rtos itemlength 2 ) (setq totxcg (rtos totxcg 2 ) (setq totycg (rtos totycg 2 ) (acet-ui-status (strcat "Length: " tlength "\n" "X CoG Pos: " totxcg "\n" "Y CoG Pos: " totycg "\n" ) -
We have many geo-referenced raster images of a drawing map. Now we are manually inserting them in drawing where required. Is there any way that if we click anywhere in the drawing the image of that place should be insert.
-
Hi All, It's been some time since I have been using AutoCAD and all the lisp controls I learnt have disappeared from memory. I basically only using CAD as a tool for cleaning files to link into Revit and so have been setting up a routine to run through all the clean and purge utilities to speed this up and remove the repetitiveness of using the same sequence of commands over and over. One utility I'd like to add into my lisp is "Flatten.lsp" I have found how to run it but is there anyway I can pre-answer the prompts? i.e. Flatten All (Return) Yes? Thanks in advance. Mark
-
How can we merge two adjacent polygons or two adjacent closed polylines using lisp or any tool in autocadmap 2004.
-
How can i write a text integer more than 32767 using lisp. when i type 123456 the message is "Requires an integer between -32768 and 32767"
-
Hey Guys, Its been a awhile since I have done any Autolisp programming and I am stuck... I am using a conditional statement to generate a number i.e. 1.625 and then I want to add that to the Z elevation of a point but it keep erroring out at this line. I have spent about an hour and half looking back thru resources and haven't been able to find the correct syntax. This is the line erroring out: (setq NEWPT1 (APPEND (LIST (CAR USRP1) (CADR USRP1)) (+ (CDDR USRP3) TRAP_Z_OFF))) ; ERRORS OUT HERE Here is the full code. (defun C:droptrap() (command "UNDO" "BEGIN") (initerr) (setvar "lunits" 2) (setvar "luprec" 4) (setvar "attreq" 0) (command "UNDO" "BEGIN") (setq OLDCMD (GETVAR "CMDECHO")) (setvar "CMDECHO" 0) (setq OLDOSMODE (GETVAR "OSMODE")) (setvar "OSMODE" 0) (setq OLDORTHOMODE (GETVAR "ORTHOMODE")) (vl-load-com) (setq thisdrawing (vla-get-activedocument (vlax-get-acad-object))) (initget "1 2 3 4") (setq TRAP_TYPE (getkword "\n Select trapeze type: ([1]:1-5/8x1-5/8, [2]:1-5/8x1-5/8 B2B, [3]1-5/8x13/16, [4]1-5/8x13/16 B2B): ")) (if (or (= TRAP_TYPE "1")(= TRAP_TYPE "3")) (progn (initget "1 2") (setq FACE_DIR (getkword "\n Trapeze opening up or down?: ([1]:UP [2]:Down): ")) ) (setq FACE_DIR "1") ) (cond ((and (= TRAP_TYPE "1")(= FACE_DIR "2")) (setq TRAP_Z_OFF 1.625)) ((and (= TRAP_TYPE "3")(= FACE_DIR "2")) (setq TRAP_Z_OFF 0.8125)) (T (setq TRAP_Z_OFF 0.0)) ) (setq blockname "TRAP-XDATA-T1_1.625") (setq USRP1 (GETPOINT "\n Select center point of rod 1: ")) (setq USRP2 (GETPOINT "\n Select center point of rod 2: ")) (setq USRP3 (getpoint "\n Select elevation of attachment point: ")) (setq NEWPT1 (APPEND (LIST (CAR USRP1) (CADR USRP1)) (+ (CDDR USRP3) TRAP_Z_OFF))) ; ERRORS OUT HERE (setq NEWPT2 (APPEND (LIST (CAR USRP2) (CADR USRP2)) (+ (CDDR USRP3) TRAP_Z_OFF))) ; ERRORS OUT HERE TOO (setq MIDPT (POLAR NEWPT1 (ANGLE NEWPT1 NEWPT2) (* (DISTANCE NEWPT1 NEWPT2) 0.5))) (setvar "ORTHOMODE" 1) (COMMAND "-INSERT" BLOCKNAME MIDPT "1" "1" NEWPT2) (command "rotate3d" (entlast) "" 2 NEWPT1 NEWPT2 90) (setvar "OSMODE" OLDOSMODE) (setvar "CMDECHO" OLDCMD) (setvar "CLAYER" LAYNAME) (COMMAND "UNDO" "END") (PRINC) ) The code is unfinished so I am trying to keep it working as I build it.
-
Hey guys, I'm working on a piece of code where I need the lisp to look up a custom property that's set and extract it. The problem I am having is that we updated our templates within the last two years so this piece of code doesn't work properly with some of the older drawings we have. I want it to assign the variable a value if it can't find it, but I don't know how to get around the automation error. Here's my attempt but I am at a loss as to what to do. (defun c:test (/ acadobject acaddocument dprops pp pp#) (setq acadObject (vlax-get-Acad-Object)) (setq acadDocument (vla-get-Activedocument acadObject)) (setq dProps (vlax-get-property acadDocument 'Summaryinfo)) (vla-getcustombyindex dprops 72 'PP 'PP#) (if (= PP# nil) (setq PP# "PLXX-X-XX-") );;end if );;end defun Here's the error I get. Error: Automation Error. Out of range FYI: The name of the custom property is Plot Plan Thanks in advance!
- 3 replies
-
- automation error
- autolisp
-
(and 1 more)
Tagged with: