Author Topic: Layer 0 properties..  (Read 3485 times)

0 Members and 1 Guest are viewing this topic.

Andrea

  • Water Moccasin
  • Posts: 2372
Layer 0 properties..
« on: March 15, 2006, 08:16:48 AM »
Hi all,

Simple question..but don't know where to start..

We use many diffrent client standards here...
some of these standard is a blank dwg with all layer, linetype, dimstyle etc... on it
who is insert each time in an existing drawing, that create layer dimstyle etc...

the problem is.
I would like to overwrite the layer dimstyle etc..
specialy the propreties of layer 0.

sure it will be more simple to insert the drawing in this blanked dwg....
but you know....xref, layout, etc..  :|

I can use also a template.... but some drawing comes from others company.

Is there any way to do that ?

thanks in advance.
Keep smile...

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Layer 0 properties..
« Reply #1 on: March 15, 2006, 08:22:59 AM »
what all do you want to change?
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Layer 0 properties..
« Reply #2 on: March 15, 2006, 08:29:25 AM »
what all do you want to change?

the first step...is
to force all propreties layer, specially layer 0

second.
force and update all dimstyle

lets start with this....for the moment.
Keep smile...

kpblc

  • Bull Frog
  • Posts: 396
Re: Layer 0 properties..
« Reply #3 on: March 15, 2006, 09:34:28 AM »
May be, these codes helps you?
First of all, you have to create text style. Use this:
Code: [Select]
;|=============================================================================
* Author: kpblc (kpblc2000@gmail.com) (Sept 16 2005)
*    Creates and activate standard text style
*    Call parameters:
* none
*    sample of call:
(_kpblc-style-create-textstyle)
===============================================================================|;
(defun _kpblc-create-textstyle (/ ent_list font_filename exist_style)
  (if (findfile "spds.shx") ; it's my standard font file name, use yours
    (setq font_filename (strcat (vl-filename-base (findfile "spds.shx")) ".shx"))
    (setq font_filename (strcat (vl-filename-base (findfile "simplex.shx")) ".shx"))
    ) ;_ end of if
  (setq   ent_list
    (list
      '(0 . "STYLE")
      '(100 . "AcDbSymbolTableRecord")
      '(100 . "AcDbTextStyleTableRecord")
      '(2 . "SPDS")      ; text style name. It's also my standard name. Use yours
      '(70 . 0)         ;
      '(40 . 0.0)         ; text height
      '(41 . 0.8)         ; width factor
      '(50 . 0.0)         ; oblique angle
      '(71 . 0)         ; not backwatf, not upside down
      '(42 . 2.5)         ; last height used
      (cons 3 font_filename)   ; primary font file name
      '(4 . "")         ; big font file name
      ) ;_ end of list
   ) ;_ end of setq
               ;(entmake ent_list)
  (if (setq exist_style (tblobjname "style" "SPDS"))
    ;; Style exist, make it as standard
    (foreach item ent_list
      (_kpblc-ent-modify exist_style (car item) (cdr item))
      ) ;_ end of foreach
    ;; style not exist
    (entmake ent_list)
    ) ;_ end of if
  (setvar "textstyle" "SPDS")
               ;(princ)
  ) ;_ end of defun
After you creates text style, you can create dimstyle. Something like this:
Code: [Select]
|=============================================================================
* Author: kpblc (kpblc2000@gmail.com) (Sept 16 2005)
*    Creates and activate standard dim style
*    Call parameters:
* none
*    sample of call:
(_kpblc-style-create-dimstyle)
===============================================================================|;(defun _kpblc-create-dimstyle
       (/ ent_list exist_style arrow_block active_dimstyle)

  (defun _kpblc-create-sub-dimstyle (style-number / ent_list ent_name)
    (setq ent_name (if style-number
     (strcat "SPDS$" (itoa style-number))
     "SPDS"
     ) ;_ end of if
  ent_list
   (list
     (cons 0 "DIMSTYLE") ;      @R@
     (cons 100 "AcDbSymbolTableRecord") ;      @R@
     (cons 100 "AcDbDimStyleTableRecord") ;      @R@
     (cons 2 ent_name) ;dimsty      @R@
     (cons 70
   (if (not style-number)
     0
     style-number
     ) ;_ end of if
   ) ; @R@
     (cons 40 (getvar "dimscale")) ;dimscale   @R@
     (cons 41 2.5) ;dimsz      @R@
     (cons 42 0.625) ;dimexo      @R@
     (cons 43 3.75) ;dimdli      @R@
     (cons 44 1.25) ;dimexe      @R@
     (cons 45 0.5) ;dimrnd      @R@
     (cons 46 0.0) ;dimdle      @R@
     (cons 140 2.5) ;dimtxt      @R@
     (cons 141 -2.5) ;dimcen      @R@
     (cons 143 0.005) ;dimaltf   @R@
     (cons 144 1) ;dimlfac
     (cons 145 0) ;dimtvp
     (cons 147 0.5) ;dimgap      @R@
     (cons 72 0) ;dimlim
     (cons 73 0) ;dimtih      @R@
     (cons 74 0) ;dimtoh      @R@
     (cons 77 1) ;dimtad      @R@
     (cons 78 8) ;dimzin      @R@
     (cons 79 2) ;dimazin   @R@
     (cons 170 0) ;dimalt
     (cons 172 1) ;dimtofl   @R@
     (cons 173 0) ;dimsah      @R@
     (cons 174 0) ;dimtix
     (cons 175 1) ;dimsoxd
     (cons 176 0) ;dimclrd
     (cons 177 0) ;dimclre
     (cons 178 0) ;dimclrt
     (cons 179 1) ;dimadec
     (cons 271 0) ;dimdec      @R@
     (cons 272 0) ;dimtdec   @R@
     (cons 275 1) ;dimaunit
     (cons 277 2) ;dimlunit
     (cons 278 44) ;dimdsep   @R@
     (cons 279 ;dimtmove
   (cond
     ((not style-number) 0)
     ((= style-number 0) 1)
     ((= style-number 1) 1)
     (t 1)
     ) ;_ end of cond
   ) ;_ end of cons
     (cons 280 0) ;dimjust
     (cons 281 0) ;dimsd1
     (cons 282 0) ;dimsd2
     (cons 283 0) ;dimtolj
     (cons 284 8) ;dimtzin
     (cons 288 0) ;dimupt
     (cons 340 (tblobjname "style" "SPDS")) ;dimtxtsty   @R@
     (cons 371 -2) ;dimlwd
     (cons 372 -2) ;dimlwe
     ) ;_ end of list
  ) ;_ end of setq
    (if (member style-number '(nil 0 1))
      (progn
(setq ent_list
       (reverse
(cons
   (cons 342
(cdr
   (assoc 330
  (entget
    (tblobjname "block" "_archtick")
    ) ;_ end of entget
  ) ;_ end of assoc
   ) ;_ end of cdr
) ;dimblk      @R@
   (reverse ent_list)
   ) ;_ end of cons
) ;_ end of reverse
      ) ;_ end of setq
(setq ent_list
       (reverse
(cons
   (cons 343
(cdr
   (assoc 330
  (entget
    (tblobjname "block" "_archtick")
    ) ;_ end of entget
  ) ;_ end of assoc
   ) ;_ end of cdr
) ;dimblk1
   (reverse ent_list)
   ) ;_ end of cons
) ;_ end of reverse
      ) ;_ end of setq
(setq ent_list
       (reverse
(cons
   (cons 344
(cdr
   (assoc 330
  (entget
    (tblobjname "block" "_archtick")
    ) ;_ end of entget
  ) ;_ end of assoc
   ) ;_ end of cdr
) ;dimblk2
   (reverse ent_list)
   ) ;_ end of cons
) ;_ end of reverse
      ) ;_ end of setq
) ;_ end of setq
      ) ;_ end of if
    (if (setq exist_style (tblobjname "dimstyle" ent_name))
      (foreach item ent_list
(_kpblc-ent-modify exist_style (car item) (cdr item))
) ;_ end of foreach
      (entmake ent_list)
      ) ;_ end of if

    ) ;_ end of defun

  (_kpblc-create-textstyle)
  (if (not (tblsearch "block" "_archtick"))
    (progn
      (setq _dimblk_ (getvar "dimblk"))
      (setvar "dimblk" "_archtick")
      (if (= _dimblk_ "")
(setvar "dimblk" ".")
(setvar "dimblk" _dimblk_)
) ;_ end of if
      ) ;_ end of progn
    ) ;_ end of if

  (foreach item (list nil 0 2 3 4 7)
    (_kpblc-create-sub-dimstyle item)
    ) ;_ end of foreach

  (if (not (vla-get-activedocument (vlax-get-acad-object)))
    (setq (vla-get-activedocument (vlax-get-acad-object))
   (vla-get-activedocument
     (vlax-get-acad-object)
     ) ;_ end of vla-get-activedocument
  ) ;_ end of setq
    ) ;_ end of if
  (if (tblobjname "dimstyle" "SPDS")
    (progn
      (setq active_dimstyle
     (vlax-ename->vla-object (tblobjname "dimstyle" "SPDS"))
    ) ;_ end of setq
      (vlax-put-property
(vla-get-activedocument (vlax-get-acad-object))
"ActiveDimStyle"
active_dimstyle
) ;_ end of vlax-put-property
      ) ;_ end of progn
    (vl-cmdf "_.-dimstyle" "_Save" "SPDS")
    ) ;_ end of if
  ) ;_ end of defun

;;; I't my library function, modifies bit of entity
(defun _kpblc-ent-modify (ent bit value / ent_list old_dxf new_dxf)
  (if (not
   (and
     (or
       (= (cdr (assoc 0 (entget ent))) "STYLE")
       (= (cdr (assoc 0 (entget ent))) "DIMSTYLE")
       ) ;_ end of or
     (= bit 100)
     ) ;_ end of and
   ) ;_ end of not
    (progn
      (setq ent_list (entget ent)
       new_dxf  (cons bit
            (if (and (= bit 62) (= (type value) 'str))
              (if (= (strcase value) "BYLAYER")
                256
                0
                ) ;_ end of if
              value
              ) ;_ end of if
            ) ;_ end of cons
       ) ;_ end of setq
      (if (not (equal new_dxf (setq old_dxf (assoc bit ent_list))))
   (progn (entmod (if old_dxf
          (subst new_dxf old_dxf ent_list)
          (append ent_list (list new_dxf))
          ) ;_ end of if
             ) ;_ end of entmod
          (entupd ent)
          (redraw ent)
          ) ;_ end of progn
   ) ;_ end of if
      ) ;_ end of progn
    ) ;_ end of if
  ent
  ) ;_ end of defun
Remeber! It creates dim and text styles uses my settings!
Sorry for my English.

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Layer 0 properties..
« Reply #4 on: March 17, 2006, 12:26:44 PM »
KPBLC..

thanks..but is not what i'm looking for..
I don't need to create DIMSTYLE or TEXTSTYLE ..

I need to REPLACE layer propreties, dimstyle properties and textstyle properties.
WHEN inserting a drawing containing all this.

let's make an exemple with layer:
DWG#1 (current drawing) i have:
layer 0
color 3
linetype continuous
thaw
on
plot yes


DWG#2 (that i need to insert):
layer 0
color 5
linetype hidden
thaw
on
plot no


The final result when the DWG#2 is inserted in DWG#1 (current drawing):
layer 0
color 5
linetype hidden
thaw
on
plot no

it would be fun if there only a variable for overwriting....
Keep smile...

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Layer 0 properties..
« Reply #5 on: March 17, 2006, 12:33:16 PM »
To do that I think you would need ObjectDBX, and copy over the layer properties that you want, for all the layers you want.  I don't know of a default way of doing it.
Tim

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

Please think about donating if this post helped you.

sinc

  • Guest
Re: Layer 0 properties..
« Reply #6 on: March 18, 2006, 05:09:25 AM »
I'm not sure why you would want to do that to layer 0, but the Layer Translator will let you transfer some of the layer settings from another drawing.  From Drawing A, load Drawing B into the Layer Translator, select Layer 0 in each drawing, hit "MAP", then hit "TRANSLATE".

This copies layer color, linetype, and lineweight.  It will also change the layer name.  I think it's also supposed to change the plot style, but it doesn't - probably a bug.  It should also allow you to copy at least the Plot Yes/No, but it doesn't do that, either.

kpblc

  • Bull Frog
  • Posts: 396
Re: Layer 0 properties..
« Reply #7 on: March 20, 2006, 02:27:33 AM »
I thought the problem was not only in layer properties. Do you want to get standard settings of all your drawings?
You can use dws-files (standard check files), where you can define all layer names, layer settings, linetype settings etc. The lisp isn't requiered for this (if you don't scared by manual working).
I'm scared by that, because I'm lazy.
If you wanna change only layer settings (and the lisp is requiered), you can use something like this:
Code: [Select]
(foreach item '(("color"  7)
("linetype"  "Continuous")
("LineWeight"  25)
)
  (vlax-put-property
    (vla-item (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
      "0"
      ) ;_ end of vla-item
    (car item)
    (cadr item)
    ) ;_ end of vlax-put-property
  ) ;_ end of foreach
Sorry for my English.