Stratica11 Posted July 20, 2022 Posted July 20, 2022 I am trying to create a single command that will run three separate data extraction commands for three different blocks and their attributes. Based on the code below I have it working, but these files will be copied to different file locations and when I test that, the .CSV files I have them creating are not being created in the correct folder. They should always appear in the same folder as the current file, but that's not what's happening... I'm not sure what I'm missing. Any help would be greatly appreciated. (defun C:TAGS ( / e ss) ; by name (setq d "DOOR TAG") (if (> d "") (setq ss (ssget "_X" (list (cons 2 d)(cons 0 "INSERT"))))) (if (zerop (getvar "CMDACTIVE")) (progn (sssetfirst ss ss)(princ)) ss ) (command "-DATAEXTRACTION" (strcat (getvar 'dwgprefix) "Door Schedule.dxe")) (if (wcmatch (getvar "cmdnames") "*DATAEXTRACTION*") (command "_Y")) (setq w "WINDOW TAG") (if (> w "") (setq ss (ssget "_X" (list (cons 2 w)(cons 0 "INSERT"))))) (if (zerop (getvar "CMDACTIVE")) (progn (sssetfirst ss ss)(princ)) ss ) (command "-DATAEXTRACTION" (strcat (getvar 'dwgprefix) "Window Schedule.dxe")) (if (wcmatch (getvar "cmdnames") "*DATAEXTRACTION*") (command "_Y")) (setq c "CABINET TAG") (if (> c "") (setq ss (ssget "_X" (list (cons 2 c)(cons 0 "INSERT"))))) (if (zerop (getvar "CMDACTIVE")) (progn (sssetfirst ss ss)(princ)) ss ) (command "-DATAEXTRACTION" (strcat (getvar 'dwgprefix) "Cabinet Schedule.dxe")) (if (wcmatch (getvar "cmdnames") "*DATAEXTRACTION*") (command "_Y")) ) Quote
CAD_Noob Posted July 20, 2022 Posted July 20, 2022 following this...will need this in the future 1 Quote
marko_ribar Posted July 21, 2022 Posted July 21, 2022 (edited) Just to simplify code - make it more concise... (defun c:dataext_door_winddow_cabinet ( / process ) (defun process ( tag / ss ) (cond ( (setq ss (ssget "_I" (list (cons 0 "INSERT") (cons 2 (strcat (strcase tag) " TAG"))))) (sssetfirst nil ss) ) ( (setq ss (ssget "_X" (list (cons 0 "INSERT") (cons 2 (strcat (strcase tag) " TAG"))))) (sssetfirst nil ss) ) ) (vl-cmdf "_.-DATAEXTRACTION" (strcat (getvar 'dwgprefix) (strcat tag " Schedule.dxe"))) (if (wcmatch (getvar 'cmdnames) "*DATAEXTRACTION*") (vl-cmdf "_Y") ) ) (process "Door") (process "Window") (process "Cabinet") (princ) ) Edited July 21, 2022 by marko_ribar 1 Quote
BIGAL Posted July 21, 2022 Posted July 21, 2022 Maybe something I have a count blocks by attributes up to 5 levels of attributes would look for Door Window and cabinet in one go. If sounds like what you want post a sample dwg. Does not use data extraction. Quote
Stratica11 Posted July 21, 2022 Author Posted July 21, 2022 6 hours ago, BIGAL said: Maybe something I have a count blocks by attributes up to 5 levels of attributes would look for Door Window and cabinet in one go. If sounds like what you want post a sample dwg. Does not use data extraction. I'm storing the information in the tags and the end result would be an excel sheet for each (Door Schedule.xls, Window Schedule.xls, and Cabinet Schedule.xls). Something that I could then consolidate into the one excel sheet that we are currently using. If this sounds like something your thing does, I would definitely be interested. The code I have now does what I'm wanting but with the issue mentioned, so it's close, but not perfect. Thanks! DoorsWindowsCabinets.dwg Quote
Stratica11 Posted July 21, 2022 Author Posted July 21, 2022 8 hours ago, marko_ribar said: Just to simplify code - make it more concise... (defun c:dataext_door_winddow_cabinet ( / process ) (defun process ( tag / ss ) (cond ( (setq ss (ssget "_I" (list (cons 0 "INSERT") (cons 2 (strcat (strcase tag) " TAG"))))) (sssetfirst nil ss) ) ( (setq ss (ssget "_X" (list (cons 0 "INSERT") (cons 2 (strcat (strcase tag) " TAG"))))) (sssetfirst nil ss) ) ) (vl-cmdf "_.-DATAEXTRACTION" (strcat (getvar 'dwgprefix) (strcat tag " Schedule.dxe"))) (if (wcmatch (getvar 'cmdnames) "*DATAEXTRACTION*") (vl-cmdf "_Y") ) ) (process "Door") (process "Window") (process "Cabinet") (princ) ) Thank you so much for making the code cleaner. I'm definitely learning all this as I go, so I assumed it was pretty messy. I appreciate it! Quote
BIGAL Posted July 21, 2022 Posted July 21, 2022 (edited) This is what I got as a result, the Door Tag block should count correct need to look more into block. I added more blocks so can see count. Edited July 21, 2022 by BIGAL Quote
Kumar24 Posted October 20, 2023 Posted October 20, 2023 (defun c:CRTP (/ sel SS dxeFile) (initget 1 "All Select") (setq sel (strcase (getkword "\Select individual blocks or Select All (S or A): "))) (if (= sel "SELECT") (setq ss (ssget '((2 . "xyz123")))) (setq ss (ssget "X" '((2 . "xyz123")))) ) (if (zerop (getvar "CMDACTIVE")) (progn (sssetfirst ss ss)(princ)) ss ) (command "-DATAEXTRACTION" (strcat (getvar 'dwgprefix) "dsf.dxe")) (if (wcmatch (getvar "cmdnames") "*DATAEXTRACTION*") (command "_Y")) ) How to change the selection of Data Extraction and set to to selected set of blocks, can you please suggest 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.