eric_monceaux Posted November 6, 2009 Share Posted November 6, 2009 I have created a template (attached) that has specific fields in the Custom tab of DWGPROPS, which is referenced in the titleblock. I wanted to see if it was possible to have a LISP that asks for the custom field info at the start of a new drawing in the command bar instead of a dialog box. I have tried changing the CMDDIA variable to 0, but it doesn't help. I really like using the DWGPROPS, but it doesn't navigate like ATTEDIT does (using keyboard navigation), and I am trying to speed that process up. Also, on a side note, has any leway been made on being able to add a "total number of layouts" field in AutoCAD 2010? (For Page # of #) DWGPROPS Lisp.dwg Quote Link to comment Share on other sites More sharing options...
VVA Posted November 9, 2009 Share Posted November 9, 2009 (edited) Try it ;;; *********************************************** ************************* ;;; * Library DWGruLispLib Copyright © 2007 DWGru Programmers Group ;;; * ;;; * _dwgru-Dwgprops-get-all-prop ;;; * ;;; * 27/12/2007 Version 0001. Vladimir Azarko (VVA) ;;; *********************************************** ************************* (defun _dwgru-dwgprops-get-all-prop (Doc / si ret nc key value) ;;; Returns the file's properties, set the command _dwgprops ;;; Returns an associative list, where the key is: ;; - For properties created by the user (tab OTHER) ;;; Property name ;; - For standard properties (tab PAPER) ;;; Key field ;;; NAME - *TITLE* ;;; AUTHOR - *AUTHOR* ;;; TOPIC - *SUBJECT* ;;; KEY WORDS - *KEYWORDS* ;;; NOTES - *COMMENTS* ;;; Hyperlink Base - *HYPERLINK* ;;;!! Key fields are converted to uppercase ;;; Doc - a pointer to the document, nil - the current ;;; Example ;;; (_dwgru-dwgprops-get-all-prop nil) ;;;(("* AUTHOR * "" VVA ") (" * COMMENTS * "" Memo ") (" * HYPERLINK * "" Base ") ;;;("* KEYWORDS * "" Key ") (" * TITLE * "" named ") (" * SUBJECT * "" R ") (" UNIQKEY "" Key ")) (and (or Doc (setq Doc (vla-get-activeDocument (vlax-get-acad-object))) ) (setq si (vla-get-SummaryInfo Doc)) (setq ret (list (list "*AUTHOR*" (vla-get-author si)) (list "*COMMENTS*" (vla-get-comments si)) (list "*HYPERLINK*" (vla-get-HyperlinkBase si)) (list "*KEYWORDS*" (vla-get-keywords si)) (list "*TITLE*" (vla-get-Title si)) (list "*SUBJECT*" (vla-get-Subject si)) ) ) (setq nc (vla-numcustominfo si)) (while (> nc 0) (vla-GetCustomByIndex si (- nc 1) 'key 'value) (setq ret (append ret (list(list (strcase key) value)))) (setq nc (1- nc)) ) (vlax-release-object si) ) ret ) ;;; *********************************************** ************************* ;;; * Library DWGruLispLib Copyright © 2007 DWGru Programmers Group ;;; * ;;; * _dwgru-Dwgprops-get-custom-prop ;;; * ;;; * 27/12/2007 Version 0001. Vladimir Azarko (VVA) ;;; *********************************************** ************************* (defun _dwgru-dwgprops-get-custom-prop (key Doc / app counter counter2 counter3 doc dwgprops kv) ;;; Returns the value of the property created by the user (command _dwgprops) ;;; Returns an associative list, where the key is: ;; - For properties created by the user (tab OTHER) ;;; Key - a string property name (tab OTHER) ;; - For standard properties (tab PAPER) ;;; Key field ;;; NAME - *TITLE* ;;; AUTHOR - *AUTHOR* ;;; TOPIC - *SUBJECT* ;;; KEY WORDS - *KEYWORDS* ;;; NOTES - *COMMENTS* ;;; Hyperlink Base - *HYPERLINK* ;;; ;;; Uses the library ;;; _dwgru-Dwgprops-get-all-prop ;;; _dwgru-Assoc (_dwgru-assoc-multi) ;;; Doc - a pointer to the document, nil - the current (cadr (_dwgru-assoc key (_dwgru-dwgprops-get-all-prop Doc))) ) ;;; *********************************************** ************************* ;;; * Library DWGruLispLib Copyright © 2007 DWGru Programmers Group ;;; * ;;; * _dwgru-Dwgprops-set-custom-prop ;;; * ;;; * 27/12/2007 Version 0001. Vladimir Azarko (VVA) ;;; *********************************************** ************************* (defun _dwgru-dwgprops-set-custom-prop (key value Doc / si) ;;, Create in the properties of the figure (team _dwgprops bookmark OTHER) ;;; Property with key and value value ;;; If the property was not, it is created, otherwise the changes ;;; Key - a string property name (tab OTHER) ;;; Value - a string - value of property ;;; Uses the library ;;; _dwgru-Dwgprops-get-custom-prop ;;; Doc - a pointer to the document, nil - the current ;;; Returns - nil ;;; Example ;;; (_dwgru-dwgprops-set-custom-prop "dwgru" "dwgru-dwgprops-set-custom-prop" nil) (or Doc (setq Doc (vla-Get-ActiveDocument (vlax-Get-Acad-Object))) ) (setq si (vla-Get-SummaryInfo Doc)) (if (_dwgru-dwgprops-get-custom-prop key Doc) (vla-SetCustomByKey si key value) (vla-AddCustomInfo si key value) ) ) (defun _dwgru-assoc-multi (key lst) (if (= (type key) 'str) (setq key (strcase key)) ); _ End of if (vl-remove-if-not (function (lambda (a / b) (and (setq b (car a)) (or (and (= (type b) 'str) (= (strcase b) key)) (equal b key)) ); _ End of and ); _ End of lambda ); _ End of function lst ); _ End of vl-remove-if-not ); _ End of defun (defun _dwgru-assoc (key lst) (car (_dwgru-assoc-multi key lst)) ); _ End of defun Usage (defun C:TEST () [color="Red"](vl-load-com) ;;; Do not forget to add[/color] (setq str (getstring t "\nJob Number:")) (_dwgru-dwgprops-set-custom-prop "Job Number" str nil) (setq str (getstring "\nCustomet:")) (_dwgru-dwgprops-set-custom-prop "Customer" str nil) (setq str (getstring t "\nAddres:")) (_dwgru-dwgprops-set-custom-prop "Addres" str nil) ) Edited January 14, 2011 by VVA Quote Link to comment Share on other sites More sharing options...
eric_monceaux Posted November 9, 2009 Author Share Posted November 9, 2009 Ok, I loaded the lisps, but I think I did something wrong, because I get the following error: Command: appload DWGruLispLib.lsp successfully loaded. test.lsp successfully loaded. Command: ; error: malformed list on input Command: Command: Command: test Job Number:109-567 ; error: no function definition: _DWGRU-ASSOC Command: Quote Link to comment Share on other sites More sharing options...
eric_monceaux Posted November 9, 2009 Author Share Posted November 9, 2009 Nevermind. I had missed a section of code. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.