Ahankhah Posted January 4, 2015 Posted January 4, 2015 Hi everybody, as I requested in another thread (Finding template of new drawing), I am seeking a way to find out the name and directory of the template file which is used for NEW drawing. I tested all ways mentioned in the thread, with no success (shown as follow) (getenv "General\\LastTemplate") (getenv "LastTemplate") (vla-get-TemplateDWGPath (vla-get-Files (vla-get-Preferences (vlax-get-acad-object)))) Indeed the returned name and path refers to Qnew template. I appreciate any help Quote
Lee Mac Posted January 4, 2015 Posted January 4, 2015 I don't think this is possible Ahankhah - after the template has been selected, a new drawing is created by cloning the settings found in the template file, and as far as I am aware no information pertaining to the filename of the template file is preserved. My only suggestion would have been to use (getenv "LastTemplate") but you already state that this has not been successful. Quote
Ahankhah Posted January 4, 2015 Author Posted January 4, 2015 Lee, knowing that something is impossible is a kind of solution. It means I must search one less way to get the goal8). (Of course I translated the sentence from Persian to English. I hope you understand me:roll:.) thank you very much. Quote
Lee Mac Posted January 4, 2015 Posted January 4, 2015 I understand you perfectly Ahankhah - of course, I'd happily be proven wrong if someone does find a way to determine this information. Lee Quote
hmsilva Posted January 4, 2015 Posted January 4, 2015 Using, 'new' or 'qnew' command, the used template will be stored at "LastTemplate". I'm missing something? Henrique Quote
BlackBox Posted January 5, 2015 Posted January 5, 2015 1+ Only data that is contained within a given template is available to a resultant new drawing. That said, adding a custom XRecord, etc. to your respective drawing template(s) that identifies the template will show up in all drawings created from same, moving forward. Cheers Quote
Ahankhah Posted January 5, 2015 Author Posted January 5, 2015 (edited) Lee, Hmsilva, I found just now (getenv "LastTemplate") returns correct answer. What dropped me into that wrong (above mentioned) situation was that, I was gotten "LastTemplate" value after issuing "NEW" command and completing :vlr-CommandEnded event, but before entering to the new drawing's view, so LISP returned the previuous value. (By the way I was previously "QNEW"ed a drawing.) Thank you very much for taking time to contribute your knowledge to me. Edited January 5, 2015 by Ahankhah Quote
Ahankhah Posted January 5, 2015 Author Posted January 5, 2015 (edited) BlackBox, although my problem is solved, but your idea is very good in some other cases. Also, it is possible to set some custom properties via dwgprops. But my problem was finding the last file opened as template, even if it was not known for the programmer. Edited January 5, 2015 by Ahankhah Quote
Ahankhah Posted January 5, 2015 Author Posted January 5, 2015 (edited) Lee, you were not wrong. You just trusted on my claim. Edited January 5, 2015 by Ahankhah Quote
BlackBox Posted January 5, 2015 Posted January 5, 2015 although my problem is solved, but your idea is very good in some other cases. A former employer used this methodology (and adaptations of same), to embed corporate disclaimers into our drawings, that would justify legal recourse when competitors used our drawings, etc. but that scenario is still not without some pretty large gaps; just thought it might help you moving forward on this. Also, it is possible to set some custom properties via dwgprops. But my problem was finding the last file opened as template, even if it was not known for the programmer. I understand, and know of no way to determine that for existing drawings - only moving forward, as described, unfortunately. In order to determine what template was used, perhaps there's a discipline-specific layer, color of layer, or block definition that is able to be reasonably assumed to be a unique identifier? If so, you could easily query via ODBX en-mass. Cheers Quote
Ahankhah Posted January 6, 2015 Author Posted January 6, 2015 BlackBox, thank you for sharing your idea. Quote
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.