+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Forum Newbie
    Using
    MEP 2012
    Join Date
    May 2012
    Posts
    4

    Default LISP needed to rename Spaces by selecting text

    Registered forum members do not see this ad.

    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!
    Attached Images

  2. #2
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,942

    Default

    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.
    Code:
    (entget (car (entsel)))
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  3. #3
    Forum Newbie
    Using
    MEP 2012
    Join Date
    May 2012
    Posts
    4

    Default

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

    Code:
    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"))

  4. #4
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    3,942

    Default

    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.
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  5. #5
    Forum Newbie
    Using
    MEP 2012
    Join Date
    May 2012
    Posts
    4

    Default

    Ok, understood. Thank you for your time anyway.

    Maybe someone else with MEP could offer some insight.

  6. #6
    Forum Deity BlackBox's Avatar
    Computer Details
    BlackBox's Computer Details
    Operating System:
    Windows 8.1 Professional, Server 2012 R2 Datacenter
    Computer:
    Dell Precision T3600
    CPU:
    Hex-Core Intel Xeon 3.2Ghz
    RAM:
    32GB
    Graphics:
    3GB NVIDIA Quadro K4000
    Primary Storage:
    256GB SSD
    Secondary Storage:
    1TB Western Digital VelociRaptor 10K RPM
    Monitor:
    Dual 24" Dell Ultrasharp Widescreen Monitors
    Using
    Civil 3D 2015
    Join Date
    Nov 2009
    Posts
    4,606

    Default

    Welcome to CADTutor!

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

    Code:
    (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
    "Potential has a shelf life." - Margaret Atwood

    Autodesk Exchange Apps
    ~ Autoloader ~ AutoCAD Security

  7. #7
    Forum Newbie
    Using
    MEP 2012
    Join Date
    May 2012
    Posts
    4

    Default

    Wow, that was fast! Thank you so much!

  8. #8
    Forum Deity BlackBox's Avatar
    Computer Details
    BlackBox's Computer Details
    Operating System:
    Windows 8.1 Professional, Server 2012 R2 Datacenter
    Computer:
    Dell Precision T3600
    CPU:
    Hex-Core Intel Xeon 3.2Ghz
    RAM:
    32GB
    Graphics:
    3GB NVIDIA Quadro K4000
    Primary Storage:
    256GB SSD
    Secondary Storage:
    1TB Western Digital VelociRaptor 10K RPM
    Monitor:
    Dual 24" Dell Ultrasharp Widescreen Monitors
    Using
    Civil 3D 2015
    Join Date
    Nov 2009
    Posts
    4,606

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by mkp6486 View Post
    Wow, that was fast! Thank you so much!
    Happy to help.
    "Potential has a shelf life." - Margaret Atwood

    Autodesk Exchange Apps
    ~ Autoloader ~ AutoCAD Security

Similar Threads

  1. Lisp to remove spaces in a string
    By sadhu in forum AutoLISP, Visual LISP & DCL
    Replies: 11
    Last Post: 12th Mar 2014, 07:34 am
  2. Plotting Routine - Allow word with spaces for text entry for paper size??
    By ILoveMadoka in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 21st Jun 2011, 01:09 pm
  3. paper space text adding extra spaces when printing!?
    By Blueprint in forum AutoCAD Drawing Management & Output
    Replies: 1
    Last Post: 7th Apr 2010, 04:10 pm
  4. "text changing" lisp needed.
    By fleshget in forum AutoLISP, Visual LISP & DCL
    Replies: 13
    Last Post: 22nd Oct 2009, 04:24 pm
  5. text edit lisp needed
    By CadTechJGC184 in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 18th May 2009, 09:14 pm

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts