Jump to content

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


Recommended Posts

Posted

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

 

⛄ ❄️ 🎅 🎄

 

Posted

i will try, thank you.

(ram is 16Gb .... i can't add more :(   )

i will test on another pc having 32Gb ram.

 

Posted

please, could you insert in the script the counter to 1000 before activating (gc)?

Posted
(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)
)

 

Posted

it worked! memory problem solved! thank you :) :)

Posted

you're welcome. You can try to set max-count to higher value like 10.000 or 100.000 if routine becomes to slow but if it works then it works 😀

 

🐉

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