Jump to content

Recommended Posts

Posted

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"))

)

 

Posted

following this...will need this in the future

  • Like 1
Posted (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 by marko_ribar
  • Like 1
Posted

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. 

Posted
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

Posted
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!

Posted (edited)

This is what I got as a result, the Door Tag block should count correct need to look more into block.

 

image.thumb.png.d579697684adbee5d940dbd2531a5ac6.png

 

I added more blocks so can see count.

 

image.thumb.png.bbda2420b94cded1260a3a09ddc2732e.png

Edited by BIGAL
  • 1 year later...
Posted
(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 

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...