
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Dear All,
a small modification to be done in followig code. The below code can match the sorce text value to destination text value. The modifcation I need is to match block name value to selected text value.
Lisp Code 1 for reference:
(defun c:MT() (setq entt (car (entsel "Select source text:")))
(setq enttx (entget entt))
(setq txt (assoc 1 enttx))
(setq entd (entget (car (entsel "Select destination DIMENSION:"))))
(setq dtx (assoc 1 entd))
(setq vij (subst txt dtx entd))
(entmod vij))
Or other code I have, that can match text value to block name value.
(defun c:RNB
(/ *error* _strip ssText ssBlock newBlockName blockName acDoc)
(defun *error* (msg)
(if acDoc
(vla-endundomark acDoc)
)
(cond ((not msg)) ; Normal exit
((member msg '("Function cancelled" "quit / exit abort"))) ; <esc> or (quit)
((princ (strcat "\n** Error: " msg " ** "))) ; Fatal error, display it
)
(princ)
)
(defun _strip (string)
(foreach char '("<" ">" ":" "\"" "/" "\\" "|" "?" "*")
(while (vl-string-search char string)
(setq string (vl-string-subst "" char string))
)
)
string
)
(while
(and
(princ "\nSelect text: ")
(setq ssText (ssget ":S:E" '((0 . "MTEXT,TEXT"))))
(princ "\nSelect block to rename: ")
(setq ssBlock (ssget ":S:E" '((0 . "INSERT"))))
(/= (setq newBlockName
(strcat
""
(_strip (vla-get-textstring
(vlax-ename->vla-object (ssname ssText 0))
)
)
)
)
(setq blockName (vla-get-effectivename
(vlax-ename->vla-object (ssname ssBlock 0))
)
)
)
(not (tblsearch "block" newBlockName))
)
(progn
(vla-startundomark
(setq acDoc (vla-get-activedocument (vlax-get-acad-object)))
)
(vla-put-name
(vla-item (vla-get-blocks acDoc) blockName)
newBlockName
)
(prompt (strcat "\nBlock \""
blockName
"\" renamed to \""
newBlockName
"\" "
)
)
)
)
)
Regards,
T.Brahmanandam
Solved! Go to Solution.