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

Thread: importing layer states via "layerstate-import" function

  1. #1
    Member
    Join Date
    2009-12
    Location
    Portland
    Posts
    26
    Login to Give a bone
    0

    Default importing layer states via "layerstate-import" function

    Has anyone sucessfully used the layerstate-import or layerstate-importfromdb function in a routine? I am trying to import predefined layerstates (four total) either directly as .las file or from a .dwg that contains them already. I tried as described in the AutoLISP reference guide from help, but doesn't seem to work.

    I have tried several variations of the example shown e.g. (layerstate-import “c:\\mylayerstate.las“)

    I also tried placing in .dwg file and using the layerstate-importfromdb function; with or without wild card (thinking maybe I could insert them all at the same time); with or without the .dwg and .las paths included in the support tree...

    I had a user request to be able to import firm standard layerstates into a drawing via macro and this seemed like the way to go...if anyone has done it this way, or has a different/better way, the info would be appreciated. I did get as far as a retun of nil which according to the example just means it didn't work...

    thanks.

  2. #2
    I could stop if I wanted to
    Join Date
    2009-03
    Location
    London, England
    Posts
    304
    Login to Give a bone
    0

    Default Re: importing layer states via "layerstate-import" function

    I import them in this program.

  3. #3
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,714
    Login to Give a bone
    0

    Default Re: importing layer states via "layerstate-import" function

    I use the layerstate* functions daily... well, mostly through automation I've implemented.

    I typically work with large plan sets (+/-100-550 sheets), only some of which have VISRETAIN=1, and we manage these sheets display via layer states.

    Within our project directory structure, we store / export these layer states (once set up) as *.LAS in a particular location. I've written a couple of functions that make working with these easier for us.

    Specifically, the *.LAS file that is stored in the project directory is considered our 'current' file, and every time a sheet is opened, if it is VISRETAIN=1, and has a matching name to one of the standardized layer state names, then it (the layer state within the drawing) is automatically deleted, and the one residing in the project directory is imported, and applied.

    This, combined with a quick Layer State Update function which automatically re-saves the current layer settings to the current layer state, and exports it to the project directory, makes managing layer states simple, and mostly automated. We hardly have to *think* about it, except for when changes occur, etc.

    Hope this helps!
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  4. #4
    Member
    Join Date
    2009-12
    Location
    Portland
    Posts
    26
    Login to Give a bone
    0

    Default Re: importing layer states via "layerstate-import" function

    It helps in that it lets me know those functions do indeed work. Not sure why they are not producing results for me. Obviously you have put a lot of time and thought into making your routines work; I'm just in the beginning state, realizing I can put them to work for me.

    I just want to use a little .lsp in a macro, where users can click a button and have all the standard layerstates magically appear.

    Knowing those functions work, I'll have to keep playing with them until I figure it out...thanks all.

    The logical place to start for me seemed to drop this into the command line and see if it produced "T" or "nil" (layerstate-import “c:\\mylayerstate.las“) But that's as far as I got...

  5. #5
    Member
    Join Date
    2009-12
    Location
    Portland
    Posts
    26
    Login to Give a bone
    0

    Default Re: importing layer states via "layerstate-import" function

    To be more focuessed, I guess one question is what does the "\\" mean in the previous example? Is the "\\" the help desk's way of saying "hey, we don't know where your layerstate lives, so put your own path in", or does it mean that as long as it's on the C: drive it will find it?

  6. #6
    I could stop if I wanted to
    Join Date
    2009-03
    Location
    London, England
    Posts
    304
    Login to Give a bone
    0

    Default Re: importing layer states via "layerstate-import" function

    Quote Originally Posted by snarlcad View Post
    To be more focuessed, I guess one question is what does the "\\" mean in the previous example?
    When supplying the layerstate-import function with the filename argument you will need to specify the full filepath of your .las file.

    In LISP, the backslash character '\' is an escape character. In short, this means that it is used to give subsequent characters an alternative meaning, for example with the newline character '\n' or the tab character '\t'.

    Hence to use a literal backslash in a string, you need to mark the backslash as literal by prefixing it with another backslash. '\\'.

    To see this effect, try the following:

    Code:
    (princ "\nA single backslash \\")
    Notice how the single backslash at the start of the string was used to give an alternative meaning to the 'n' character, creating a newline character. And similarly, the backslash prefixing another backslash '\\' marks it as a literal backslash.

    Have a read of this section of the Visual LISP IDE Help Documentation:

    Using the AutoLISP Language » AutoLISP Basics » Basic Output Functions » Control Characters in Strings

    If you are unsure how to access this help, see this short tutorial, this may also help.

    Now, how does this relate to the filepath I hear you ask...

    Well, in LISP there are two ways to specify a filepath: using double backslashes (each interpreted as a single backslash by the above explanation), or by using single forward slashes.

    e.g.
    Code:
    C:\\MyFolder\\MySubfolder\\MyFile.ext
    
    C:/MyFolder/MySubfolder/MyFile.ext
    Hence when using the layerstate-import function, you need to specify the full filepath of your .las file:

    Code:
    (layerstate-import "C:\\myfolder\\mysubfolder\\myfile.las")
    I haven't tested, but if the .las file resides in an AutoCAD support path, the layerstate-import function may be able to find it without a full filepath, i.e. just using "myfile.las", but otherwise you can use the findfile function to get the full filepath of such a file.

    I hope this helps,

    Lee

  7. #7
    Member
    Join Date
    2009-12
    Location
    Portland
    Posts
    26
    Login to Give a bone
    0

    Default Re: importing layer states via "layerstate-import" function

    I haven't tested it yet, but YES it helps a LOT. I think at one time or another I knew about the special formatting to place a file path, but forgot it...your explanation was terrific...I will try this again next time I get a chance and I'm sure it will work with the correct formatting...sometimes it's those little details that make all the difference...cheers!

  8. #8
    I could stop if I wanted to
    Join Date
    2009-03
    Location
    London, England
    Posts
    304
    Login to Give a bone
    0

    Default Re: importing layer states via "layerstate-import" function

    You're welcome snarlcad

  9. #9
    Member
    Join Date
    2007-02
    Posts
    3
    Login to Give a bone
    0

    Default Re: importing layer states via "layerstate-import" function

    I also use "steal" from Lee, but i need one that also brings the draw in the layers that i import and not only the layer without the draw.

  10. #10
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,714
    Login to Give a bone
    0

    Default Re: importing layer states via "layerstate-import" function

    Quote Originally Posted by osvaldo.cipriano View Post
    I also use "steal" from Lee, but i need one that also brings the draw in the layers that i import and not only the layer without the draw.
    Does 'draw' = 'entities'...?
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 4
    Last Post: 2014-01-01, 07:58 PM
  2. Replies: 0
    Last Post: 2011-03-15, 05:44 PM
  3. Can scripts be used to apply "Saved Layer States"
    By rdomke69 in forum AutoCAD General
    Replies: 2
    Last Post: 2008-01-24, 12:58 PM
  4. Replies: 4
    Last Post: 2006-11-10, 03:50 PM
  5. Replies: 13
    Last Post: 2006-11-06, 09:38 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
  •