Author Topic: Convert annotative blocks to normal blocks  (Read 11169 times)

0 Members and 1 Guest are viewing this topic.

ribarm

  • Water Moccasin
  • Posts: 2166
  • Marko Ribar, architect
Re: Convert annotative blocks to normal blocks
« Reply #15 on: December 07, 2015, 02:47:45 AM »
Ok, I've found this link :
http://www.cad-notes.com/use-burst-for-block-with-attributes-instead-of-explode/
explaining for what burst command is useful in comparison to EXPLODE... And there is also this link :
http://autocadtips1.com/2011/07/21/using-burst-to-explode-a-block/
explaining usage of BURST over EXPLODE to explode Dynamic Blocks...

But have you seen examples where you can't do EXPLODE on block that is explodable and instead you must use BURST to explode block with attributes (block behaves like unexplodable) - I have report that in some cases this is an issue?
Please any opinion?
Thanks...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

boycemin

  • Mosquito
  • Posts: 1
Re: Convert annotative blocks to normal blocks
« Reply #16 on: July 18, 2019, 02:17:06 PM »
I can't guarantee, but have you tried to iterate through selection set without singe option...

Code: [Select]
(defun c:t ( / ucsf ch blocks bllst ss i ssent Block BlockName inspt rotang rotangd Xeffscf Yeffscf Zeffscf sssubents ans )

  (vl-load-com)

  (if (eq (getvar 'worlducs) 0)
    (progn
      (command "_.UCS" "_W")
      (setq ucsf t)
    )
  )
  (initget 1 "Annotative Non-annotative")
  (setq ch
    (getkword
      "\nDo you want to make selected blocks Annotative or Non-annotative [A/N] : "
    )
  )
  (setq blocks (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))))
  (vlax-for bl blocks
    (setq bllst (cons (list (vla-get-name bl) bl (vla-get-isxref bl)) bllst))
  )
  (prompt "\nSelect blocks with or without attributes that reside on unlocked layer(s)...")
  (setq ss (ssget "_:L" '((0 . "INSERT"))))
  (if ss
    (repeat (setq i (sslength ss))
      (setq ssent (ssname ss (setq i (1- i))))
      (setq Block (vlax-ename->vla-object ssent))
      (setq BlockName (vla-get-effectivename Block))
      (setq inspt (vlax-safearray->list (vlax-variant-value (vla-get-insertionpoint Block))))
      (setq rotang (vla-get-rotation Block))
      (setq rotangd (* (/ 180 PI) rotang))
      (setq Xeffscf (vla-get-Xeffectivescalefactor Block))
      (setq Yeffscf (vla-get-Yeffectivescalefactor Block))
      (setq Zeffscf (vla-get-Zeffectivescalefactor Block))
      (if (and (assoc BlockName bllst) (eq (last (assoc BlockName bllst)) :vlax-false))
        (vla-put-explodable (cadr (assoc BlockName bllst)) :vlax-true)
      )
      (command "_.EXPLODE" ssent)
      (while (< 0 (getvar 'cmdactive))
        (command "")
      )
      (setq sssubents (ssget "_P"))
      (if (= ch "Annotative")
        (progn
          (setq ans "Yes")
          (command "_.ROTATE" sssubents "" "_non" inspt (- rotangd))
          (command "_.BLOCK" BlockName "_Y" "_A" ans "_N" "_non" inspt sssubents "")
          (command "_.INSERT" BlockName "_non" inspt Xeffscf Yeffscf rotangd)
        )
        (progn
          (setq ans "No")
          (command "_.ROTATE" sssubents "" "_non" inspt (- rotangd))
          (command "_.BLOCK" BlockName "_Y" "_A" ans "_N" "_non" inspt sssubents "")
          (command "_.INSERT" BlockName "_non" inspt Xeffscf rotangd)
        )
      )
    )
    (prompt "\nEmpty sel.set... Retry routine with some blocks selected next time...")
  )
  (if ucsf
    (command "_.UCS" "_P")
  )
  (princ)
)

If you have attributed blocks, then you'll have to do it in another way... You have to try without me as I am not sure how to quickly write it...

[EDIT : Code changed to accept attributed blocks...]

- Hi Ribarm! thanks for your code! it worked on my Cad2019
it have a litle trouble:
i tried with an AnnoBlock (Az) (has list scale 1:1 / 1:50 / 1:100) in a normal block (Nx),
its means Nx= [(Ny)+(Az)]
-
after convert [Az] to Non-annoBlock => [Nz],
in my cur view (1:100) have [Nz] = Az(1:1)scale1.5
and inside Block Nx:
with block curview 1:100,result Nx = [(Ny) + [Nz]scale 150]
with block curview 1:50,  result Nx = [(Ny) + [Nz]scale 75]
with block curview 1:1 ,   result Nx = [(Ny) + [Nz]scale 1.5]
may you fix result is alway scale 1 for curview and same scale for all in normal block not dependd on block view?
i think it will be pretty cool if we could custom scale for New[N] for all (but not change anything inside)
-
by the way, i would like to share with you guys, lisp i get from vietnam
this have AAS function to make Normal block become to annotative block in you Cur View with setting of list scale, ANC help you check available scale of AnnoBlock
but this lisp appears vietnamese language, i have no idea how to translate to English. its no extension by .lsp
hope it is useful for everyone
-
« Last Edit: July 18, 2019, 02:30:50 PM by boycemin »