Jump to content

Dynamische Blöcke and Layouts


dober

Recommended Posts

Please help

I want to change my dynamic blocks on the layouts all the layouts at once.

With a normal block, the Lisp goes well.

I do not know how I have to adapt for Dynamic Bklöcke because with the synonymous with dynamic blocks works.

 

 

Thank you

 

(defun c:Test   (/ taglist ss ent att tnme)
 
 (setq    taglist
    '(("EBENE"      . "TEST1")
      ("BAUTEIL"    . "TEST2")) ;  <--- List Tags and Values here.
   )

 (if (setq ss (ssget "_X" '((0 . "INSERT") (2 . "Test-Block")  (66 . 1)  (410 . "~Model")
	      )))
  
     (foreach ent  (mapcar 'cadr (ssnamex ss))
   (setq att (entnext ent))
   (while (not (eq "SEQEND" (cdadr (entget att))))
     (setq tnme (cdr (assoc 2 (entget att))))
     (if (assoc tnme taglist)
       (entmod (subst (cons 1 (cdr (assoc tnme taglist)))
              (assoc 1 (entget att)) (entget att))))
     (setq att (entnext att))))
     (command "_regenall"))
   (princ "\n<!> No Blocks Found <!>"))
 (princ))

 

Bitte um Hilfe

Ich will meine Dynamischen Blöcke auf den Layouts ändern alle Layouts auf einmal.

Mit einem normalen Block geht das Lisp gut.

Leisder weiss ich nicht wie ich das für Dynamische Bklöcke anpassen muss da mit das auch mit Dynamischen Blöcken funktioniert.

 

 

Danke

Link to comment
Share on other sites

Hi Dober,

 

 

I think what you are looking for has to do with the effective name property. Plenty of stuf on this site. Havent had much time to test it or work any further on my block program and it might be a little over the top (so nothing new there ;-) but it also just might work for you :

 

 

http://www.cadtutor.net/forum/showthread.php?100670-RlxBlk-Replace-Redefine-blocks-visibility-states-preview-and-link-attributes&highlight=rlxblk

 

 

gr. Rlx

Link to comment
Share on other sites

I have here the German version of Autocad about it is not with me I believe!

It simply simply nothing at me kmmt also no error message.

 

Thanks again.

Link to comment
Share on other sites

here's something on how to select dynamic block names

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/block-s-effective-name-conflicts-with-u/td-p/4941518

 

the important part is

 (cons 2 (strcat "`*U*," bname)) 

 

this will select all blocks with bname (your blockname) and also all blocks with name beginning with *u

 

next you have to loop thru all of those blocks and get the effective name and if this name matches your own blockname you know you've got the right one.

 

 
(progn
(repeat (setq i (sslength ss))
(setq e (vlax-ename->vla-object (setq o (ssname ss (setq i (1- i))))))
(if (vlax-property-available-p e 'effectivename)
(setq n (vla-get-effectivename e))
(setq n (vla-get-name e))
)
(if (wcmatch (strcase n) bnames)
(ssadd o ss1)
)

 

Gr. Rlx

Link to comment
Share on other sites

Thanks for the tip, the unfortunately not so synonymous!

 

 

Maybe a sample drawing would help? If I understand you code / language correctly , you want to update certain attributes for certain blocks?

 

 

gr. Rlx

Link to comment
Share on other sites

unfortunately cannot open drawing here !#$%^& I was suppost to get a 'new' pc here at work but instead got secondhand and crippled pc so for now cannot go higher than acad 2012... :cry:

Link to comment
Share on other sites

quickly written :

 

 



; Dober.lsp written for Dober on CadTutor - rlx 27-jun-2017
; blockname = "Schriftkopf mit Rahmen"
; tag 1 = EBENE , tag 2 = BAUTEIL
(defun C:Dober ( / bn att-list layout obj)
 (vl-load-com)
 (setq bn "Schriftkopf mit Rahmen" att-list '( ("EBENE" . "rlx1") ("BAUTEIL" . "rlx2")))
 (vlax-for layout (vla-get-layouts (vla-get-ActiveDocument (vlax-get-acad-object)))
   (vlax-for obj (vla-get-block layout)
     (if (and (eq (vla-get-objectname obj) "AcDbBlockReference")
       (vlax-property-available-p obj 'effectivename)
       (eq (strcase (vla-Get-EffectiveName obj)) (strcase bn))
       (eq (vla-get-hasattributes obj) :vlax-true))
(update_attributes obj)
     )
   )
 )
)
(defun update_attributes (%obj / )
 (mapcar
   (function
     (lambda ( att / tag)
(if (setq tag (assoc (vla-get-TagString att) att-list))
  (vlax-put-property att 'TextString (cdr tag)))))
   (vlax-invoke %obj 'GetAttributes)
 )
)


 

 

gr. Rlx

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