I was hoping this would answer my question but the link to the Picture is not found.
I have a simple Autolisp question, similar to this if anyone can answer. I am writing a routine, and in the routine I want to be able to get (and Store with a Setq if needed) the value from a custom field in the drawing from the Drawing Properties. (for example: FLRLEVEL would be the custom field name in the Drawing Properties and the Value may be something like 02, for the second floor). This field is not really tied to any particular object in the drawing, so I am not sure if it can be done without an Object ID? (Which is what all of the examples have been of) I know I could have the lisp prompt for the floor number, but this routine will be ran multiple times in each DWG and I was hoping to have it stored with the DWG rather than the LISP routine; I have tried GETVAR but it is not found as a system variable. If anyone can assist me I will be forever grateful. Thank you in advance.
Is it possible to reference custom fields in LISP or SCR and use the values entered there to turn on and off layers? Example of a custom field code referenced in attributes:
%<\AcSm SheetSet.CUSTOMFIELDNAME \f "%tc1">%
Theoretically if i enter a 1 or a 0 as the field property, cant i use a simple condition and layer on/off command to achieve this?
Thanks,
Thank you for sharing the code.
The field is inserted at top left corner.
How may I change that to insert at middle centre?
It seems that the field format is the same if it is Top Left or Middle Centre.
Thank you both for sharing the code. Very useful!
I have a polyline and a block with attribute "Length".
I have two tasks:
- to set a field expression in the block attribute with the lenght of the polyline;
- to read the expression from the field attribute and find the handle of the polyline.
Thanks!
Here is a sample.
One polyline and a block. The attribute in the block refere the length ot the polyline.
I need a lisp code that read the block reference and find the handle of the polyline.
Thanks!
Wow. With a 3 month response time for each message, this conversation could take a while.
As far as I can see, there is not any relation between the block and the polyline , and the attribute is not a FIELD ,
So how do you think it can be do?
IMHO you have to do 2 clicks, one at the block , and other at the polyline
Rudi, try the attached as a starting point. May want to add standard error checking, and also catch if the block with same name exists
(defun c:plfld ( / plent pt1 pt2 curnomutt curcmd) (prompt "\nSelect Polyline :") (setq plent (car (entsel)) pt1 (getpoint "\nSelect insertion point :") curcmd (getvar 'cmdecho) curnomutt (getvar 'nomutt) pt2 (subst (+ (car pt1) 26) (car pt1) pt1)) (setvar 'cmdecho 0) (setvar 'nomutt 1) (entmake (list (cons 0 "BLOCK") (cons 100 "AcDbEntity") (cons 100 "AcDbBlockBegin") (cons 8 "0") (cons 10 pt1) (cons 2 "SomeBlk") (cons 70 2))) (entmake (list (cons 0 "TEXT") (cons 100 "AcDbEntity") (cons 100 "AcDbText") (cons 8 "0") (cons 10 pt1) (cons 40 12.0) (cons 1 "L="))) (entmake (list (cons 0 "ATTDEF") (cons 100 "AcDbEntity") (cons 100 "AcDbText") (cons 8 "0") (cons 10 pt2) (cons 40 12.0) (cons 1 (strcat "%<\\AcObjProp.16.2 Object(%<\\_ObjId " (itoa (vla-get-objectID (vlax-ename->vla-object plent))) ">%,1).Length \\f \"%lu2%pr0\">%")) (cons 100 "AcDbAttributeDefinition") (cons 3 "Len") (cons 2 "LEN") (cons 70 0))) (entmake (list (cons 0 "ENDBLK") (cons 100 "AcDbEntity") (cons 100 "AcDbBlockEnd") (cons 8 "0"))) (command "._-Insert" "SomeBlk" pt1 "1" "" "0" "") (setvar 'cmdecho curcmd) (setvar 'nomutt curnomutt) (princ) )
Thank you, it works! Very useful!
I will try to insert already made block for a large
number polylines, not to create new block many times.
You can create anything in AutoCAD!!! though it may take a while...but that is the "fun" in it right?
I suggest looking for clues as to how things can be done, and not just answers to a test (because you wont understand what to do when something breaks)
Being an educator, I am very opposed feeding the fisherman fish...you get it.
And Yes, you can even a block that can resemble a process contained in a cloud!
(not just data, but a process to generate/obtain/update the data - a field can contain an autolisp variable.fine - but I needed something that would be more dynamic and change as my drawing changed automatically (like a field based on an autolisp function result))
In short, some reactor code to "process" your code and set the text values on-the-fly and/or when you want the processing performed. The code used to obtain the value desired can also be housed in the drawing.
Grab the code, do the processing as desired, and update the text values accordingly.
Since there are a number of ways to implement this loose design...
I'll leave it up to you to create an implementation...
I do it on the daily, but am unable to share this code as it is not mine to share...sorry.
The main difference here is the complexity of the calculations required may be fairly involved, but it is your choice about the when and where the processing to update your values occurs instead of only relying on a variable value (without discovery/calculation/processing).
If anyone inquires as to posting a sample, I may be able create a simpler scenario for the community to illustrate the process. (I would need to ask the people who pay me first).
TANX.Rob