Author Topic: Layer Creator Project  (Read 38958 times)

0 Members and 1 Guest are viewing this topic.

VovKa

  • Water Moccasin
  • Posts: 1626
  • Ukraine
Re: Layer Creator Project
« Reply #30 on: July 02, 2008, 04:34:49 PM »
chances for mistakes from the end user.
that's for sure, and that's why i use dbx

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Layer Creator Project
« Reply #31 on: July 02, 2008, 04:36:07 PM »
My wish was to keep the data file as easy to maintain as possible.
Using the example file "Framing Layer Data File" I posted, you can still use tab
as the separator.
Where do you see the errors creeping in with that format?
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: Layer Creator Project
« Reply #32 on: July 02, 2008, 04:37:12 PM »
Tim,

I don't have an image of the form, but I use Layer Filters defined in the Layer Data File to "sort" Layers in the Import Layer form.  And yes, ObjectDBX is very powerful: I have Forms to import Views and Blocks, I have a form that pulls all our ADT stuff, styles etc, from a main ADT Data Drawing where all our styles are defined. That drawing is the defined ADT Standards drawing - so as I update / edit styles I use this tool to update a Project - and of course the next time a user starts drawing a wall (even if it's note already defined in the active drawing)they have the latest style definition instantly via ObjectDBX.

The nice thing about this type of program - management theory is A: the template drawing doesn't necessarily have to contain all Layers (Blocks, Views, ADT Styles, etc.) B: When used with AutoCAD's Standards tool it makes managing Office Standards a breeze, and C: the user decides what layers (s)he needs at any point in time - instead of inserting an entire drawing (one place I worked had over 700 standard layers!)
James Buzbee
Windows 8

JohnK

  • Administrator
  • Seagull
  • Posts: 10604
Re: Layer Creator Project
« Reply #33 on: July 02, 2008, 04:41:08 PM »
VovKa,

My thought when i was creating my layer creator was that a delimited file for my layers was a pain to maintain. So i made mine use the AutoCAD method (list of lists). ...Give this one a try:
http://www.theswamp.org/index.php?topic=23173.msg280776#msg280776

Load it up and just cancel the dialog box that will pop up.
Use the (save-layer-list-to-file) function to save a layer file you can look at. Then you can see what im talking about. The whole process fast and fairly clean.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

JohnK

  • Administrator
  • Seagull
  • Posts: 10604
Re: Layer Creator Project
« Reply #34 on: July 02, 2008, 04:42:50 PM »
My wish was to keep the data file as easy to maintain as possible.
Using the example file "Framing Layer Data File" I posted, you can still use tab
as the separator.
Where do you see the errors creeping in with that format?

1.) I dislike tabs in general so i disable them in my editor; i use spaces instead.
2.) A user in Notepad just hits the space bar instead of tab.
3.) A user uses two tabs instead of one.
...
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

JohnK

  • Administrator
  • Seagull
  • Posts: 10604
Re: Layer Creator Project
« Reply #35 on: July 02, 2008, 04:43:42 PM »
chances for mistakes from the end user.
that's for sure, and that's why i use dbx
now that is a good point!
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

VovKa

  • Water Moccasin
  • Posts: 1626
  • Ukraine
Re: Layer Creator Project
« Reply #36 on: July 02, 2008, 04:44:07 PM »
Where do you see the errors creeping in with that format?
an old lady drafting all day long and expecting computer to be smart enough to read her thougts, will surely find a way to crash any application :)
maybe misspelling, maybe typing ":" instead of ";" somewhere in data file, end users are rather ingenious...

JohnK

  • Administrator
  • Seagull
  • Posts: 10604
Re: Layer Creator Project
« Reply #37 on: July 02, 2008, 04:45:48 PM »
Tim,

I don't have an image of the form, but I use Layer Filters defined in the Layer Data File to "sort" Layers in the Import Layer form.  And yes, ObjectDBX is very powerful: I have Forms to import Views and Blocks, I have a form that pulls all our ADT stuff, styles etc, from a main ADT Data Drawing where all our styles are defined. That drawing is the defined ADT Standards drawing - so as I update / edit styles I use this tool to update a Project - and of course the next time a user starts drawing a wall (even if it's note already defined in the active drawing)they have the latest style definition instantly via ObjectDBX.

The nice thing about this type of program - management theory is A: the template drawing doesn't necessarily have to contain all Layers (Blocks, Views, ADT Styles, etc.) B: When used with AutoCAD's Standards tool it makes managing Office Standards a breeze, and C: the user decides what layers (s)he needs at any point in time - instead of inserting an entire drawing (one place I worked had over 700 standard layers!)

My AutoLisp version was tested on 10,000 layers and took about 1 second. How long would it take for ODBX?
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Layer Creator Project
« Reply #38 on: July 02, 2008, 04:57:05 PM »
Won't correct layers.  I have a routine that will correct the layers to meet company standards if the don't.  You have to use code to do it, and I use ODBX.

Tim do you have a link to your latest routine?
Here you go Alan.

[ http://www.theswamp.org/index.php?topic=12845.msg156899#msg156899 ]
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

VovKa

  • Water Moccasin
  • Posts: 1626
  • Ukraine
Re: Layer Creator Project
« Reply #39 on: July 02, 2008, 04:57:31 PM »
45 seconds

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Layer Creator Project
« Reply #40 on: July 02, 2008, 04:58:27 PM »
ODBX or read from a text file to me is the same, just that a drawing you know has to have layers laid out correctly.  I don't use text files I only use drawings, and I have the drawings separated out to disciplines.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

JohnK

  • Administrator
  • Seagull
  • Posts: 10604
Re: Layer Creator Project
« Reply #41 on: July 02, 2008, 05:08:34 PM »
45 seconds?!?!  ...No way. I wrote that one because the previous one here (i didnt write it, it was before my time) took 3 seconds for 100 layers!?! *lol*
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Layer Creator Project
« Reply #42 on: July 02, 2008, 05:10:05 PM »
Will not overwrite, but will create if not there.  Worked on the test list except for some linetypes that I don't have, and that didn't stop the command from running.

Had to use one ActiveX call, as I don't know how else to get a linetype into the table without it or a 'command' call.

Code: [Select]
(defun c:Test (/ LtCol LtFileList File Opened Str tempStr LayPat tempList Dflt LayList PltStyList tempData tempName
    tempLt LtList Found tempPs)
   
    (defun GetPlotStyleList (/ tempName tempList)
       
        (foreach i (dictsearch (namedobjdict) "ACAD_PLOTSTYLENAME")
            (cond
                ((equal (car i) 3)
                    (setq tempName (cdr i))
                )
                ((equal (car i) 350)
                    (setq tempList (cons (cons tempName (cdr i)) tempList))
                )
            )
        )
        tempList
    )
    ;------------------------------------------------------
    (defun ReadLinetypeFile (Path / Opened tempStr tempList)
       
        (setq Opened (open Path "r"))
        (while (setq tempStr (read-line Opened))
            (if (= (substr tempStr 1 1) "*")
                (setq tempList
                    (cons
                        (strcase (car (StrParse (substr tempStr 2) ",")))
                        tempList
                    )
                )
            )
        )
        (close Opened)
        tempList
    )
    ;-----------------------------------------------------------------
    (setq LtCol (vla-get-Linetypes (vla-get-ActiveDocument (vlax-get-Acad-Object))))
    (setq LtFileList
        (list
            (if (equal (getvar 'Measurement) 0)
                "acad.lin"
                "acadiso.lin"
            )
        )
    )
    (if
        (and
            (setq File (getfiled "Select layer definition file." "" "lay" 4))
            (setq Opened (open File "r"))
            (progn
                (while (setq Str (read-line Opened))
                    (setq tempStr (substr Str 1 2))
                    (cond
                        ((= tempStr "*-")
                            (setq LtFileList (cons (substr Str 4) LtFileList))
                        )
                        ((= tempStr "*/")
                            (setq LayPat (StrParse (substr Str 4) " "))
                            (foreach i LayPat
                                (if (> (strlen i) 0)
                                    (setq tempList (cons i tempList))
                                )
                            )
                            (setq LayPat (mapcar 'strcase (reverse tempList)))
                        )
                        ((= tempStr "*+")
                            (setq Dflt (mapcar 'RemoveSpace (StrParse (substr Str 4) (car LayPat))))
                        )
                        (
                            (and
                                (/= (substr tempStr 1 1) "*")
                                (/= tempStr "")
                                (/= (substr tempStr 1 1) " ")
                            )
                            (setq LayList
                                (cons
                                    (mapcar 'RemoveSpace (StrParse Str (car LayPat)))
                                    LayList
                                )
                            )
                        )
                    )
                )
                (close Opened)
                LayList
            )
            Dflt
            (setq LayPat (cdr LayPat))
            (setq ListLen (length LayPat))
            (setq PltStyList (GetPlotStyleList))
        )
        (foreach i LayList
            (setq cnt 0)
            (setq tempData '((70 . 0)))
            (repeat ListLen
                (setq tempProp (nth cnt LayPat))
                (setq tempValue (nth cnt i))
                (cond
                    ((= tempProp "NAME")
                        (setq tempData
                            (cons
                                (cons 2 (setq tempName tempValue))
                                tempData
                            )
                        )
                    )
                    ((= tempProp "PLOTSTYLENAME")
                        (setq tempData
                            (cons
                                (if (setq tempPs (assoc tempValue PltStyList))
                                    (cons 390 (cdr (assoc tempValue PltStyList)))
                                    (cons 390 (cdr (assoc "Normal" PltStyList)))
                                )
                                tempData
                            )
                        )
                    )
                    ((= tempProp "COLOR")
                        (setq tempData
                            (if (setq tempList (assoc 62 tempData))
                                (subst
                                    (cons
                                        62
                                        (if (< (cdr tempList) 0)
                                            (* -1 tempValue)
                                            tempValue
                                        )
                                    )
                                    tempList
                                    tempData
                                )
                                (cons
                                    (cons 62 (atoi tempValue))
                                    tempData
                                )
                            )
                        )
                    )
                    ((= tempProp "LINETYPE")
                        (setq tempData
                            (cons
                                (cons 6 (setq tempLt (strcase tempValue)))
                                tempData
                            )
                        )
                    )
                    ((= tempProp "FREEZE")
                        (if (= tempValue "FREEZE")
                            (setq tempData
                                (if (setq tempList (assoc 70 tempData))
                                    (subst
                                        (cons
                                            70
                                            (1+ (cdr tempList))
                                        )
                                        tempList
                                        tempData
                                    )
                                    (cons
                                        (cons 70 1)
                                        tempData
                                    )
                                )
                            )
                        )
                    )
                    ((= tempProp "LOCK")
                        (if (= tempValue "LOCK")
                            (setq tempData
                                (if (setq tempList (assoc 70 tempData))
                                    (subst
                                        (cons
                                            70
                                            (+ (cdr tempList) 4)
                                        )
                                        tempList
                                        tempData
                                    )
                                    (cons
                                        (cons 70 4)
                                        tempData
                                    )
                                )
                            )
                        )
                    )
                    ((= tempProp "LAYERON")
                        (if (= tempValue "OFF")
                            (setq tempData
                                (if (setq tempList (assoc 62 tempData))
                                    (subst
                                        (cons
                                            62
                                            (* -1 (cdr tempList))
                                        )
                                        tempList
                                        tempData
                                    )
                                    (cons
                                        (cons 62 -7)
                                        tempData
                                    )
                                )
                            )
                        )
                    )
                )
                (setq cnt (1+ cnt))
            )
            (if (not (tblsearch "LType" tempLt))
                (foreach i LtFileList
                    (setq Found nil)
                    (if (not Found)
                        (progn
                            (if (not (assoc i LtList))
                                (setq LtList
                                    (cons
                                        (cons i (ReadLinetypeFile (findfile i)))
                                        LtList
                                    )
                                )
                            )
                            (setq tempList (assoc i LtList))
                            (if (member tempLt tempList)
                                (progn
                                    (vlax-invoke LtCol 'Load tempLt i)
                                    (setq Found T)
                                )
                            )
                        )
                    )
                )
            )
            (if
                (not
                    (entmake
                        (append
                            '(
                                (0 . "LAYER")
                                (100 . "AcDbSymbolTableRecord")
                                (100 . "AcDbLayerTableRecord")
                            )
                            (reverse tempData)
                        )
                    )
                )
                (prompt (strcat "\n Could not make layer: " tempName))
            )
        )
    )
    (princ)
)

Edit:
Forgot to post the subs.

Code: [Select]
(defun RemoveSpace (String / cnt)
; Remove spaces from begining and end of string

(while (= (substr String 1 1) " ")
(setq String (substr String 2 (strlen String)))
)
(setq cnt (strlen String))
(while
(and
(> cnt 0)
(= (substr String cnt 1) " ")
)
(setq cnt (1- cnt))
)
(substr String 1 cnt)
)
;----------------------------------------------
(defun StrParse (String Seperator / Pos1 Pos2 NewStrList)
;|
  Seperator a string (making a list of stings) at a given
  string value
  ie: (StrParse "1,1,0" ",")
  returns: ("1" "1" "0")
  Written when I couldn't find it on the web
  By: Tim Willey 11/15/2004
|;

(setq Pos2 1)
(while (setq Pos1 (vl-string-search Seperator String Pos1))
(if (= Pos2 1)
(setq NewStrList (cons (substr String Pos2 Pos1) NewStrList))
(setq NewStrList (cons (substr String Pos2 (- (1+ Pos1) Pos2)) NewStrList))
)
(setq Pos2 (1+ (+ (strlen Seperator) Pos1)))
(setq Pos1 (+ Pos1 (strlen Seperator)))
)
(reverse (setq NewStrList (cons (substr String Pos2) NewStrList)))
)
« Last Edit: July 02, 2008, 05:22:36 PM by T.Willey »
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

JohnK

  • Administrator
  • Seagull
  • Posts: 10604
Re: Layer Creator Project
« Reply #43 on: July 02, 2008, 05:15:59 PM »
T.Willey,
How do you code up some of these larger lisps in so little time...You must type 1000 words per min!?
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

VovKa

  • Water Moccasin
  • Posts: 1626
  • Ukraine
Re: Layer Creator Project
« Reply #44 on: July 02, 2008, 05:19:19 PM »
took 3 seconds for 100 layers!?! *lol*
my dbx loads 100 layers in tenths of a second, so not a problem for me :)