Author Topic: Layer 0 attack  (Read 17199 times)

0 Members and 1 Guest are viewing this topic.

Notsober

  • Guest
Layer 0 attack
« on: November 17, 2008, 05:52:22 PM »
Hi all... I know some of you won't like this, but I need a huge favor. My company is not listening to me, they don't want to spend the money, they don't want to bill the client 40 hours per dwg to simplify these P&ID's (process migration).

So, I'm looking for a lisp routine that will go into a given dwg, and strip it of ALL layers except 0. But not only that, but ALL the properties including colors, linetypes, and lineweights have to remain unchanged! This includes ALL blocks and nested blocks, and their attributes. ALL existing layers EXCEPT 0 have to go.

Is anyone up for the challenge? Please..........???

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Layer 0 attack
« Reply #1 on: November 17, 2008, 06:40:11 PM »
My company <snip> don't want to spend the money <snip> don't want to bill the client 40 hours per dwg to simplify these P&ID's (process migration) <snip> Is anyone up for the challenge? Please ... ???

Aside from the horrors of the "work", I don't why you're bothering to pursue this when you have neither the approval or the mandate. Are you going to subsidize the company on your own time, on your ticket, and are asking for people to climb aboard the fail ship? Sorry if that sounds harsh but this sounds wack at my computer.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Notsober

  • Guest
Re: Layer 0 attack
« Reply #2 on: November 17, 2008, 06:54:07 PM »
basically, I'm trying to save my job ass here. What they want me to do is not what I want to do, but I feel like I'm HAVING to do it, or I can go look for another job. See, around here engineering is slowing down, so they look for odd ended jobs to keep us going (keep us off overhead) until bigger jobs come along.

I feel the same way you do. But I'm at my wits end when I really don't know how else to do what they're intending to desire as an end product. I personally believe they are making me mangle and shred these drawings to pieces. But what should I care? If the client is willing to pay for it, then by all means. It doesn't matter what and how we do things normally. This is not a normal situation. Problem is, only that it takes a long time to strip each dwg, then plug in the desired processes. I figured I could at least save myself some time by having a routine that help me do what I want to do.

So in closing: What does it matter to you WHY i'm doing this? They know I'm stripping the dwg of all the layers. That's what they want. I simply don't know how to do it more effectively than the way I'm doing it now...

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Layer 0 attack
« Reply #3 on: November 17, 2008, 07:04:54 PM »
This should work ( not tested ).  If not, it is close to what you want.  It can be called from ObjectDBX.  If you want, a purge can be added, or a delete of all the layer records after.  But I'll leave that to you.   :wink:

Code: [Select]
(defun ChangeAllItemsToLayer0 (doc)
   
    (vlax-for i (vla-get-Layers doc)
        (vla-put-Lock i :vlax-false)
    )
    (vlax-for blk (vla-get-Blocks doc)
        (vlax-for i blk
            (vla-put-Layer i "0")
            (if (= (vla-get-ObjectName i) "AcDbBlockReference")
                (foreach j (append (vlax-invoke i 'GetAttributes) (vlax-invoke i 'GetConstantAttributes))
                    (vla-put-Layer j "0")
                )
            )
        )
    )
)

To call in the current drawing.
Code: [Select]
(ChangeAllItemsToLayer0 (vla-get-ActiveDocument (vlax-get-Acad-Object)))
Tim

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

Please think about donating if this post helped you.

Notsober

  • Guest
Re: Layer 0 attack
« Reply #4 on: November 17, 2008, 07:19:18 PM »
okay awesome.

I was just over at CADTutor, was gonna find out HOW to go about asking, the right way, someone to write a lisp for me  :wink:

i wish i had the time to really learn it  :|  I know I would enjoy it.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Layer 0 attack
« Reply #5 on: November 17, 2008, 07:23:27 PM »
If you're forcing everything to layer "0" AND you don't want the colors and line types to change doesn't that mean you have to hard code the entity's colors and line types by examining the entity's layer properties, hard coding said properties accordingly? Or do I misunderstand the requirement noted in the first post?
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Notsober

  • Guest
Re: Layer 0 attack
« Reply #6 on: November 17, 2008, 07:25:20 PM »
testing now...

This should work ( not tested ).  If not, it is close to what you want.  It can be called from ObjectDBX.  If you want, a purge can be added, or a delete of all the layer records after.  But I'll leave that to you.   :wink:

Code: [Select]
(defun ChangeAllItemsToLayer0 (doc)
   
    (vlax-for i (vla-get-Layers doc)
        (vla-put-Lock i :vlax-false)
    )
    (vlax-for blk (vla-get-Blocks doc)
        (vlax-for i blk
            (vla-put-Layer i "0")
            (if (= (vla-get-ObjectName i) "AcDbBlockReference")
                (foreach j (append (vlax-invoke i 'GetAttributes) (vlax-invoke i 'GetConstantAttributes))
                    (vla-put-Layer j "0")
                )
            )
        )
    )
)

To call in the current drawing.
Code: [Select]
(ChangeAllItemsToLayer0 (vla-get-ActiveDocument (vlax-get-Acad-Object)))

Notsober

  • Guest
Re: Layer 0 attack
« Reply #7 on: November 17, 2008, 07:26:52 PM »
If you're forcing everything to layer "0" AND you don't want the colors and line types to change doesn't that mean you have to hard code the entity's colors and line types by examining the entity's layer properties, hard coding said properties accordingly? Or do I misunderstand the requirement noted in the first post?

yes pretty much is what i'm having to do now, only "manually" as opposed to automated...

Notsober

  • Guest
Re: Layer 0 attack
« Reply #8 on: November 17, 2008, 07:30:55 PM »
...or ... what exactly do you mean by "hard code"?

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Layer 0 attack
« Reply #9 on: November 17, 2008, 07:35:04 PM »
If you're forcing everything to layer "0" AND you don't want the colors and line types to change doesn't that mean you have to hard code the entity's colors and line types by examining the entity's layer properties, hard coding said properties accordingly? Or do I misunderstand the requirement noted in the first post?
If this is true, it wouldn't be too hard to add.

What Michael means is that if the entity is on layer1, and layer1 color = 1, and layer1 linetype = hidden, and layer 0 color = 7, and layer 0 linetype = continuous, then once you change the layer, the entity will have color = 7 and linetype = continuous, because that is what the layer says ( if the entity's color and linetype are bylayer ).  Or should the entity's color = 1 and linetype = hidden?
Tim

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

Please think about donating if this post helped you.

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Layer 0 attack
« Reply #10 on: November 17, 2008, 07:36:39 PM »
How about something like this:

Code: [Select]
(defun makesmecry (obj / p)
  (foreach p '(Color Linetype Lineweight)
    (if (vl-position (vlax-get-property obj p) '(256 -1 "ByLayer"))
      (vl-catch-all-apply
'vlax-put-property
(list obj
      p
      (vlax-get-property
(vlax-ename->vla-object
  (tblobjname "layer" (vla-get-layer obj))
)
p
      )
)
      )
    )
  )
  (vl-catch-all-apply
    'vlax-put-property
    (list obj 'Layer "0")
  )
  (princ)
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Notsober

  • Guest
Re: Layer 0 attack
« Reply #11 on: November 17, 2008, 07:40:00 PM »
If you're forcing everything to layer "0" AND you don't want the colors and line types to change doesn't that mean you have to hard code the entity's colors and line types by examining the entity's layer properties, hard coding said properties accordingly? Or do I misunderstand the requirement noted in the first post?
If this is true, it wouldn't be too hard to add.

What Michael means is that if the entity is on layer1, and layer1 color = 1, and layer1 linetype = hidden, and layer 0 color = 7, and layer 0 linetype = continuous, then once you change the layer, the entity will have color = 7 and linetype = continuous, because that is what the layer says ( if the entity's color and linetype are bylayer ).  Or should the entity's color = 1 and linetype = hidden?

well yeah. that's why it's so complex... and the very reason why it's a challenge. Because regardless of why I need a fine tool like this, someone later on down the road might need something like this too  :wink:

and frankly, i'm quite tired of people's ruthless addiction to having blocks within blocks within blocks, and different properties for each of them!! GD!

Notsober

  • Guest
Re: Layer 0 attack
« Reply #12 on: November 17, 2008, 07:41:21 PM »
you do realize that you can post any kind of code, and i have no idea what it's gonna do?

i just know how to execute it. how scary is that?

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Layer 0 attack
« Reply #13 on: November 17, 2008, 07:45:12 PM »
you do realize that you can post any kind of code, and i have no idea what it's gonna do?

i just know how to execute it. how scary is that?

My code will grab the object layer properties if the properties are not set by object. You can plug it into Tim's code like so:

Code: [Select]
(defun ChangeAllItemsToLayer0 (doc)

  (vlax-for i (vla-get-Layers doc)
    (vla-put-Lock i :vlax-false)
  )
  (vlax-for blk (vla-get-Blocks doc)
    (vlax-for i blk
      (makesmecry i)
      (if (= (vla-get-ObjectName i) "AcDbBlockReference")
(foreach j (append (vlax-invoke i 'GetAttributes)
   (vlax-invoke i 'GetConstantAttributes)
   )
  (makesmecry j)
)
      )
    )
  )
)

*appears to work fine
« Last Edit: November 17, 2008, 08:01:45 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Notsober

  • Guest
Re: Layer 0 attack
« Reply #14 on: November 17, 2008, 08:18:55 PM »
okay hold up! wow...

i can paste all this code into one routine like this? - or is this not a lisp? if not, then i'm lost.
Code: [Select]
   
(defun ChangeAllItemsToLayer0 (vla-get-ActiveDocument (vlax-get-Acad-Object)))
   
  (vlax-for i (vla-get-Layers doc)
    (vla-put-Lock i :vlax-false)
  )
  (vlax-for blk (vla-get-Blocks doc)
    (vlax-for i blk
      (makesmecry i)
      (if (= (vla-get-ObjectName i) "AcDbBlockReference")
(foreach j (append (vlax-invoke i 'GetAttributes)
   (vlax-invoke i 'GetConstantAttributes)
   )
  (makesmecry j)
)
      )
    )
  )
)

(defun makesmecry (obj / p)
  (foreach p '(Color Linetype Lineweight)
    (if (vl-position (vlax-get-property obj p) '(256 -1 "ByLayer"))
      (vl-catch-all-apply
'vlax-put-property
(list obj
      p
      (vlax-get-property
(vlax-ename->vla-object
  (tblobjname "layer" (vla-get-layer obj))
)
p
      )
)
      )
    )
  )
  (vl-catch-all-apply
    'vlax-put-property
    (list obj 'Layer "0")
  )
  (princ)
)

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Layer 0 attack
« Reply #15 on: November 18, 2008, 08:53:02 AM »
That's exactly what you do  :-) If you are going to run this by odbx, you'd probably have to combine the two....but I could be wrong.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Notsober

  • Guest
Re: Layer 0 attack
« Reply #16 on: November 18, 2008, 09:56:12 AM »
That's exactly what you do  :-) If you are going to run this by odbx, you'd probably have to combine the two....but I could be wrong.

Okay. I opened the dwg that you *fixed* THANKS that's exactly what I wanted! but now i wish I understood the difference between odbx and lisp... cuz right now I'm still stuck on how to do what you did with the code.

help me get this right.

I save this code into a notepad and save it as *.lsp? I get the feeling I'm wrong there...

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Layer 0 attack
« Reply #17 on: November 18, 2008, 10:13:29 AM »
Odbx is a way to process a bunch of drawings without actually "opening" them. If you have tons of these drawings to shred, that might be the route to take. As for the notepad and .lsp extension, that's exactly what you need to do.

Add this to your lisp file to call it with "allzero at the command line:

Code: [Select]
(defun c:allzero (/)
  (ChangeAllItemsToLayer0
    (vla-get-ActiveDocument (vlax-get-Acad-Object))
  )
)

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Layer 0 attack
« Reply #18 on: November 18, 2008, 10:22:41 AM »
Slight mod & some comments.
This worked for me, although a regen was needed for some objects to show properly.
Code: [Select]
(defun ChangeAllItemsToLayer0 (doc)
  ;; unlock all layers
  (vlax-for i (vla-get-Layers doc)
    (vla-put-Lock i :vlax-false)
  )
  ;; loop through all blocks
  (vlax-for blk (vla-get-Blocks doc)
    (vlax-for i blk
      (makesmecry i) ; go set properties of object
      ;;  if the object is a block look for attributes
      (if (= (vla-get-ObjectName i) "AcDbBlockReference")
        ;;  foreach attribute
(foreach j (append (vlax-invoke i 'GetAttributes)
   (vlax-invoke i 'GetConstantAttributes)
   )
  (makesmecry j) ; go set properties of object
)
      )
    )
  )
)

(defun makesmecry (obj / p)
  ;;  for each property
  (foreach p '(("Layer" "0")("Color" 256) ("Linetype" -1) ("Lineweight" "ByLayer"))
    ;;  if property is one of these
    (if ;(and (vlax-property-available-p obj (car p) t)
             (not (equal (vlax-get-property obj (car p)) (cadr p)));)
      (vl-catch-all-apply ; catch any error while
'vlax-put-property ; changing the property
(list obj (car p) (cadr p))
      )
    )
  )
  (princ)
)

(defun c:test()
  (ChangeAllItemsToLayer0 (vla-get-ActiveDocument (vlax-get-Acad-Object)))
  (princ)
)
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.

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Layer 0 attack
« Reply #19 on: November 18, 2008, 10:32:04 AM »
What are the errors? Perhaps post the drawing that is errors on.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Layer 0 attack
« Reply #20 on: November 18, 2008, 10:38:37 AM »
CAB,

Your version of makesmecry does the opposite of what he needs.
If the property of the object is bylayer, then you need to grab the layer property and apply it byobject.

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Layer 0 attack
« Reply #21 on: November 18, 2008, 10:47:06 AM »
Oops, I missed that requirement. :oops:
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.

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Layer 0 attack
« Reply #22 on: November 18, 2008, 10:48:33 AM »
Oops, I missed that requirement. :oops:

It happens to the best of us  :-)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Layer 0 attack
« Reply #23 on: November 18, 2008, 11:00:03 AM »
I was thinking to myself, "Why is Ron doing that?"  8-)
I'm on my third cup, you'd think I'd be awake by now.
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.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Layer 0 attack
« Reply #24 on: November 18, 2008, 11:19:55 AM »
This is what I can ante up now.

It forces all to layer "0" except entities that were on "frozen" or "off" layers. Rather than delete the offending entities I opted to force them to two new layers, "FROZEN" or "OFF", so in the end you will have a drawing with potentially three layers "0", "FROZEN" and "OFF", as it purges all other layers, though absolute purging is not guaranteed in this version. For example, layers frozen in view ports will not be purged as the view port's xdata will reference the layers, preventing a purge. While that can easily be dealt with, as well as a suite of other layer purge inhibiting conditions, I simply don't have the time.

All entities will end up with hard coded color, line type and line weights corresponding to the layer they originally resided on. However, to perform the job correctly any objects with color or linetype "ByBlock" should inherit their properties from their parent's block (or parent block's layer). The program is coded so it branches on "ByBlock" accordingly, but in this version "ByBlock" is treated the same as "ByLayer", that is properties are inherited from the immediate parent layer.

Copy all the code, paste to a new text file and save as ForeceLayerZero.lsp to a folder in your support path. To load it type (load "ForceLayerZero"). To run it after it's loaded just type ForceLayerZero. Read the inline comments if you want to know more.

While it may look intimidating and / or appear to be a lot of code, it's neither. I have a verbose, modular coding style that makes it appear more than it is. Fear not, it's easy, simple sh*t.

Code: [Select]
;;  Provided complete with errors and omissions, without warranty,
;;  implied or stated for any particular use. USE AT YOUR OWN RISK.

(defun C:ForceLayerZero ( / _ChangeProperties _ItemExists _AddItem _Main )

    (defun _ChangeProperties ( object layer_index frozen off / properties lineweight )
   
        (setq properties
            (cdr
                (assoc
                    (vla-get-layer object)
                    layer_index
                )
            )
        )

        ;;  color
       
        (cond
       
            ;;  bylayer

            (   (eq 256 (vla-get-color object))
                (vla-put-color
                    object
                    (cdr (assoc 'color properties))
                )
            )
       
            ;;  byblock -- to do this properly the color
            ;;  of the parent block (if there is one) should
            ;;  be used (or the parent block's layer color if
            ;;  the parent block is bylayer). Maybe in the
            ;;  next version, for now treat same as bylayer.
   
            (   (zerop (vla-get-color object))
                (vla-put-color
                    object
                    (cdr (assoc 'color properties))
                )
            )
        )   
       
        ;;  linetype
       
        (cond
       
            ;;  bylayer

            (   (eq "ByLayer" (vla-get-linetype object))
                (vla-put-linetype
                    object
                    (cdr (assoc 'linetype properties))
                )
            )

            ;;  byblock -- to do this properly the linetype
            ;;  of the parent block (if there is one) should
            ;;  be used (or the parent block's layer linetype
            ;;  if the parent block linetype is bylayer). Maybe
            ;;  in the next version, for now treat same as bylayer.
   
            (   (eq "ByBlock" (vla-get-linetype object))
                (vla-put-linetype
                    object
                    (cdr (assoc 'linetype properties))
                )
            )
           
        )
       
        ;;  lineweight
                   
        (if
            (/=
                (vla-get-lineweight object)
                (setq lineweight (cdr (assoc 'lineweight properties)))
            )
            (vla-put-lineweight object lineweight)
        )
       
        ;;  map the entity to layer "FROZEN", "OFF" or "0"
       
        (cond
            (   (minusp (cdr (assoc 'freeze properties)))
                (vla-put-layer object frozen)
            )
            (   (zerop (cdr (assoc 'layeron properties)))
                (vla-put-layer object off)
            )
            (   t
                (vla-put-layer object "0")
            )
        )
       
    )
   
    (defun _ItemExists ( collection key / result )
        (vl-catch-all-apply
           '(lambda ( )
                (vla-item collection key)
                (setq result t)
            )
        )
        result
    )
   
    (defun _AddItem ( collection prefix / key )
   
        (if (_ItemExists collection prefix)
            (setq key prefix)
            (   (lambda ( i )
                    (while
                        (_ItemExists collection
                            (setq key
                                (strcat
                                    prefix
                                    (itoa (setq i (1+ i)))
                                )       
                            )       
                        )
                    )
                )
                1000
            )               
        )
       
        (vla-add collection key)
   
    )

    (defun _Main ( document / layers layer_index frozen frozen_name off off_name )
   
        (if (< 1 (vla-get-count (setq layers (vla-get-Layers document))))
       
            (progn
   
                ;;  unlock all layers and create
                ;;  the layer property index
       
                (vlax-for layer (setq layers (vla-get-Layers document))
       
                    (vla-put-Lock layer :vlax-false)
       
                    (setq layer_index
                        (cons
                            (cons
                                (vla-get-name layer)
                                (mapcar
                                   '(lambda ( property )
                                        (cons
                                            property
                                            (vlax-get layer property)
                                        )
                                    )
                                   '(color linetype lineweight layeron freeze)
                                )
                            )
                            layer_index
                        )
                    )
                )
       
                ;;  make layer 0 active so we can
                ;;  nuke all the other layers later
               
                (   (lambda ( layer )
                        (vla-put-layeron layer :vlax-true)
                        (if (/= "0" (getvar "clayer"))
                            (vla-put-freeze  layer :vlax-false)
                        )                       
                    )
                    (vla-item layers "0")
                )
       
                (setvar "clayer" "0")
               
                ;;  create 2 new layers, one will be called "FROZEN" the
                ;;  other will be called "OFF". Place entities accordingly.
               
                (setq
                    frozen      (_AddItem layers "FROZEN")
                    frozen_name (vla-get-name frozen)
                    off         (_AddItem layers "OFF")
                    off_name    (vla-get-name off)
                )
               
                ;;  set the layer properties accordingly
               
                (vla-put-freeze frozen :vlax-true)
                (vla-put-layeron off :vlax-false)
       
                ;;  now abuse every object in the drawing
       
                (vlax-for block (vla-get-Blocks document)
                    (vlax-for object block
                        (_ChangeProperties object layer_index frozen_name off_name)
                        (if (eq "AcDbBlockReference" (vla-get-ObjectName object))
                            (foreach attrib
                                (append
                                    (vlax-invoke object 'GetAttributes)
                                    (vlax-invoke object 'GetConstantAttributes)
                                )
                                (_ChangeProperties object layer_index frozen_name off_name)
                            )
                        )
                    )
                )
       
                ;;  purge the bastard
       
                (repeat 5 (vla-purgeall document))
               
                ;;  if the frozen and off layers remain in the drawing
                ;;  rename them if they don't sport the names we want
               
                (if (null (vlax-erased-p frozen))
                    (if (/= "FROZEN" (strcase (vla-get-name frozen)))
                        (vla-put-name frozen "FROZEN")
                    )
                )     
       
                (if (null (vlax-erased-p off))
                    (if (/= "OFF" (strcase (vla-get-name off)))
                        (vla-put-name off "OFF")
                    )
                )
   
            )
           
        )                           
       
        (princ)       

    )
   
    ;;  do it, do it now

    (_Main (vla-get-activedocument (vlax-get-acad-object)))

)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Notsober

  • Guest
Re: Layer 0 attack
« Reply #25 on: November 18, 2008, 11:51:05 AM »
As much as I really appreciate everyone's efforts, I still have to say: It took alot of guts for some of you, and I really can't give you any good reasons why I asked for this routine. But when the boss says do this, I have no choice but to say, okay. Not because I'm a kissass, hardly the case. It's only because they don't know any better, and I'd be talking out of my ass when I go to explain to them why they still shouldn't do this. Basically a dead end road for me if I do that.

So, here is the dwg that I mutilated with your help! Go ahead, check it out. Leaving "0" ON, you can turn OFF BIFENTHRIN, turn ON FORTRESS and viola! You're now looking at the lines and valves that have to do with only that particular process. MOCAP is not yet completed.. so it's still the same as BIFENTHRIN I think.

Notsober

  • Guest
Re: Layer 0 attack
« Reply #26 on: November 18, 2008, 11:53:44 AM »
What are the errors? Perhaps post the drawing that is errors on.


Code: [Select]
allzero.lsp successfully loaded.
Command: ; error: syntax error
Command:
Command: allzero
; error: no function definition: CHANGEALLITEMSTOLAYER0
Command:
Command: appload
allzero.lsp successfully loaded.
Command: ; error: extra right paren on input
Command:
Command: appload
allzero.lsp successfully loaded.
Command: ; error: bad argument type: VLA-OBJECT nil

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Layer 0 attack
« Reply #27 on: November 18, 2008, 12:04:22 PM »
Change this
(defun ChangeAllItemsToLayer0 (vla-get-ActiveDocument (vlax-get-Acad-Object)))
to this
(defun ChangeAllItemsToLayer0 (doc)

but id didn't work for me
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.

Notsober

  • Guest
Re: Layer 0 attack
« Reply #28 on: November 18, 2008, 02:12:30 PM »
Change this
(defun ChangeAllItemsToLayer0 (vla-get-ActiveDocument (vlax-get-Acad-Object)))
to this
(defun ChangeAllItemsToLayer0 (doc)

but id didn't work for me

didn't work for me either... bummer.

I have the borders now, that some reason there are some leftover layers that won't purge! i cannot find where they are hiding! grrrr....

M-dub

  • Guest
Re: Layer 0 attack
« Reply #29 on: November 18, 2008, 02:20:59 PM »
Just explode everything a dozen times and THEN see if you can find it.  When / if you do, undo and go change it.

Notsober

  • Guest
Re: Layer 0 attack
« Reply #30 on: November 18, 2008, 02:30:17 PM »
i must be grossly misunderstanding something.

You reposted posted my original that you fixed. Where I'm going wrong is that I cannot reproduce what you're doing with all the code you're posting.

Now, not trying to sound overly whiny, but unless you come to my office and show me exactly what you're doing, I otherwise have no idea.

I understand that I can't just throw a whole bunch of code into a notepad, call it whatever I want, and expect it to work properly. Please post a step by step instruction manual on how to decipher the code you're posting  :lol:

i know how to follow directions. Provided the directions aren't taking me to Jerusalem, when I really want to go to Moscow  :police:

Notsober

  • Guest
Re: Layer 0 attack
« Reply #31 on: November 18, 2008, 02:42:14 PM »
Just explode everything a dozen times and THEN see if you can find it.  When / if you do, undo and go change it.

Quick Select found nothing on these layers. Although Layer Manager insists there are objects on those layers... great.


M-dub

  • Guest
Re: Layer 0 attack
« Reply #32 on: November 18, 2008, 02:45:15 PM »
Just explode everything a dozen times and THEN see if you can find it.  When / if you do, undo and go change it.

Quick Select found nothing on these layers. Although Layer Manager insists there are objects on those layers... great.



Did you try quick select before or after a dozen Explode commands?

Notsober

  • Guest
Re: Layer 0 attack
« Reply #33 on: November 18, 2008, 02:47:20 PM »
Just explode everything a dozen times and THEN see if you can find it.  When / if you do, undo and go change it.

Quick Select found nothing on these layers. Although Layer Manager insists there are objects on those layers... great.



Did you try quick select before or after a dozen Explode commands?

before AND after.

besides, it only lets me explode ONCE, after that says: 3917 objects were not able to be exploded.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Layer 0 attack
« Reply #34 on: November 18, 2008, 02:48:35 PM »
I have the borders now, that some reason there are some leftover layers that won't purge! i cannot find where they are hiding! grrrr....
Try the code here for that.

[ http://www.theswamp.org/index.php?topic=13052.0 ]
Tim

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

Please think about donating if this post helped you.

Notsober

  • Guest
Re: Layer 0 attack
« Reply #35 on: November 18, 2008, 02:53:07 PM »
I have the borders now, that some reason there are some leftover layers that won't purge! i cannot find where they are hiding! grrrr....
Try the code here for that.

[ http://www.theswamp.org/index.php?topic=13052.0 ]

THANKS... but...

Quote
Command: chaselayer


+++ Layers that were not found anywhere:
   0
   0
   33
   6
   EQUIPMENT INSUL
   TEXT3 (EQUIPMENT)
Command:

now what? If they weren't found anywhere, how come they won't freaking purge??

Spike Wilbury

  • Guest
Re: Layer 0 attack
« Reply #36 on: November 18, 2008, 03:03:36 PM »
Try my SuperBurst command:

http://www.theswamp.org/index.php?topic=18383.msg224660#msg224660

Run it and then - call the autocad purge command as needed.

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: Layer 0 attack
« Reply #37 on: November 18, 2008, 03:04:42 PM »
Hi all... I know some of you won't like this, but I need a huge favor. My company is not listening to me, they don't want to spend the money, they don't want to bill the client 40 hours per dwg to simplify these P&ID's (process migration).

Maybe I've missed something but... what's the point of simplifying the drawings?  Why go through the trouble of setting everything to layer 0?
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

Notsober

  • Guest
Re: Layer 0 attack
« Reply #38 on: November 18, 2008, 03:06:48 PM »
Hi all... I know some of you won't like this, but I need a huge favor. My company is not listening to me, they don't want to spend the money, they don't want to bill the client 40 hours per dwg to simplify these P&ID's (process migration).

Maybe I've missed something but... what's the point of simplifying the drawings?  Why go through the trouble of setting everything to layer 0?

Look here.

Notsober

  • Guest
Re: Layer 0 attack
« Reply #39 on: November 18, 2008, 03:09:17 PM »
Try my SuperBurst command:

http://www.theswamp.org/index.php?topic=18383.msg224660#msg224660

Run it and then - call the autocad purge command as needed.

Greek. Like Chinese, I don't understand it.

If you spoke German, I can understand that  :-D

Spike Wilbury

  • Guest
Re: Layer 0 attack
« Reply #40 on: November 18, 2008, 03:14:08 PM »
Try my SuperBurst command:

http://www.theswamp.org/index.php?topic=18383.msg224660#msg224660

Run it and then - call the autocad purge command as needed.

Greek. Like Chinese, I don't understand it.

If you spoke German, I can understand that  :-D

Download the arx.... SuperBurst17.arx (if you are running a latest autocad version 2007 and greater - I left the source code open, any swamper can play with the code if they want) - load it in autocad, call the command: SUPERBURST, select ALL and at the end purge your drawing and maybe use the old command -change to change all to layer 0....

see if helps.

(and nope I do not speak German, is in my To-Do list - one of these days)

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Layer 0 attack
« Reply #41 on: November 18, 2008, 03:29:11 PM »
Give this a whirl...be warned that it deletes audited items (which in this case seemed to be empty blocks).

Code: [Select]
(defun c:allzero (/ doc makesmecry rjp-progress n ss)
  (vl-load-com)
  (setq doc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
  (vla-auditinfo doc :vlax-true)
  (vla-purgeall doc)
  (vlax-for i (vla-get-Layers doc)
    (vla-put-lock i :vlax-false)
  )
  (vl-catch-all-apply 'setvar (list 'clayer "0"))

  (defun makesmecry (obj / p)
    (foreach p '(Color Linetype Lineweight)
      (if (vl-position (vlax-get-property obj p) '(256 -1 "ByLayer"))
(vl-catch-all-apply
  'vlax-put-property
  (list obj
p
(vlax-get-property
  (vlax-ename->vla-object
    (tblobjname "layer" (vla-get-layer obj))
  )
  p
)
  )
)
      )
    )
    (vl-catch-all-apply
      'vlax-put-property
      (list obj 'Layer "0")
    )
    (princ)
  )

  (vlax-for blk (vla-get-blocks doc)
    (vlax-for i blk
      (makesmecry i)
      (if (= (vla-get-ObjectName i) "AcDbBlockReference")
(foreach j (append (vlax-invoke i 'GetAttributes)
   (vlax-invoke i 'GetConstantAttributes)
   )
  (makesmecry j)
)
      )
    )
  )
  ;;deletes audited crap so be forewarned
  (if (setq ss (ssget "x" '((2 . "AUDIT*"))))
    (foreach x (mapcar 'cadr (ssnamex ss))
      (entdel x)
    )
  )
  (repeat 3 (vla-purgeall doc))
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Layer 0 attack
« Reply #42 on: November 18, 2008, 03:34:44 PM »
That worked for me in my limited test DWG.


Also Michael's routine worked fine.

Note that I didn't have a lot of junk in the DWG.
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.

Notsober

  • Guest
Re: Layer 0 attack
« Reply #43 on: November 18, 2008, 06:50:02 PM »
Give this a whirl...be warned that it deletes audited items (which in this case seemed to be empty blocks).

are empty blocks the same thing as anonymous blocks or blocks with only a grip and empty space?

and what's specific to know about "audited" items? (so that I know what I'm getting into  8-))

whdjr

  • Guest
Re: Layer 0 attack
« Reply #44 on: November 19, 2008, 08:37:58 AM »
Change this
(defun ChangeAllItemsToLayer0 (vla-get-ActiveDocument (vlax-get-Acad-Object)))
to this
(defun ChangeAllItemsToLayer0 (doc)

but id didn't work for me

I may be late to the party and this may have already been resolved but if your using Odbx can you issue a call to an "Active Document"?  It has been a while since I used Odbx so I may be missing the mark.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Layer 0 attack
« Reply #45 on: November 19, 2008, 11:02:36 AM »
Change this
(defun ChangeAllItemsToLayer0 (vla-get-ActiveDocument (vlax-get-Acad-Object)))
to this
(defun ChangeAllItemsToLayer0 (doc)

but id didn't work for me

I may be late to the party and this may have already been resolved but if your using Odbx can you issue a call to an "Active Document"?  It has been a while since I used Odbx so I may be missing the mark.
No.  Since it is already open you couldn't use Odbx.  But if you are the one with it opened, then you could just use the document object, from the document collection, and use it like you would an Odbx document.
Tim

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

Please think about donating if this post helped you.

Notsober

  • Guest
Re: Layer 0 attack
« Reply #46 on: November 19, 2008, 02:58:14 PM »
this guy right here is the winner! Worked perfectly, and exactly how I wanted.

now, if I can only get a code to get management OFF my layer!  :-D


Give this a whirl...be warned that it deletes audited items (which in this case seemed to be empty blocks).

Code: [Select]
(defun c:allzero (/ doc makesmecry rjp-progress n ss)
  (vl-load-com)
  (setq doc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
  (vla-auditinfo doc :vlax-true)
  (vla-purgeall doc)
  (vlax-for i (vla-get-Layers doc)
    (vla-put-lock i :vlax-false)
  )
  (vl-catch-all-apply 'setvar (list 'clayer "0"))

  (defun makesmecry (obj / p)
    (foreach p '(Color Linetype Lineweight)
      (if (vl-position (vlax-get-property obj p) '(256 -1 "ByLayer"))
(vl-catch-all-apply
  'vlax-put-property
  (list obj
p
(vlax-get-property
  (vlax-ename->vla-object
    (tblobjname "layer" (vla-get-layer obj))
  )
  p
)
  )
)
      )
    )
    (vl-catch-all-apply
      'vlax-put-property
      (list obj 'Layer "0")
    )
    (princ)
  )

  (vlax-for blk (vla-get-blocks doc)
    (vlax-for i blk
      (makesmecry i)
      (if (= (vla-get-ObjectName i) "AcDbBlockReference")
(foreach j (append (vlax-invoke i 'GetAttributes)
   (vlax-invoke i 'GetConstantAttributes)
   )
  (makesmecry j)
)
      )
    )
  )
  ;;deletes audited crap so be forewarned
  (if (setq ss (ssget "x" '((2 . "AUDIT*"))))
    (foreach x (mapcar 'cadr (ssnamex ss))
      (entdel x)
    )
  )
  (repeat 3 (vla-purgeall doc))
)

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Layer 0 attack
« Reply #47 on: November 19, 2008, 04:04:00 PM »
Glad it worked for you :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC