AutoCAD Visual LISP / AutoLISP :: Put Field Formula In Attribute Value?
Sep 7, 2011
I am trying to put a field formula in an attribute value. Basically I have a block that has a attribute called QTY and it is equal to 1. I can get the object property to equal 1 with this expression:
In the attribute dialog box it will show 1+1 instead of 2. My question is how do I get it to show 2 with out opening the formula box and evaluating it?
I am currently using a field for my elevation tags. The field reads the y-value of a line and displays the results as the elevation. Our local jurisdiction requires that we list elevations from above grade (A.G.L.) as well as from bottom of base plate. The difference is usually 6"-12".
I was wondering if I could create another field that would read the same y-value of a line, but then subtract a predetermined value (6") and display the results.
Currently we have to do the math ourselves and this leaves room for errors and is often very tedious.
Is it possible to make an attribute or a field in a template with page numbering for layouts? Is it possible to make an attribute or a field in a template with the name of the layout?
Is that possible to have a lisp to extract the Field Expression of a attribute in a block?Specifically, to extract the property VALUE (TextString) of this attribute.After to extract, I would like to put this text extracted in a different layout tab, in the same drawing. In this way, I will have a text linked to the attribute value between two layout tabs. So, when I have to change the attribute value, the text will be updated automatically.
I know that if I use the FIELD command to manually copy and paste this value it will work, but when I have a lot of attributes it becomes very laborious.
I've been fighting with building a formula in a block utilizing a field from another block. I have a support steel member that once placed, will be lengthened. I need a distance from center of the pipe to the top of concrete. I created a block with a field referencing the insertion point (center of pipe) it works fine giving me this elevation. I also have another block that is the datum node. I have several fields in this block, and it is located at the bottom of the support steel plate. I am trying to create a field that takes the center of pipe elevation and subtracts the datum node elevation to get a distance. I created the formula referencing the COP elevation field and the elevation of the datum node. The information shows properly where I am building the formula, when I click evaluate, the Preview gives me ##### and when I create the datum node block that is also the output I get. I can't figure out why it won't give me the difference between the two elevation fields. I don't know what I can do differently to have that information in the datum node.
Background: Someone exploded an attribute block and copied it hundreds of times throughout a project, each time changing the Attribute Tag to match the Value they expected to appear in their drawing. The drawing must be xrefed, so the attribute definitions do not appear.
(There is only 1 attribute in the block.)
Proposed Solutions:
1:AutoLISP routine which copies Tag data from Attribute Definition into Value of Attribute Block:
Prompt-Select Attribute Definition
Copy Tag data
Prompt-Select Attribute Block
Paste data into Value
(Allow repeat to speed workflow)(*PREFERRED*)
2:AutoLISP routine which copies Tag data from Attribute Definition into Default Value and creates a new Block:
Prompt-Select Attribute Definition
Copy Tag data
Paste data into Default Value
Create New Block
(Select Multiple Objects)(Creates tons of new blocks which are messy)
I created a block, that uses the Y coordinate of the block and returns it's location in a field.
I would like to be able to indicate weather the value is negative or positive. If Y coordinate is less then 0, then the field indicates "-" in front of the value. But if the Y coordinate is positive, I couldn't find a way to place "+"symbol in front.
Is there any way I could introduce a conditional statement saying: if Y>0 then add "+" in front?
I had a routine that extracted field values from text and atts, but noticed this morning it did not work on fields from sheets sets.
I looked at the code and realized if a field formula is beyond 256 chars, the dxf codes store it in multiple groups.
Here is the revised code that deals with thos multiple groups (3 and then 2):
;GET LIST OF TEXT AND FIELDS FOR A GIVEN TEXT;RETURNS ("PLOTTED BY " "%<\AcVar Login \f "%tc4">%" " DATE" ...);FIELDS START AND END WITH WITH %< >%;(TXT-FIELDS-SEPARATED (car (Nentsel " Select Text, MText or Attribute: "))) (DEFUN TXT-FIELDS-SEPARATED (ENAME / DICT ELIST ENDINDEX FIELDS FLDDICT FLST FORMULA INDEX OBJ SPLIT-FLDS TRIMMED-LIST TXT-LIST TXTAFTER DENT FLDVAL FLST-TR) (SETQ ELIST (ENTGET ENAME)) (COND ((OR (= (CDR (ASSOC 0 ELIST)) "TEXT")
Is there any way to grab the Object ID or name from a layout tab to use in a field? I wish to link the layout name to a callout block so that if the layout tab changes position and name (inserting a new tab), the call out block will update no matter what page it is on. Without using the Sheet Set manager.
We use Sheet Set Manager fields to keep track of section cuts and details and such.Users are asking me if they can get only the last 4 digits of the sheet number to show up on the section cuts.
Is there a way to parse or truncate a field in the formula area of the field dialog box?I'm familiar with LISP and DIESEL but the file dialog box / formula area does not seem to accept those functions. Will it take a .NET function? If so, what? Or, is there another option I'm overlooking?
We use multi-leader objects in our drawings. When the multi-leader and its value are to be replicated throughout the drawing, we create mleaders with fields that show the contents of the first mleader. That way we can update only the value in the first mleader and all of its children will update as well. It works nicely for us.
Here comes one snag. If one of us opens a drawing with which we are not intimately familiar, we don't know which mleader is the parent of which children. There might be fifty parents and four hundred children in a drawing so going through them by hand is a big productivity drain.
What I need to do is write a routine that will let the user select the mleader that includes the field and have the routine highlight and/or zoom to the parent object.
I thought I should be able to find that info in the dxf codes for the mleader, but I am either missing it or it's not there.
I am trying to find a lisp that would get an attribute value (tag name = NBR_5) . I'm trying to run a simple routine that would let the user place the value from the titleblock attribute as text on a drawing. I see a ton of articles regarding getting attributes but I am not well versed in programming.
I have many texts fields in my drawing. I need edit the format of all field. e.g field - 1030.60 convert to - 1.030,60 Is there any lisp doing that? I mean, select multiple field and change it.
The Field dialog box has an item for CurrentSheetNumber with field expression: %<AcSm Sheet.Number>%
Is it possible to create a Field to display the Next Sheet Number (CurrentSheetNumber + 1) and a Field to display the Previous Sheet Number (CurrentSheetNumber - 1)?
I'm trying to create a field in a block (titleblock) that will automaticly update when I change the viewportscale.It's mostly only 1 viewport, sometimes a second of even 3rd but, they are not important to the titleblock.
I've read aboud fields and diesel expressions. I've tried and it works. there is only 1 problem,It only works with the object (when field expresssion, object, custom scale) in this case the viewport pressent at that time.
When i use the same field with the same expressions, it does not recognize the viewport/object.Is there a way to make the field, diesel expression or even something else, work without it's need for a
object name. Perhabs that the expression gets the viewportname from a lisp, something like: (setq ss(ssget "X")) ;some thing like this Can it be done?
I have a situation where I have a AutoCAD table linked to a Excel table to retrieve lots of general information for a standard drawing. That works just fine. In additionally I can use the fields "formula" field name and select a cell in the AutoCAD table to pull the data from the cell to the field, and this works for table cells that are numeric, but some of the cells are text based, and for these situations AutoCAD simply gives me the #### result. Is there a way to use a field to display text data from a AutoCAD table Cell?
How I can tie a key from a custom dictionary to display in a field?
I know that I can dump the custom dictionary into global and the fields can track those values, but instead of strangling my available memory I'd rather track the dictionary key directly. How can I utilize the Entity name or the actual dictionary name & key?
Maybe it was a naive of me to charge in so boldly. The field appears to have made it in but it does not act like a field and does not reflect the correct value or update. In fact I get no response at all. In fact using "update field" "all" selects the fields but reports that they are locked.
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")
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: