Hello,
Some time ago I got help on this post and the tool is working. However users experience that this function is in some circumstances doing something that is not always fully logic for them.
When we copy block from one drawing to other with this function then it works nice. But the problem is that when we i.e. have a block in ‘drawing A’ and copy the block and use this command to paste still into the same ‘drawing A’ then function is of course doing it, but it is actually renaming the existing block.
Users would wish to be able to use this function to paste block into same drawing but so that a new block definition is created and not that it is renaming that particular block.
Would that be that possible?
Currently used function is:
(defun C:PB (/ newname oldname doc blks); change name as desired
(while
(not
(and
(setq newname (lisped "Name for Block to be Inserted"))
; calls up Text Editor with content pre-selected for replacement
(setq newname (vl-string-trim " " newname)); remove any leading/trailing space(s)
(/= newname ""); didn't either clear out or enter only space(s)
(/= newname "Name for Block to be Inserted"); didn't just hit Enter
(not (tblsearch "block" newname)); name not already in use
); and
); not
(alert
(cond
((= newname "") "Empty string or only space(s) not allowed;\nyou must supply a Block name.")
((= newname "Name for Block to be Inserted") "You must supply a new Block name.")
(T "\nThat Block name is already in use.")
); cond
); alert
); while
(command "_.pasteclip")
(while (> (getvar 'cmdactive) 0) (command pause))
;; finish _.PASTECLIP including possible Scale/Rotate options, etc.
(setq
oldname (cdr (assoc 2 (entget (entlast)))); AutoCAD's meaningless name
doc (vla-get-activedocument (vlax-get-acad-object))
blks (vla-get-blocks doc)
); setq
(vla-put-name (vla-item blks oldname) newname); = Rename
(princ)
); defun
Best regards
miroko