Jump to content

Recommended Posts

Posted

Hi folks,

 

I have received a bunch of TXT-documents describing a bunch of layers. The instructions say that the layer definitions are written the way they are so that they can be "lifted into different computersystems". What this actually means is anyones guess, it was written 1999.

 

My problem is that the only thing I find when searching for ways to "lift" layers-definitions into AutoCAD is by a lisp written by Tim Spangler, Layer Creator, which seems easy enough but the format that he uses is not the same as the one I have, example as follows:

 

// Tabell 2.223m				
// Utgåva 1 (1999)				
// Datum: 1999-10-15				
// Spänningsutjämning				
// Copyright AB Svensk Byggtjänst 1999				
// Tabellen baseras på BSAB 96 - byggdelar				
// Lagerdefinitionsfil enligt ISO 13567				
// med tillägg enligt SB 11 CAD-lager				
//				
//				
6.2	Element	6		
6-----	El- och telesystem		
	61----	El- och telekanalisationssystem	
	66----	System för spänningsutjämning och elektrisk separation	
		66B---	System för spänningsutjämning i elkraftsystem
		66C---	System för spänningsutjämning i teletekniskt system
		66D---	Åskskyddsystem
		66E---	System för skydd mot statisk elektricitet
		66F---	System för skydd mot elektromagnetisk störning
		66G---	System för potentialutjämnad närmiljö
		66H---	System för begränsning av elektriska eller magnetiska fält

 

So my question is simple; can I use the txt-files that I have and somehow get these into AutoCAD and create layers from it, in an easy fashion? Or am I SOL and have to manually create each layer?

 

Thanks for any input!

Posted

Are these the layer names?

 

66B---    System för spänningsutjämning i elkraftsystem
66C---    System för spänningsutjämning i teletekniskt system
66D---    Åskskyddsystem
66E---    System för skydd mot statisk elektricitet
66F---    System för skydd mot elektromagnetisk störning
66G---    System för potentialutjämnad närmiljö
66H---    System för begränsning av elektriska eller magnetiska fält

Or are the other 'headings' to be made into layers?

Posted

The layers should be on the format: X-XXXXXX--X

where the first X is always a letter (V in my case), the next 6 digits are the 66B--- from the list above, then two dashes (because I always work with the same presentation-level) and then one final letter that is T for temporary, R for demolition, O for original, F for moving objects, E for existing, N for new or U for reusable material.

 

The text in the list above is the Layer Description.

 

There's a lot of layers to be created...

Posted

Here's a start, unless I have misunderstood:

 

(defun c:CreateLayers ( / *error* _str->lst _readfile _makelayer file )

   (defun *error* ( msg )
       (if (and file (eq 'FILE (type file))) (setq file (close file)))
       (if (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*"))
           (princ (strcat "\nError: " msg))
       )
       (princ)
   )

   (defun _str->lst ( str del / pos )
       (if (setq pos (vl-string-search del str))
           (cons (substr str 1 pos) (_str->lst (substr str (+ pos 1 (strlen del))) del))
           (list str)
       )
   )

   (defun _readfile ( file / data line )
       (cond
           (   (setq file (open file "r"))
               (while (setq line (read-line file))
                   (if (wcmatch line "*//*")
                       (setq line (substr line 1 (vl-string-search "//" line)))
                   )
                   (if (not (eq "" (setq line (vl-string-trim " \t" line))))
                       (setq data (cons (_str->lst line "\t") data))
                   )
               )
               (setq file (close file))
           )
       )
       (reverse data)
   )

   (defun _makelayer ( name description )
       (if (null (tblsearch "LAYER" name))
           (entmakex
               (list
                  '(0 . "LAYER")
                  '(100 . "AcDbSymbolTableRecord")
                  '(100 . "AcDbLayerTableRecord")
                   (cons 2 name)
                  '(70 . 0)
                   (list -3
                       (list "AcAecLayerStandard"
                           '(1000 . "") (cons 1000 description)
                       )
                   )
               )
           )
       )
   )

   (regapp "AcAecLayerStandard")
   (if (setq file (getfiled "Select Data File" "" "txt" 16))
       (foreach line (_readfile file)
           (if (wcmatch (car line) "*-*")
               (foreach char '("T" "R" "O" "F" "E" "N" "U")
                   (_makelayer (strcat "V-" (car line) "--" char) (cadr line))
               )
           )
       )
   )
   (princ)
)
(vl-load-com) (princ)

Posted

Thanks Lee!

 

I'm at home right now and will probably not have time to check it out tomorrow (on site from early bird) but will try it out as soon as I can

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...