+ Reply to Thread
Page 2 of 2 FirstFirst 1 2
Results 11 to 16 of 16

Thread: Layer Prefixes.

  1. #11
    Super Member Glen1980's Avatar
    Computer Details
    Glen1980's Computer Details
    Operating System:
    Work: 7 Pro 64 Home:8.1 Pro
    Computer:
    Work: HP Z420 Home: Custom Rig
    Motherboard:
    Work: Intel Home: Gigabyte B95M
    CPU:
    Work: ZeonE5-1620v3 @ 3.6GHz Home:i7 4790K 4Ghz
    RAM:
    Work: 16GB Home: 16GB Corsair Vengeance 1600 GHz
    Graphics:
    Work: NVIDIA Quaddro K2200 Home: Geforce GT 960
    Primary Storage:
    Work: 256GB SSD Home: 500GB Crucial MX100 SSD
    Secondary Storage:
    Work: 500 GB 7200RPM Home: LAN access to drive
    Monitor:
    Work: Twin LG 24" Home: Single 29" Ultra wide LG
    Discipline
    Architectural
    Glen1980's Discipline Details
    Occupation
    Architectural Technician - Residential
    Discipline
    Architectural
    Details
    High Rise concrete frame. Low Rise traditional masonry construction Low Rise Timber Frame Conversion - Office, Schools & Colleges, Hospitals to residential flats/apartments.
    Using
    AutoCAD 2016
    Join Date
    Feb 2007
    Location
    Herts/Essex, England
    Posts
    686

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by pBe View Post
    You dont need to change every time you open a drawing. if you use the first code i posted via script

    _.open "C:\Folderpath\54512Project.dwg" (FIXPREFIX "54512" "512") _.save _close
    _.open "C:\Folderpath\78427Project.dwg" (FIXPREFIX "78427" "427") _.save _close
    I wondered why I couldn't make the first code work. I'll have a play after lunch.
    "Remember Baldrick, we are not at home to Mr Cock Up" - E Blackadder

  2. #12
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,873

    Default

    Quote Originally Posted by Glen1980 View Post
    I wondered why I couldn't make the first code work. I'll have a play after lunch.
    Perhaps you can use the code at post #10

    You can however still use LMs' ODX Wrapper by referencing the drawing filename for variable oldprefix
    e.g.

    Given the Filename prefix is the same as the Layer names prefixes.
    Drawing name: 85391-FloorPlan.dwg

    Code:
     (setq fname (vla-get-name (vla-get-ActiveDocument (vlax-get-acad-object))))
    85391-FloorPlan.dwg
    Code:
     (if
          (assoc (setq OldPrefix (substr fname 1 5))
                 '(("65477" . "477")("85391" . "391")("297671" . "671")))
          (dothis)
          )
    HTH

  3. #13
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    17,578

    Default

    Quote Originally Posted by pBe View Post
    Sample using Lee Macs' ObjextDBX Wrapper

    Code:
    (defun c:sample ( / _FIXPREFIX )
    (defun _FIXPREFIX (OldPrefix NewPrefix doc )
     (vlax-for layer (vla-get-layers doc)
                (if (wcmatch
                          (setq ln (vla-get-name layer))
                          (strcat OldPrefix "*"))
                      (vla-put-name
                            layer
                            (vl-string-subst NewPrefix OldPrefix ln)))
            )
        )
       (LM:ODBX '_FIXPREFIX "12345" "ABC")
        (princ)
    )
    Many thanks for the recommendation pBe, much appreciated

    However, the example would need to be:

    Code:
    (defun c:sample ( / _fixprefix )
    
        (defun _fixprefix ( oldprefix newprefix doc )
            (vlax-for layer (vla-get-layers doc)
                (if (wcmatch (vla-get-name layer) (strcat oldprefix "*"))
                    (vla-put-name layer (vl-string-subst newprefix oldprefix (vla-get-name layer)))
                )
            )
        )
    
        (LM:ODBX '(lambda ( doc ) (_fixprefix "12345" "ABC" doc)) nil t)
        (princ)
    )
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  4. #14
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,873

    Default

    Quote Originally Posted by Lee Mac View Post
    Code:
    (LM:ODBX '(lambda ( doc ) (_fixprefix "12345" "ABC" doc)) nil t)
    (princ)
    )
    Oh my

    We wouldnt want those arguments missing now do we...
    Apologies Lee

    Cheers

  5. #15
    Super Member Glen1980's Avatar
    Computer Details
    Glen1980's Computer Details
    Operating System:
    Work: 7 Pro 64 Home:8.1 Pro
    Computer:
    Work: HP Z420 Home: Custom Rig
    Motherboard:
    Work: Intel Home: Gigabyte B95M
    CPU:
    Work: ZeonE5-1620v3 @ 3.6GHz Home:i7 4790K 4Ghz
    RAM:
    Work: 16GB Home: 16GB Corsair Vengeance 1600 GHz
    Graphics:
    Work: NVIDIA Quaddro K2200 Home: Geforce GT 960
    Primary Storage:
    Work: 256GB SSD Home: 500GB Crucial MX100 SSD
    Secondary Storage:
    Work: 500 GB 7200RPM Home: LAN access to drive
    Monitor:
    Work: Twin LG 24" Home: Single 29" Ultra wide LG
    Discipline
    Architectural
    Glen1980's Discipline Details
    Occupation
    Architectural Technician - Residential
    Discipline
    Architectural
    Details
    High Rise concrete frame. Low Rise traditional masonry construction Low Rise Timber Frame Conversion - Office, Schools & Colleges, Hospitals to residential flats/apartments.
    Using
    AutoCAD 2016
    Join Date
    Feb 2007
    Location
    Herts/Essex, England
    Posts
    686

    Default

    Cheers guys.

    Hopefully I won't have to use this LISP again but you never can tell when people will decide to different stuff.
    "Remember Baldrick, we are not at home to Mr Cock Up" - E Blackadder

  6. #16
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    17,578

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by pBe View Post
    Oh my

    We wouldnt want those arguments missing now do we...
    Apologies Lee
    No worries dude
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

Similar Threads

  1. [2007] Fatal error on opening layer list and layer isolate
    By Prorad in forum AutoCAD Bugs, Error Messages & Quirks
    Replies: 8
    Last Post: 6th Dec 2013, 11:38 pm
  2. Replies: 3
    Last Post: 16th Feb 2012, 09:48 pm
  3. Replies: 5
    Last Post: 19th Oct 2010, 01:36 pm
  4. Notepad Prefixes Showing
    By gsksun4 in forum AutoCAD Beginners' Area
    Replies: 0
    Last Post: 7th May 2010, 06:57 pm
  5. Tough Question - Layer Locking (Make Layer Visible But No Pick)
    By johnshar123xx in forum AutoCAD General
    Replies: 1
    Last Post: 21st Nov 2008, 03:20 pm

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