My goal involves the sheet set. As far as I know sheet set manipulation is not possible with lisp, only with .NET. However, I am simply trying to read one of the custom properties within a sheet set. This can be done via fields. Can a field then be read with lisp?
Thanks,
Jeff
Thank you for the reply.
I did see this post in my searching, but it seems all solutions involve an entity of some sort - either a block to get a field from or an mtext to place a field into.
The field I am attemptint to work with is the SheetSet Custom Sheet property which I have named 'Released'. If it does not contains a date I will have a "Preliminary" message appear on the title block.
So what I am getting at is this, if I do not have the field inserted within anything I cannot entget it. Even if I did, can I translate it from the expression "%<\AcSm Sheet.Released>%" into something usable?
Thanks,
Jeff
andrew.nao How do you mean "you can read it"?
If I try something like (setq test (strcat "%<\AcSm Sheet.Released>%")) the result would be to assign the expression itself to 'test' rather than the contents of the field as I would like.
Is there something I am amissing?
Jeff
Jeff
AFAIK, you can't evaluate a field expression independent of an object. However, you could create a temporary MText object, populate its contents with the field expression, retrieve the value the field assumes, then delete the MText. That is, if the field is referencing something inaccessible through LISP - I have limited experience with Sheet Sets so I wouldn't know.
Lee
well i dont use sheet sets but if i use %<\AcVar CreateDate \f "M/d/yyyy h:mm tt">% as a test it will display the date (obviously) so if you use
(setq ent1 (ssget)) (setq ent (ssname ent1 0)) (setq elist (entget ent)) (setq x (cdr (assoc 1 elist)))
it will set X to the current date you could then do what you want with the variable is this what you are looking to do?
A quick example for your consideration Jeff:
(defun EvalFieldString ( doc str / obj )
(vl-cmdf "_.updatefield"
(vlax-vla-object->ename
(setq obj (vlax-invoke (vla-get-modelspace doc) 'addmtext '(0. 0. 0.) 0. str))
)
""
)
(setq str (vla-get-textstring obj))
(vla-delete obj)
str
)
With some fields you may not need to use the UpdateField command:
(defun EvalFieldString ( doc str / obj ) (setq obj (vlax-invoke (vla-get-modelspace doc) 'addmtext '(0. 0. 0.) 0. str)) (setq str (vla-get-textstring obj)) (vla-delete obj) str )
Example call:
(setq doc (vla-get-activedocument (vlax-get-acad-object))) (evalfieldstring doc "%<\\AcVar Date \\f \"MMMM d, yyyy\">%") "August 9, 2011"
Note the extra backslashes in the field string to mark the relevant characters as literals.
Lee_Mac and andrew.nao - you guys are awesome.
I took your suggestions and put together a workable solution.
I started with Lee_Macs idea to create an mtext, populate it with the field and then extract it (which I didn't see how to do until andrews code example). Then it occurred to me...
My goal is to find the 'released' attribute in a sheet. I already had to verify that it is indeed a sheet in order to work. If it is a sheet it will have a title block. So rather than create a temporary mtext I am going to use the title block. It already has an attribute with the field in it.
(IF (= (GETVAR "ssfound") "") ;_ check to see if there is a sheet set associated to the current file (COND ((SETQ titleblock (SSGET "X" (LIST (CONS 0 "insert") (CONS 2 "Anno-Ttlb-Engr-1117") (CONS 410 (GETVAR "ctab")) ) ;_ end of LIST ) ;_ end of SSGET ) ;_ end of SETQ (SETQ listOatts (MAPCAR '(LAMBDA (Att) (CONS (VLA-GET-TAGSTRING Att) (VLA-GET-TEXTSTRING Att))) (VLAX-INVOKE (VLAX-ENAME->VLA-OBJECT (SSNAME titleblock 0)) "GetAttributes") ) ;_ end of MAPCAR releasedVIAss (CDR (ASSOC "REL_DATE" listOatts)) ) ;_ end of SETQ ) ((SETQ titleblock (SSGET "X" (LIST (CONS 0 "insert") (CONS 2 "Anno-Ttlb-Engr-1824") (CONS 410 (GETVAR "ctab")) ) ;_ end of LIST ) ;_ end of SSGET ) ;_ end of SETQ (SETQ listOatts (MAPCAR '(LAMBDA (Att) (CONS (VLA-GET-TAGSTRING Att) (VLA-GET-TEXTSTRING Att))) (VLAX-INVOKE (VLAX-ENAME->VLA-OBJECT (SSNAME titleblock 0)) "GetAttributes") ) ;_ end of MAPCAR releasedVIAss (CDR (ASSOC "REL_DATE" listOatts)) ) ;_ end of SETQ ) ((SETQ titleblock (SSGET "X" (LIST (CONS 0 "insert") (CONS 2 "Anno-Ttlb-Engr-2436") (CONS 410 (GETVAR "ctab")) ) ;_ end of LIST ) ;_ end of SSGET ) ;_ end of SETQ (SETQ listOatts (MAPCAR '(LAMBDA (Att) (CONS (VLA-GET-TAGSTRING Att) (VLA-GET-TEXTSTRING Att))) (VLAX-INVOKE (VLAX-ENAME->VLA-OBJECT (SSNAME titleblock 0)) "GetAttributes") ) ;_ end of MAPCAR releasedVIAss (CDR (ASSOC "REL_DATE" listOatts)) ) ;_ end of SETQ ) ((SETQ titleblock (SSGET "X" (LIST (CONS 0 "insert") (CONS 2 "Anno-Ttlb-FPln-2436") (CONS 410 (GETVAR "ctab")) ) ;_ end of LIST ) ;_ end of SSGET ) ;_ end of SETQ (SETQ listOatts (MAPCAR '(LAMBDA (Att) (CONS (VLA-GET-TAGSTRING Att) (VLA-GET-TEXTSTRING Att))) (VLAX-INVOKE (VLAX-ENAME->VLA-OBJECT (SSNAME titleblock 0)) "GetAttributes") ) ;_ end of MAPCAR releasedVIAss (CDR (ASSOC "REL_DATE" listOatts)) ) ;_ end of SETQ ) (T ()) ) ;_ end of COND (SETQ releasedVIAss nil) ;_ if no sheetset, then no auto-prelim ) ;_ end of if (IF (= releasedVIAss "####") ;_ if sheetset exists but sheet not release - then no auto-prelim (SETQ releasedVIAss nil) ) ;_ end of if
Then all there is to do is check with the releasedVIAss to see if the sheet is released before adding the 'Preliminary' note.
FYI, I realize that the redundant result of the COND is rather rediculous, but it works for now.
Thank you,
Jeff