mwohlford Posted December 6, 2020 Posted December 6, 2020 (edited) I wrote a lisp program that creates an equipment list from part numbers in selected blocks and a csv file with information about those part numbers. It allows the user to then select a layout followed by an insertion point, then creates the table a populates it with the list. On a small project were 4 or 5 sheets are all that is needed the sheets are in the same drawing file and this works great. However, on larger projects the sheet that the equipment list needs to go on is not in the same drawing file. Is there a way to select a layout in another file for the table to be created and inserted on? I know I could save the list to a global variable, open the drawing with the sheet to insert on and create the table from there. I would like to not have to ask the user to go through the extra steps. Is it possible to maybe use getfiled to open a drawing to the specified sheet then create the table? Any guidance would be helpful whether with getfiled or some other method that I could work into my code. Edited December 6, 2020 by mwohlford Quote
Jonathan Handojo Posted December 6, 2020 Posted December 6, 2020 (edited) If you're familiar with using VLA methods, you can access another drawing yes. You use vla-get-ActiveDocument to get the vla-object of your active document... you can use the below (a snippet of the Steal Routine by Lee Mac) to get the vla object the document of another drawing. (defun steal:getdocumentobject ( filename / acdocs dbdoc vers ) (vlax-map-collection (vla-get-documents (vlax-get-acad-object)) (function (lambda ( doc ) (setq acdocs (cons (cons (strcase (vla-get-fullname doc)) doc) acdocs)) ) ) ) (cond ( (null (setq filename (findfile filename))) nil ) ( (cdr (assoc (strcase filename) acdocs)) ) ( (null (vl-catch-all-error-p (vl-catch-all-apply 'vla-open (list (setq dbdoc (vla-getinterfaceobject (vlax-get-acad-object) (if (< (setq vers (atoi (getvar 'acadver))) 16) "ObjectDBX.AxDbDocument" (strcat "ObjectDBX.AxDbDocument." (itoa vers)) ) ) ) filename ) ) ) ) dbdoc ) ) ) So you can perform something like: (foreach x '(your_list_of_dwg_paths) (setq dbdc (steal:getdocumentobject x)) ;; and do your stuff here (vlax-release-object dbdc) ) Edited December 6, 2020 by Jonathan Handojo 1 Quote
mwohlford Posted December 6, 2020 Author Posted December 6, 2020 Thank you for pointing me in the right direction. If I understand the Lee Mac's function correctly, I will use the returned document object to create the table. Since the drawing will not be visible I will need to provide a predetermined insertion point and layout for said table. I can then use vla-save before releasing the document. I am having a hard time wrapping my head around how the cond statement is working with two null conditions. Would you be willing to briefly explain to further my education? Quote
mwohlford Posted December 6, 2020 Author Posted December 6, 2020 While waiting for the previous post to be approved, I stepped through the conditions and worked it out. 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.