See the top rated post in this thread. Click here

Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Create Layer name using the Drawing name

  1. #1
    Member
    Join Date
    2008-06
    Posts
    39
    Login to Give a bone
    0

    Default Create Layer name using the Drawing name

    Is it possible to create a layer using the drawing name minus the .dwg extension? I want to create a lisp file that automatically sets the layer name to drawing name with an X- in front of it.

  2. #2
    Member
    Join Date
    2005-01
    Posts
    42
    Login to Give a bone
    0

    Default Re: Create Layer name using the Drawing name

    Hi-

    Here is a quick tool that will create a layer using the drawing name with the prefix of "X-".

    Code:
    (defun c:dwglayer ()
    (setq lay (strcat "X-" (vl-filename-base (getvar "dwgname"))))
    (command "layer" "m" lay "")
    )
    Hope this helps.
    Last edited by Opie; 2009-01-05 at 07:14 PM. Reason: [code] tags added

  3. #3
    Member
    Join Date
    2008-06
    Posts
    39
    Login to Give a bone
    0

    Default Re: Create Layer name using the Drawing name

    That works but can I make it obtain the Referenced file name as oppose to the current drawing name?

  4. #4
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,105
    Login to Give a bone
    1

    Default Re: Create Layer name using the Drawing name

    Quote Originally Posted by g_wong View Post
    That works but can I make it obtain the Referenced file name as oppose to the current drawing name?
    So you are referring to creating a layer based on an xref or referenced drawing?
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  5. #5
    Member
    Join Date
    2008-06
    Posts
    39
    Login to Give a bone
    0

    Default Re: Create Layer name using the Drawing name

    Yeah that is what I want to accomplish.

  6. #6
    Member
    Join Date
    2005-01
    Posts
    42
    Login to Give a bone
    0

    Default Re: Create Layer name using the Drawing name

    Quote Originally Posted by g_wong View Post
    Yeah that is what I want to accomplish.
    Is there more than one xref?

  7. #7
    Member
    Join Date
    2008-06
    Posts
    39
    Login to Give a bone
    0

    Default Re: Create Layer name using the Drawing name

    The company standards are to create one layer per XREF, this takes quite a bit of time so if there is someway to automate it thru a lisp command that would be fantastic.

  8. #8
    Member
    Join Date
    2005-01
    Posts
    42
    Login to Give a bone
    0

    Default Re: Create Layer name using the Drawing name

    Give this a try.

    Code:
    (defun c:dwglayer (/ lay)
    (vlax-for item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
      (if (= (vla-get-isxref item) ':vlax-true)
        (progn
          (setq lay (strcat "X-" (vla-get-name item)))
          (command "layer" "m" lay "")
        )
      )
    )
    (princ)
    )
    Last edited by Opie; 2009-01-05 at 07:50 PM. Reason: [code] tags added

  9. #9
    I could stop if I wanted to
    Join Date
    2005-09
    Location
    Canada
    Posts
    214
    Login to Give a bone
    0

    Default Re: Create Layer name using the Drawing name

    Quote Originally Posted by jsowinski View Post
    Hi-

    Here is a quick tool that will create a layer using the drawing name with the prefix of "X-".

    Code:
    (defun c:dwglayer ()
    (setq lay (strcat "X-" (vl-filename-base (getvar "dwgname"))))
    (command "layer" "m" lay "")
    )
    Hope this helps.
    Never forget to Undescore AutoCAd command....
    Code:
    (command "._layer" "_m" lay "")
    and many add condition if layer exist...

    Code:
    (defun c:dwglayer (/ LayerName)
    (setq LayerName (strcat "X-" (vl-filename-base (getvar "dwgname"))))    
    (if (not (tblsearch "LAYER" (strcase LayerName)))   
    (vla-Add (vla-get-Layers (vla-get-ActiveDocument (vlax-get-Acad-Object))) LayerName)
    )
    )

  10. #10
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,105
    Login to Give a bone
    0

    Default Re: Create Layer name using the Drawing name

    Quote Originally Posted by g_wong View Post
    The company standards are to create one layer per XREF, this takes quite a bit of time so if there is someway to automate it thru a lisp command that would be fantastic.
    Typically, are your reference drawing names the same as the filename? Or does your company rename the reference name to a more common name?
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

Page 1 of 2 12 LastLast

Similar Threads

  1. LISP to create layer, hatch and set layer back to original.
    By jpcadconsulting347236 in forum AutoLISP
    Replies: 1
    Last Post: 2013-12-11, 07:22 PM
  2. Ability to Create a Layer that Acts Similar to Layer 0
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2008-05-28, 06:58 PM
  3. Replies: 3
    Last Post: 2007-03-14, 01:33 PM
  4. Replies: 2
    Last Post: 2006-05-10, 06:38 PM
  5. Replies: 19
    Last Post: 2006-02-12, 11:06 PM

Posting Permissions

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