Jump to content

move blocks to other (new) layer by TWO attribute values


hpimprint

Recommended Posts

you could try adding garbage collection command (gc) but it would slow down the routine. Or add a counter and when it reaches lets say 1000 , do (GC) and reset counter.

 

...
(foreach block (ss->ol ss)
  (gc)
  ;;; qui definisce cosa sono tag1, tag2 e tag3 tra le proprietà del blocco
...

 

else buy more ram ? else I think splitting dwg is only way...

 

⛄ ❄️ 🎅 🎄

 

Link to comment
Share on other sites

(defun c:blockschangenameandlayer ( / ss tag1 tag2 tag3 lay count max-count)
  (setq count 0 max-count 1000)
  (if (setq ss (ssget "x" '((0 . "insert"))))
    (foreach block (ss->ol ss)
      ;;; qui definisce cosa sono tag1, tag2 e tag3 tra le proprietà del blocco
      (setq tag1 (gav block "systemId") tag2 (gav block "PipelineID") tag3 (gav block "keyword"))
      (if (and tag1 tag2 (setq tag1 (validsn tag1)) (setq tag2 (validsn tag2)))
        (cond
          ((and tag3 (setq tag3 (validsn tag3)) (eq (strcase tag3) "SUPPORT"))
	     ;;; se keyword=SUPPORT aggiunge al nome layer "-SUPPORT"
             (create_layer (setq lay (strcat tag1 "-" tag2 "-" tag3))) (vla-put-layer block lay))
          (t (create_layer (setq lay (strcat tag1 "-" tag2))) (vla-put-layer block lay))
        )
      )
      (if (< count max-count)(setq count (1+ count))(progn (setq count 0)(gc)))
    )
  )
  (princ)
)

 

Link to comment
Share on other sites

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...