Results 1 to 8 of 8

Thread: QUES: Using a field, display _part_ of a layer name?

  1. #1
    Member
    Join Date
    2008-10
    Location
    South Africa
    Posts
    11
    Login to Give a bone
    0

    Question QUES: Using a field, display _part_ of a layer name?

    hello,

    new here, etc. trying to write my first lisp routine. well cobble it together from code i've found elsewhere....

    sorry if this is long-winded:

    i have a block with attributes; two of which are fields. one field reads the area of a polyline, the other the layer on which that polyline resides. the layer is important 'cus it shows what type of area the polyline is measuring (net internal, gross, etc).

    the lisp routine allows me to pick the polyline, then the block; editing the fields inside the block attributes to correctly refer to the correct polyline.

    our layer conventions dictate that there is some 'rubbish' before and after the part of the layer that describes the measurement type, and i want the field to ignore those bits and just give me the relevant information. there are 5no characters before and 4no after, that i'd like to 'ignore'.

    can anyone help? please?!

    oh, i used fields, because the block would update itself when ever the polyline was edited. ie the area altered, or the layer changed...

    thanks in advance
    Last edited by timbcurtis; 2008-11-15 at 03:37 PM. Reason: spelling/typo

  2. #2
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,804
    Login to Give a bone
    0

    Default Re: QUES: Using a field, display _part_ of a layer name?

    Quote Originally Posted by timbcurtis View Post
    ...and i want the field to ignore those bits and just give me the relevant information. there are 5no characters before and 4no after, that i'd like to 'ignore'.
    Try this...

    Code:
    
    
    (defun trimstr (s)
      (substr (setq s2 (substr s 6)) 1 (- (strlen s2) 4))
    )
    ;;; use like this
    (trimstr "12345MY LAYER NAME1234")
    "MY LAYER NAME"
    
    
    
    R.K. McSwain | CAD Panacea |

  3. #3
    Member
    Join Date
    2008-10
    Location
    South Africa
    Posts
    11
    Login to Give a bone
    0

    Unhappy Re: QUES: Using a field, display _part_ of a layer name?

    thanks.

    i tried something like that, but i think my problem is that i'm trying to do insert the polyline id into the field string, and i'm not sure where exactly to use a "trimstr"-like argument... i think i'm jst getting myslef confused!

    i'll post the lsp file and a dwg with my block....
    Attached Files Attached Files

  4. #4
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: QUES: Using a field, display _part_ of a layer name?

    Nope, unfortunately that can't be done. A FIELD can only use DIESEL expressions to manipulate strings like this:
    Code:
    $(substr,$(substr,12345MY LAYER NAME1234,6),1,$(-,$(strlen,$(substr,12345MY LAYER NAME1234,6)),4)
    Now, it is possible to add a nested field to get the Layer Name, but AutoCAD (for some stupid reason I've complained about before) converts that field into its string value. This only happens inside a DIESEL fieldcode, when you place a nested field inside a Formula it works correctly.

  5. #5
    Member
    Join Date
    2008-10
    Location
    South Africa
    Posts
    11
    Login to Give a bone
    0

    Red face Re: QUES: Using a field, display _part_ of a layer name?

    Quote Originally Posted by irneb View Post
    Nope, unfortunately that can't be done.

    well, that's no good.

    thanks for the help guys. i guess i'll just have to deal with the extra bits in the layer name. i can always take them out in excel, i guess.

  6. #6
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: QUES: Using a field, display _part_ of a layer name?

    Quote Originally Posted by timbcurtis View Post
    well, that's no good.

    thanks for the help guys. i guess i'll just have to deal with the extra bits in the layer name. i can always take them out in excel, i guess.
    You're right it's no good at all!

    You could use a custom LISP reactor instead of a FIELD, but unfortunately that would only work on the PC's you installed this reactor to.

    I think your safest bet would be to modify in Excel, I think the Trim, LTrim & RTim might be of use there.

    Otherwise as a work-around, you could create custom Materials in the DWG. Name them according to your areas, then assign each polyline with its relevant material. I'd suggest LAYISO, QSELECT and / or FILTER to make this easier. Unfortunately assigning a material to a layer, then setting the polyline to material ByLayer will only show ByLayer in the FIELD.

  7. #7
    Member
    Join Date
    2008-10
    Location
    South Africa
    Posts
    11
    Login to Give a bone
    0

    Default Re: QUES: Using a field, display _part_ of a layer name?

    thanks for all the tips

    i've managed to work around it by exporting all the data to one excel file, and getting a second to look at it for all the data, clean it up and present it in a more legible way. Tedious, but it works. luckily i don't really need to have the cleaned-up layer names on the actual drawings.

    Side question: any way to get DATAEXTRACTION to extract number data into an excel file actually as numbers?! the numbers are stored as text. it's very odd.

  8. #8
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: QUES: Using a field, display _part_ of a layer name?

    Quote Originally Posted by timbcurtis View Post
    Side question: any way to get DATAEXTRACTION to extract number data into an excel file actually as numbers?! the numbers are stored as text. it's very odd.
    It extracts all attribute data as text, even if it's numbers. The only number extracts would be calculated columns such as count. What I do to get around this is to extract to a XLS / CSV file, then using Excel's data wizard create an ODBC link to that data - in which case you can specify exactly what's actually in the column: text, integers, reals, dates, times, etc. But, then this becomes a two step process: export from AutoCAD, then Update from Excel. If you have Office 2007, you can set this to come into a table structure which makes formatting / formulas a lot easier and cleaner.

Similar Threads

  1. Field Display
    By Anthony Rhodes in forum AutoCAD Civil 3D - General
    Replies: 3
    Last Post: 2012-06-29, 12:50 AM
  2. Can I use a field to display label info?
    By kevin.jackman in forum AutoCAD Civil 3D - General
    Replies: 1
    Last Post: 2010-02-14, 05:41 AM
  3. Change display of layer without changing layer properties
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2006-09-11, 02:33 PM
  4. Replies: 4
    Last Post: 2006-08-04, 10:58 PM
  5. Grips in Multi-View blocks? ADT 2006 ques.
    By CADMama in forum ACA General
    Replies: 2
    Last Post: 2006-06-22, 04:27 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
  •