+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Full Member
    Using
    AutoCAD 2014
    Join Date
    Apr 2014
    Posts
    96

    Default Layouts - vlax-for and vla-get-layouts

    Registered forum members do not see this ad.

    All,


    In AutoCAD 2016, and when using vlax-for and vla-get-layouts in the code below, I need to switch to a different layout before the new layout names are applied to the layouts.


    Code:
    (defun C:DEMO (/ tab str)
      (vl-load-com)
      (vlax-for lyt (vla-get-layouts
        (vla-get-activedocument (vlax-get-acad-object))
      )
        (setq tab (vla-get-name lyt))
        (setq str (substr tab 1 4))
        (vla-put-name lyt (strcat "2" str))
      )
      (princ)
    )
    Any ideas?


    Thanks

  2. #2
    Quantum Mechanic
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    10,011

    Default

    error: Automation Error. Cannot rename the Model layout need a IF to check tab is not Model

    Code:
    (defun C:DEMO (/ tab str)
      (vl-load-com)
      (vlax-for lyt (vla-get-layouts
        (vla-get-activedocument (vlax-get-acad-object))
      )
        (setq tab (vla-get-name lyt))
        (setq str (substr tab 1 4))
        (If (/= "Model" tab)
        (vla-put-name lyt (strcat "2" str))
        )
        )
      (princ)
    )
    (c:demo)
    A man who never made mistakes never made anything

  3. #3
    Full Member
    Using
    AutoCAD 2014
    Join Date
    Apr 2014
    Posts
    96

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by BIGAL View Post
    error: Automation Error. Cannot rename the Model layout need a IF to check tab is not Model

    Code:
    (defun C:DEMO (/ tab str)
      (vl-load-com)
      (vlax-for lyt (vla-get-layouts
        (vla-get-activedocument (vlax-get-acad-object))
      )
        (setq tab (vla-get-name lyt))
        (setq str (substr tab 1 4))
        (If (/= "Model" tab)
        (vla-put-name lyt (strcat "2" str))
        )
        )
      (princ)
    )
    (c:demo)



    Thanks BIGAL,


    Fixed it.


    SUBSTR starts at 1, not 0 as with other functions like NTH.


    Code:
    (defun C:DEMOX (/ tab str)
      (vl-load-com)
      (vlax-for lyt (vla-get-layouts
        (vla-get-activedocument (vlax-get-acad-object))
      )
        (setq tab (vla-get-name lyt))
        (setq str (substr tab 2 5))
        (if (not (eq "MODEL" (strcase (vla-get-name lyt))))
          (vla-put-name lyt (strcat "2" str))
        )
      )
      (princ)
    )
    Appreciate your help

Similar Threads

  1. for knowing layouts to .dwgs and .dwgs to layouts
    By 121madhu in forum AutoLISP, Visual LISP & DCL
    Replies: 11
    Last Post: 17th Jan 2014, 11:10 pm
  2. layouts
    By bjenk8100 in forum AutoCAD Beginners' Area
    Replies: 4
    Last Post: 1st Nov 2009, 10:25 am
  3. Layouts, i don't get it
    By the-trooper in forum AutoCAD Drawing Management & Output
    Replies: 7
    Last Post: 12th May 2008, 01:48 pm
  4. no. of layouts...
    By chrisdarmanin in forum AutoCAD Drawing Management & Output
    Replies: 18
    Last Post: 16th Dec 2006, 04:07 pm
  5. Layouts
    By Son of Aslan in forum AutoCAD Drawing Management & Output
    Replies: 1
    Last Post: 23rd Mar 2006, 09:50 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