AutoCAD Visual LISP / AutoLISP :: Looping Through Attributes And Store Values?
Mar 19, 2013
I have an interesting challenge. I am tasked with updating old drawings. The only difficulty that I've run into with the old files are that the TitleBlocks are all done with all of the attributes are named "SPEC". There are 90 attributes. I'm really struggling with getting each attribute's value and then storing the value to a variable so that I can then put that value into a new TitleBlock. The old TB will be deleted to avoid future confusion in the file.
(To clearify, the old TitleBlock is in model space, while there are actually nine new TitleBlocks all in seperate paper space Layouts, and this program may have to run on hundreds of files.)
getting the values from the Old TB. I need them in order of first to last or last to first (either way will work since I have the variable names in a list that can be reversed if necessary.)
simple function to read through the block's attributes in order and store the attribute's value to a variable name in the seperate list (also in order)?
View 5 Replies
ADVERTISEMENT
Nov 4, 2011
I am using 2008 and I have a dynamic block with attributes that I want to insert with the below program and have the attritute values filled in automatically. I have done this with other programs in the past and they worked great with literally no problems. They were not dynamic blocks may be the reason this does not work. Why the block will not fill in the attributes like it should. Occasionally in my testing I see a message about "units" when I am inserting the block but I have my insunits set to 0. I have attached one of the blocks I want to use. I am thinking either you cannot do this because it is a dynamic block or there is a new variable that won't let it work.
(setq upisosym "L:/AcadUtilsJack/Programs/InsertIsoSymbols/ELL90BW_Flip_01" isosym "rat")
(setq upod "3" upsch "sched" upmatl "matl" uprat "400")
I found these two new variables and turn them off or 0 thinking they might be the problem???
(setvar "INSUNITSDEFTARGET" 1)
(setvar "INSUNITSDEFSOURCE" 1)
(defun c:JD ()
(setvar "attdia" 0)
(setvar "attreq" 1)
[Code] .....
View 9 Replies
View Related
Jun 3, 2013
I wrote a lisp, that grabs all text and assigns it a variable. Here's what it looks like:
(setq numbers (ssget "_X" (list (cons 0 "TEXT") (cons 1 "*")) ))
(sslength numbers)
(setq numb1(ssname numbers 0))
(setq enlist1 (entget numb1))
(setq texty (fix (caddr(assoc 10 enlist1))))
(setq value1 (cdr(assoc 1 enlist1)))
In this case length returns a value of 20. I can repeat this command 20 times and have all these variables but I don't think that is the best way. I do need the "y" value insertion point of the text. Line numbers are very important with what I do.In the end what I want to do is
1. sort through how ever many values sslength returns.
2. compare a blocks attribute "y" value insertion point with that of all the text values.
3. If both y values are equal then that blocks "tag name" will be changed.
Here is what I am doing on the block end with for reference:
(if (= texty fuwhole)
(setq funum1 (subst (cons 1 (strcat "FU" value1)) (assoc 1 funum1) funum1))
(entmod funum1)
)
fuwhole is the blocks "y" value insertion point.
funum1 is the blocks dxf group code
View 2 Replies
View Related
Aug 26, 2013
I am using AutoCAD 2011. I have a lisp that I have created/modified.
What it does:
Allows me to Select a layer that I call out and change its color properties back to bylayer.
(i primarily use this when i am cleaning up my drawings, I turn them all to gray with another command i have then i run this one to find all the entities on that specified layer)
What i am trying to do:
I would like this command to do a loop. So say i type in a layer name that does not exist, instead of running through the rest of the command i want it to revert back to "specify layer name" until the correct name is entered for that layer.
Here is the lisp:
(defun cLL ()
(setq varLayer (getstring t "
Specify Layer Name: "))
(sssetfirst nil (ssget "X" (list (cons 8 varLayer))))
(command "change" "p" "" "p" "c" "bylayer" "")
(princ)
View 9 Replies
View Related
Jan 9, 2013
I have created the following keyboard macro:
^C^C_.MOCORO \ C X R
It launches move-copy-rotate, allows me to pick 2 items (in my case a electrical symbol and its associated tag), copies the entities to the desired location then rotates. It works perfect, however after the rotate I need to repeat the process indefinitely starting before the "C".
I know that I can usu an asterisk at the beginning to loop the entire macro, however I don't want to re-select, just continue on with the MCR function using the already selected entities. Any GOTO function in macros?
I suspect that I might need LISP for this but I not familiar with writing that code.
View 4 Replies
View Related
Jul 18, 2013
I have an attribute blocks and this att block has two tag values , is there a simple code for to change 1st tag values automaticly according to 2nd values ?
for example :
1st tag (50x50) - 2nd tag ( 100 ) ==> 50x50-100
if i enter 201 valuse to 2nd tag then 1 st tag has to change as 100x100
if i enter 501 valuse to 2nd tag then 1 st tag has to change as 150x510
I attached a jpg file for explain much better
View 9 Replies
View Related
Jul 29, 2005
Say I have a block that contains two attributes, one contains a value that is a number and another contains a value that is letters. I have many of these blocks placed in a drawing, could you create a lisp that would return the sum of the number value and return it to the command line along with the letter value. Something like this:
Sum--------Item
128 RP
389 TD1
2389 SP4
View 9 Replies
View Related
Jul 17, 2013
Lisp or lisp code for sum attribute tag values and paste result to an another attribute block tag?
i attached jpg for explain to what i want to do .
View 4 Replies
View Related
Oct 26, 2012
Any routine where I could keep picking on my exit arrow blocks (showing how many persons exiting from each space) one-by-one and the program would add up the numbers. For example I pick on blocks with numbers of 2, 4 & 3 and I would get 9.
View 3 Replies
View Related
Nov 18, 2011
I have this snippet that inserts a block “Exit_Arrow”. The block has one attribute. Is it possible to force the attribute to remain at “0” rotation regardless what angle the bock is rotated?
(defun C:Exit_Arrow (/ LA DS)
(setq LA (getvar "clayer"))
(setq DS (getvar "dimscale"))
(C:TTEXT)
(command "._insert" " Exit_Arrow " pause DS "")
(setvar "clayer" LA)
(princ))
Is it possible to create blocks whose attributes remain at "0" rotation regardless the host block's rotation?
View 9 Replies
View Related
May 16, 2013
I isolated 3 attributes as you can see with my code. My object is too take the value of blkDESC1 and set it as blktag, and then take blkDESC2 and set it as blkDESC1, and erase blkDESC2.
(defun c:aup (/ dxf ent dxf1 ent1) (defun dxf (code ent) (cdr (assoc code (entget ent))))
(progn (if (and (setq ent (car (entsel "
Select an Attributed Block: ")))
(eq "INSERT" (dxf 0 ent))
[code]........
View 1 Replies
View Related
Jun 17, 2012
I need to wright a routine in autolisp that selects all 3Dpolylines with the same vertex Z value.Qselect as no transparent mode and filter doesn't work.
View 7 Replies
View Related
Aug 24, 2011
Here's my situation:
I have a block named "WIDGET-A". And in that block are (4) attribute tags whose names are:
"ID"
"TAG01"
"TAG02"
"TAG03"
The user will be prompted to pick the value displayed at any of the "TAG##" attributes - they will select the attribute tag they want (we don't know which one it is, we just want to assign that value of the attribute tag they clicked on to a variable called "VAR2".
Now, what we also want AutoCAD to evaluate, behind the scenes, is the value of the attribute tag named "ID" which we know always exists in the block and then assign that value to a variable called "VAR1".
Is there a way for AutoCAD to do this all from only a single user pick on top of an attribute value, in a block whose name isn't always going to be 'WIDGET-A' either.... But the block, whatever it's name, will always have the attribute tag "ID" with a value in it, and we always want to capture the value of whatever attribute tag within the block that the user clicked on.
View 2 Replies
View Related
Jan 3, 2012
how to extract value X Y Z of point p3 p4
(defun c:test ()
(vl-load-com)
(setq actdoc (vla-get-ActiveDocument (vlax-get-acad-object)))
(setq objm (vla-get-ModelSpace actdoc))
(setq obju (vla-get-Utility actdoc))
(setq oldhigh (getvar "Highlight") oldsnap (getvar "Osmode") oldblip (getvar "BlipMode") oldecho (getvar "Cmdecho") );setq
(setvar "Highlight" 0) (setvar "Osmode" 517) (setvar "Cmdecho" 0) (setvar "Blipmode" 0)
[code]....
View 4 Replies
View Related
Mar 21, 2013
This time I'm wrestling with getting the values from multiple blocks. The blocks all have the same name but at least the attributes have names this time. Each block have exactly 4 attributes, like: att1 (a number representing chronological order), att2 (some data), att3 (the actual date as a string of when the data was added), att4 (some more data)
I need to get and store the attribute's values. I was hoping to make a selectionset of the blocks and step through using the chronological order number.
At this point I have tried several combinations of foreach and ssget "x" (list (cons 2 MYBLOCK)), but I keep getting errors that I'm sure are telling me that I'm not passing the correct information to the function for iterating through. I'm banging my head.
(DEFUN c:GFOR (/ ATTLST REVBLK CNT CNT1 BLK RBLK ATTVAL ATT REV#)
(SETQATTLST(LIST "R#" "INIT" "DATE" "DESC")REVBLK(ssget "x" (list (cons 0 "INSERT") (cons 2 "REVISION")))CNT0CNT10 )
(vlax-ldata-put "dict" "RevTotal" (BLKCNT "REVISIONS")) (FOREACH BLK REVBLK (SETQ RBLK (ssname BLK CNT1)) (setq ATTVAL (mapcar '(lambda (x) (vla-get-TextString x)) (vlax-invoke (vlax-ename->vla-object RBLK) 'GetAttributes))) (foreach ATT ATTLST (SETQ REV# (STRCAT "REVISION" (1+ CNT)))
(vlax-ldata-put "dict" REV# (member ATTVAL)) (setq CNT (1+ CNT)) ) (SETQ CNT1 (1+ CNT1)) ) (PRINC))
View 9 Replies
View Related
Dec 16, 2011
I often have DXF files that contain very many short (10 digits or less) instances of text, and only a few long instances of text (11 digits or more)....
I would like to use AutoLISP to delete all of the short text in my DXF file, but leave the longer text.
View 9 Replies
View Related
Jun 17, 2013
I need a lisp sub-function that can empty all attributes of a specified dynamic block. The idea being that the specified block contains data that changes often and in order to repopulate the block's attributes with new data to replace the old I wish to just blank out the old data first, because it's possible that the new data may not utilize as many attributes and all of the old data must be removed.
The thing is the block I'm after is on several layouts, CTABs and they all need to be wiped clean.
View 9 Replies
View Related
Jun 2, 2004
lisp routine that will add together the values of text entities? For instance, if I have a big parking lot and each section is labeled with the number of spaces, I could pick the texts and it would add all the numbers together to give me a total. Right now I export to excel to do this. I have quite a few situations where this would be handy, not just for parking spaces, so I really just want a lisp that will add all my selected numbers.
View 9 Replies
View Related
Jan 18, 2012
How to connect to MySQL database and insert data from a set of blocks containing attributes?
Something like:
block 1:
- x coordinate;
- y coordinate;
- handle;
block 2:
- x coordinate;
- y coordinate;
- handle;
block 3:
- x coordinate;
- y coordinate;
- handle;
I've just got the second part (retrieving info from the blocks), but when it comes to connect to the DB I'm completely lost.
For the DB I'm using XAMP for Windows, thus using localhost, user ('user123'), pass ('pass123') and table ('table123'). The table has ID (PriKey and AutoInc), px, py and hdl fields.
View 9 Replies
View Related
Jan 11, 2014
Would you tell me why [b]vla-FullName[/b] returns a path in LOWERCASE (except of "Program Files" and other special folders) ??
View 9 Replies
View Related
Sep 8, 2011
I have a 2 point LWPOLYLINE that has the following coordinates at its end point when I 'ID' the point.
Command: id
Specify point: end
of X = 709369.3214 Y = 7153039.9690 Z = 269.2143
However if I use..
(vlax-safearray->list (vlax-variant-value (vla-get-coordinates (vlax-ename->vla-object (car (entsel))))))
I get this
(-450567.0 269.288 -450570.0 269.214)
and if I 'dump' the object..
; Coordinates = (-450567.0 269.288 -450570.0 269.214)
; Document (RO) = #<VLA-OBJECT IAcadDocument 09855674>
; Elevation = 7.17399e+006
I don't have a clue where the '-450567.0' is coming from.
I'm in Model Space in 'World' UCS, and I'm confused.. why does the 'ID'd' value not reflect whats going on when I use the vla-get-coordinates approach.
There are many other LWPolylines within the same model that behave normally.
I've attached the drawing (I think!)
View 7 Replies
View Related
May 9, 2013
What I am trying to do is create a selection set of the "y" values of text. I've started by pulling out all the text on the drawing, but I need it to continue to grab only the "y" values of the text on the drawing.
(setq alltext (ssget "_x" (list '(0 . "TEXT"))
)
)
I've tried a bunch of different things but I am still new to lisp.
View 5 Replies
View Related
Jul 23, 2013
I cannot determine what triggers this but the command line has stopped returning values from lisp expressions.
eg. If I type (setq fred "Hello") I would expect to see "Hello" returned. I am getting nothing. Similarly if I type !fred I get nothing. If I restart AutoCAD the problem goes away. The after some time it happens again. Is there a toggle or switch or system variable that I'm not aware of?
View 4 Replies
View Related
Aug 6, 2013
I have a block named "WD_MLRH". There are 3 specific attributes which I want to change in it. The attribute names are.
RUNGCNT, RUNGDIST and RUNGFIRST.
RUNGCNT will = 20
RUNGDIST will = 1.0 (or 1 will suffice)
RUNGFIRST will be decided by a user input.
Something along the lines of...
(setq RUNGFIRST (getint "Enter first rung number: "))
I'm sure this is completely wrong, but i hope that portray what I'm trying to accomplish.
View 9 Replies
View Related
Jan 5, 2012
I've been trying tons of different solutions to solve this problem: insert a block that has an attribute which happens to be the last object id.
This is the best code I tried so far but without any succss.
(defun c:q1()
(command "_.PLINE")
(while (= (getvar "CMDNAMES") "PLINE")
(command pause)
[Code] .....
View 9 Replies
View Related
Sep 12, 2013
I have searched the web and the Autodesk Discussion Group for a LISP Routine that allows me to convert all attributes in a drawing to Layer 0 but i have had no luck. It would be great if the LISP could edit xrefs as well although not sure if this is possible.
**BATTMAN command will take too long for the hundreds of blocks, xrefs and drawings i need to edit.
View 2 Replies
View Related
Mar 1, 2013
I need a function that will allow me to do a "divide" with blocks but I need the single attribute to remain intact.
I need the blocks to align with object and keep the attribute. I did get it to work with constants but the function that I need to run next failed because of the constant. My variable is preset and locked.
View 9 Replies
View Related
Oct 16, 2012
I downloaded a lisp routine that will align block attributes. The problem is I can only select the attributes one at a time. I'd like to be able select multiple attributes using the selection window or a crossing window, but I haven't had much luck. If you use the AEATTSHOW command, it give you a prompt to "select using window" by pressing W. I'd like to have the same functionality for my Align attributes routine.
Below is the portion of code I currently have to select attributes one at a time:
;* Select all attributes to align with the parent selected above and add the attribute entname and the block
;* entname to a list in format ( (AttrEntName BlkEntName) (AttrEntName BlkEntName) (AttrEntName BlkEntName) )
;*
while (/= TempAttr nil)
(setq
TempAttr (nentsel "
Select Attributes to align: ")
[Code] .........
View 5 Replies
View Related
Oct 11, 2011
I have to go through quite a few drawings and extract the attribute vales of the whole drawing and then a subset contained within a couple of polylines.
The whole drawing is Ok as I can use at out or the data extraction, but its the ones contained within a polyline. How do I do that?
View 9 Replies
View Related
Jun 17, 2012
I need to change the value of some tags in a title block on multiple drawings. I tried using Lee Macs attribute changer [URL]. It works fine but not when tags have the same name.
I then looked at this code - [URL]
Idea was to change the tag names then use Lee Macs program. It too fails when there are duplicate tag names. It changes all tags not just the one I want.
In the the title block I have 3 tags with the name "NAME" but only one will have the value I'm looking to change. If I could place an IF statement some where in the above codes (or another code altogether) to instruct that IF the tag name is "NAME" with value "Dennis (BSL)" then change either the tag name or the value to "Daniel"
Im pretty bad at this programming stuff but with so many drawings I need a easier, automated way of doing this.
View 1 Replies
View Related
Apr 24, 2012
There is a BLOCKA that I'd like to extract its attributes - Tag and Color - into an external format (excel). There after, I'd like to import it into the drawing and based on its color attribute value, change the value to that color in the drawing.
View 7 Replies
View Related