AutoCAD Visual LISP / AutoLISP :: Attribute Height Is Changing Each Time Routine Is Run With An Annotative Block
Apr 30, 2012
I only do programming when absolutely needed so it usually only happens every couple years. I wrote this routine to count nested blocks inside of dynamic blocks to count parking spaces. The routine worked fine but was relying on the ltscale to scale a block containing an attribute for the total number of spaces. I want to update the routine to use an annotative block so the scale doesn't have to be set. I changed my block containing the attribute but now when I run my routine, the attribute height gets changed each time the routine is run. The text just gets larger and larger. Here is the portion of the routine where the attribute info is gathered and updated with the new value for that attribute. If you need the entire routine, I can post it with a slight modification so it will work outside our network.
(defun updateattrib ()
(setq CNT 0) ; sets count to 0
(while (< CNT (sslength ss)) ; starts loop while CNT is less than the number of objects in the group
[Code].....
I am running this in Civil 3D 2010 but will want it to work in 2013 so if the solution will only work in 2013, that is fine with me.
I'm trying to find a routine that will look for ABC block and updates its NUM attributes depending on what's shown in the DESC attribute. There are about 5 of these ABC blocks in a drawing. Block ABC has 2 sets of attributes: DESC and NUM.
When run, it will look at the value of tag DESC, if it contains value XXX, then it will change the NUM value to 1111. And if DESC contains value YYY, then it will change the NUM value to 2222.
Any lisp routine for changing the text width of all the attributes in a block globally. I want to change it from 1.0 to 0.8. I have attached a symbol where the attritube tags will be the same.
I am trying to create a lisp that prompts you to select multiple lines, and then prompts to enter a name of a block you wish to use. With that information use the measure command to place the entered block along the selected lines with the spacing set to the value in the blocks attribute.
I have a lisp that does most of this with the exception of the extracting the value of the block size to use as the distance between blocks, the current lisp just prompts for the distance.
I have a lot of blocks with different spacing so it is hard to remember the distance.
Here is the current Lisp i use:
(defun c:MEB (/ blk ss l name) ; TharwaT 04. 04. 2011 (if
select all blocks on certain layers in a drawing, check attribute CIRCUIT in each block if it starts with MS then attribute CONTROL = switched. I hope thats clear enough the way
(defun c:control() (graphscr) (Setq sc (ssget "X" '((0 . "INSERT")
Create a routine that looks for a block based on a portion of that block name, using a specified path or search path.
For example, block to search for is BLOCKABC123, so if someone inputs ABC or 123 as a block name, it will locate that block within that folder and inserts it into the drawing at a user specified location.
Ideally, if there is a check in that if it finds more than one match, then perhaps it flags or prompts you to choose 1, 2, or 3 option which block to use. But I can live without this special function if it requires too much time to code.
I am currently using this lisp routine to export selected objects as a dxf to import into another program:
(defun c:dxf () (command "_dxfout" (getfiled "DXF File:" "c:/dxf/" "dxf" 1) "_Objects" (ssget) "" ; completes selection "_Version" "2004" "16" ; non-default number or other option if desired, with followup line(s) if necessary ) (princ "2004 DXF Created") (princ) )
this saves the dxfs to a location of C:DXF
I would like it to save to a different location, the desired location is within the same root folder that the drawing is located in and is called "DXF-Programs-Releases"
I have a dwg with 40 blocks that have a non-annotative property. I can go through 1 by 1 and change the property to annotative and redefine the block. Is it possible to automate this? I have done some google searches but have not found anything I am able to cut and paste or put together to get it to work.
Civil 3D 2012 SP4.0 Windows 7 Enterprise 64-bit C3D 2014 SP1 Dell M6600, Core i7 @ 2.3GHz, 16 GB ram Dell T3500 workstation, too much ram to post
We are trying to update our company logo on hundreds of autocad drawings, any lisp routine or a better way to get this updated. We are trying to update our title blocks that have company logo in it and want to change the logos to the new one.
I am working on a lisp routine that automatically inserts a parameter in a block and then ads a stretch command to it. But the problem is that for the stretch command u need to select the drawn parameter. So my plan was to get the name of this parameter (car (entsel)) and feet it to my lisp program. But when i do that it doesn't work because autocad demands a parameter.
I need to match few attribute values from one block to different block. I download a lisp file called; ca.lsp which can match the single attribute value. I modified it for more than one attribute value matching. It is ok but still wish to overcome two issues for batch prcess
1. picking up the blocks by selection
2. click the alternative block numbers of times to match the numbers of attribute values I needed.
How to modify this lisp I can run it by block name selections instead of picking selection which enable me to run batch process for numbers of drawing? That will be good...
Lisp & Demo file attached (Match attribute value, A, B & C to Attribute 1, 2 & 3).
I have the below code (from a user here on the forum) which works great for aligning text, mtext and blocks to 2 points. For annotative entities, it respects the rotation angle for mtext and text.
ie I have an mtext object at 1"=20' scale and at 1"=40' scale. I run the command when the current annotative scale is 1"=40'. The object at 40' scale has changed, but the 20' scale is unchanged. This is working as I would like it to.
But for annotative blocks, it gets weirded out. In the above example, the block at 40' will rotate, but so will the attributes at 20' scale. But linework and hatching at 20' scale will be unchanged. it looks really weird. how to get it to play nice with blocks. Ideally, I'd like the block to be at different rotation angles in different annotative scales.
(defun C:R2P (/ ss ang edata); = Rotate objects to align with 2 Points (setq ss (ssget '((0 . "*TEXT,INSERT"))) ang (angle (getpoint " First alignment point: ") (getpoint " Second alignment point: ")) ) (repeat (sslength ss) (setq edata (entget (ssname ss 0))) (entmod (subst (cons 50 ang) (assoc 50 edata) edata)) (ssdel (ssname ss 0) ss) ))
MyProblem: after I insert the block “NrPunct” in my drawing ,, I cannot modify "textHeight", when I edit the ATTDEF (or attribute) with the command “DDEDIT” . Why?
I am trying to update my Title Block with a LISP routine (As the title implies).
So far, this is what i have...
(defun c:aTest (/ ss att) (if (setq ss (ssget "X" (list (cons 0 "INSERT")(cons 2 "TB_PARAMOUNT_ELC") (cons 66 1)(if (getvar "CTAB")(cons 410 (getvar "CTAB")) (cons 67 (- 1 (getvar "TILEMODE"))))))) (progn (foreach ent (mapcar 'cadr (ssnamex ss)) (setq att (entnext ent))
[Code]...
The title block, block name is static. The attribute name is static.
My ultimate goal is to copy the value of one attribute and "paste" that into the value of another attribute, and itterate this through the entire project.
I'm looking for a lisp routine that will globally list all the values from a specific attribute tag within a specific block. The attribute tag is "COMMENT" and the block name is "FSD".
I can't find my notes on how I fixed it. When we insert our title block, it automatically inserts the drawing number. For one user, it doesn't work. The title block inserts, but it won't put in the drawing number. I seem to remember I need to change a setting or something to get it to work, but I can't remember what it is.
I started a lisp that moves blocks according to their attributes and align numeric value in x 0.0. I work currently selected point by point. I will wish it to run at once on a selection set (I am angry with entsel).
(defun c:test (/ sel ent st newpt) (if (setq eset(ssget)) (progn
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.
I have a lot of attribute blocks in my drawing which i want to move them one by one
so , here is what i want to do :
I have numbers (or texts) in my work area and this numbers also exist in my attribute blocks .. i wanna move my attribute blocks with tag name value reference to my specify area if tag name values are matching with text or numbers in this area .. every block will check my selected tag string and will be move on matching text in my work area.
I would like to create a lisp that does the following:
Update a titleblock attribute with a $variable.
The titleblockname is variable / not static.
The attribute is not variable / Static, DW_SCALE
The titleblock is always places on the same layer, BL$4----
The (custom)-plotscale is stored in the $var "gvpsc".
I've tried to ajust the following lisp code. But I couldn't extract the part I need.
The problem is, the code checks all the layouts and updates all the titlblocks one by one.
Truely a good code.
The only problem is, I don't have multiple layouts and I have a variable titleblock name.
Here is to code i've tried to convert to something I could use.
(defun C:UPD-DPC () (setvar "cmdecho" 0) (setq blkname "DPC-STEMPEL");(getstring " Enter the name of block to update: ")) (setq att1 "DW_DATE");(strcase(getstring " Enter the name of the attribute to change: "))) (setq newatt (strcase(getstring "
Is there a way (or a “trick”) to have one attribute at two different locations inside of one block (I want to avoid filling in the same text twice when this block is inserted or edited)?
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.
I have a series of blocks that I need to insert into a drawing, maybe 100-200 times and then change one of the 6 attributes by an increment of 1.
I've looked at some of the older posts and have not been able to do this. Is it possible to take the tag regerence, in this case OUTLET_REF and automatically add 1 to it when the symbol is inserted.
Can this be done using Diesel or with a bit of lisp?
i have a for example a block with one attribute and would like add a new attribute. i´m trying to read the current block and redefine - it comes a new attribute in propertieswindow but not graphical.
I'm looking for a lisp routine that i can globally change the text height and width factor of a particular block attribute. The name of the attribute tag is "TAG". I would like to be able to select all the blocks that i need to edit and then specify what text height and width factor i want to change to.