CADdet Posted January 5, 2011 Posted January 5, 2011 Hi everyone, I found the following lisp on the net, and would like to append all the returnd information to a txt file i can manage a line of text but am now entierly lost as the lisp returns no less then 23 lines. The lines I'm intrested in keeping are: DockStatus (RO) Left Name Top Though if all the 23 lines are appended to a text file it will suit as its going to be processed futher in VB.net anyway. can somebody help with this; Heres the code: (defun try (tb / f) (vl-load-com) (vlax-for a (vla-get-menugroups (vlax-get-acad-object)) (if (equal (vla-get-name a) "ACAD") (vlax-for b (vla-get-toolbars a) (if (equal (strcase (vla-get-name b)) (strcase tb)) (progn (setq tlb b f 'T ) ;_ end of setq (vlax-dump-object tlb 't) ) ;_ end of progn ) ;_ end of if ) ;_ end of vlax-for ) ;_ end of if ) ;_ end of vlax-for (if (not f) (princ "\nToolbar not found: ") ) ;_ end of if (princ) ) Quote
irneb Posted January 5, 2011 Posted January 5, 2011 That code simply uses the vlax-dump-object function which just shows the properties of the object on the textscreen. It doesn't "return" anything - so you won't be able to use it to save to a file. You could turn on logging (Options dialog, Open and Save tab, Maintain a log file"). But that will simply append the entire textscreen into one file - not really what you need is it? Anyhow, here's another way of doing it: (vl-load-com) (defun getToolBar (name / mG tb p found) (vlax-for mG (vla-get-MenuGroups (vlax-get-acad-object)) (vlax-for tb (vla-get-Toolbars mG) (if (eq (strcase (vla-get-Name tb)) (strcase name)) (setq found tb) ) ) ) found ) (defun getObjPropCSV (obj props / prop str) (setq str "") (foreach prop props (if (vlax-property-available-p obj prop) (setq str (strcat str "," (vl-princ-to-string (vlax-get obj prop)))) (setq str (strcat str ",")) ) ) (substr str 2) ) You can then call it thus: (getObjPropCSV (getToolBar "UCS") '("DockStatus" "Left" "Name" "Top")) This gives a CSV string so you can save it to a CSV file using write-line. It can then be opened in Excel directly, e.g.: (defun c:SaveTBProps (/ TB f) (if (setq f (open "TBProps.CSV" "w")) (progn (write-line "DockStatus,Left,Name,Top" f) (foreach TB '("Properties" "Dimensions" "Layers" "UCS") (write-line (getObjPropCSV (getToolBar TB) '("DockStatus" "Left" "Name" "Top")) f) ) (close f) ) ) (princ) ) Quote
pBe Posted January 5, 2011 Posted January 5, 2011 hmmmmmnnn ..that code (CADdet) looks familiar 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.