streng Posted January 30, 2009 Posted January 30, 2009 Before I start I would just like to say I am completely new to VBA but once you hear about the things you can achieve with it I can't wait to start. The outcome of my first vba code is to automatically produce a drawing register within excel. Using Autocad VBA I have managed so far to open excel and produce a standard issue sheet in code In AutoCAD within our drawing files we use Custom Fields in the Drawing Properties (Custom) ToolBar. These custom fields namely: PROJECT1 PROJECT2 PROJECT3 JOB NO Put simply : what code would I use to simply place PROJECT1 field into excel field B11. Quote
fuccaro Posted February 2, 2009 Posted February 2, 2009 I don't use VBA but I think the custom fields are stored as dictionary objects. So there you should start searching for. Quote
ASMI Posted February 2, 2009 Posted February 2, 2009 This is SummaryInfo object - property of Document object. It has AddCustomInfo, GetCustomByIndex, GetCustomByKey, NumCustomInfo, RemoveCustomByIndex, RemoveCustomByKey, SetCustomByIndex, SetCustomByKey methods to manage custom properties. Access via Dim cPrp = As AcadObject Set cPrp = ThisDrawing.SummaryInfo Quote
ASMI Posted February 2, 2009 Posted February 2, 2009 Function to get custom property by key in AutoLISP syntax: (defun GetInfo(Key / sInf cPrp pVal) (vl-load-com) (setq sInf(vla-get-SummaryInfo (vla-get-ActiveDocument (vlax-get-acad-object)))) (if(vl-catch-all-error-p (vl-catch-all-apply 'vla-GetCustomByKey (list sInf Key 'pVal))) (princ(strcat "\n*** ERROR. Key '" Key "' not fouund! ")) (princ(strcat "\n" Key " = " pVal)) ); end if (princ) ); end of GetInfo Testing: Command: (GetInfo "Project Name") Project Name = Test Name Command: (GetInfo "Drawing name") *** ERROR. Key 'Drawing name' not fouund! 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.