Jump to content

LISP needed to rename Spaces by selecting text


mkp6486

Recommended Posts

Hello everyone, I am new here and was hoping I could find some help. I am using Spaces within AutoCAD MEP and I would like to have the ability to rename my spaces easily by selecting the space, then selecting the roomname/number text provided by the architect. This would save tremendous amounts of time, as the spaces must be renamed by typing in a name and number for hundreds of rooms.

 

I have attached an image for clarity.

 

This would allow me to export my gbXML space/zone data clearly labeled for cooling/heating load analysis.

 

If no such lisp routine exists, can anyone point me in the right direction for a lisp that inserts selected text into a property?

 

Thank you very much for any help!

space-properties.jpg

Link to comment
Share on other sites

Looks like you are willing to modify by AutoLISP a custom entity of MEP – I’m not aware that SPACE entity is available in Vanilla AutoCAD. For this reason will be easy to get support from someone using MEP too.

Just to see that the associated list of this entity can be accessed and modified, please paste the code below to your command line, select a SPACE item and post here the result. Thank you.

(entget (car (entsel)))

Link to comment
Share on other sites

Thank you for the reply. Here are the results of the command:

 

Command: (entget (car (entsel)))
Select object: ((-1 . <Entity name: 7ffff265c00>) (0 . "AEC_SPACE") (5 . 
"5BD0") (102 . "{ACAD_XDICTIONARY") (360 . <Entity name: 7ffff265c10>) (102 . 
"}") (330 . <Entity name: 7ffff2459f0>) (100 . "AcDbEntity") (67 . 0) (410 . 
"Model") (8 . "G-Spce"))

Link to comment
Share on other sites

Unfortunately looks that the features of that entity aren’t exposed directly, so, without access to MEP, it will be very taught to debug a code to modify it.

Link to comment
Share on other sites

Welcome to CADTutor!

 

Provided that the text entity does not have any wonky formatting, this should work:

 

(defun c:RS () (c:RenameMepSpace))
(defun c:RenameMepSpace  (/ *error* _Nomutt)
 (princ "\rRENAMEMEPSPACE ")
 (vl-load-com)

 (defun *error*  (msg)
   (and oldNomutt (setvar 'nomutt oldNomutt))
   (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 _Nomutt  (on /)
   (if on
     (setvar 'nomutt 0)
     (setvar 'nomutt 1)))

 ((lambda (acDoc oldNomutt / ssSpace ssText name)
    (if (and (_Nomutt T)
             (princ "\nSelect space object to name: ")
             (_Nomutt nil)
             (setq ssSpace (ssget ":S:E:L" '((0 . "AEC_SPACE"))))
             (_Nomutt T)
             (princ "\nSelect text to name space object: ")
             (_Nomutt nil)
             (setq ssText (ssget ":S:E:L" '((0 . "MTEXT,TEXT")))))
      (progn
        (vla-startundomark acDoc)
        (setq name (vla-get-textstring
                     (vlax-ename->vla-object
                       (ssname ssText 0))))
        (while (vl-string-search "\\P" name)
          (setq name (vl-string-subst " " "\\P" name)))
        (vla-put-name
          (vlax-ename->vla-object (ssname ssSpace 0))
          name)
        (_Nomutt T)
        (prompt (strcat "\n\nMEP Space renamed  >>  " name))
        (*error* nil))
      (cond (ssText (*error* "No space selected"))
            ((*error* nil)))))
   (vla-get-activedocument (vlax-get-acad-object))
   (getvar 'nomutt)))

 

** Tested using AutoCAD MEP 2012

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