Author Topic: Import Layer States from DWG  (Read 4661 times)

0 Members and 1 Guest are viewing this topic.

cescalante73

  • Guest
Import Layer States from DWG
« on: August 17, 2009, 01:56:08 PM »
I am having trouble importing Layers States from a DWG file. We use AutoCAD 2009
I have a DWG files that has all our CAD standards and 8 layer states.
I get this message when I try to import & restore existing from the DWG file.

"Layer States - Cannot Restore Layer State"
"The selected layer states could not be restored".


Any advice on how to solve this?

Thanks

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: Import Layer States from DWG
« Reply #1 on: August 17, 2009, 03:23:24 PM »
Don't use Layer states is what it is telling you.  Seriously I don't know! I am just running off at the fingers.   I just wanted to let you know you were not being ignored and wanted to welcome you TheSwamp. 

Have you tried importing them into a brand new drawing?
Resaving your layer States?
 
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Import Layer States from DWG
« Reply #2 on: August 17, 2009, 04:52:19 PM »
Yes, Welcome to the Swamp.
After 26 views like me no one has shared your misfortune or maybe not found a suitable answer.
Hang in there and some one will give it a go.

You posted in the LISP forum, are you importing the layers via a lisp routine?
And the layer states?
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.

cescalante73

  • Guest
Re: Import Layer States from DWG
« Reply #3 on: August 17, 2009, 07:54:04 PM »
I found this lisp that worked for the old .LAY files from LMAN legacy
How can this be modified for LAS files?


(vl-load-com)
;;; Restore Layer State without adding new layers
(defun SetLayerState (name / lst lay todel layers-collection)
  ;; Get a list of current layers
  (while (setq lay (tblnext "LAYER" (not lay))) (setq lst (cons (cdr (assoc 2 lay)) lst)))

  ;; Run the command to import & set layer state
  (command ".-LAYER"
           "_stAte"
           "_Import"
           (findfile (strcat name ".LAY"))
           "_Restore"
           name
           ""
           ""
  ) ;_ end of command

  ;; Get new layers to delete
  (setq lay nil
        layers-collection
         (vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object)))
  ) ;_ end of setq
  (while (setq lay (tblnext "LAYER" (not lay)))
    ;; Check if not a member of the old layer list
    (if (not (member (cdr (assoc 2 lay)) lst))
      (setq todel (cons (vla-Item layers-collection (cdr (assoc 2 lay))) todel))
    ) ;_ end of if
  ) ;_ end of while

  ;; Delete these layers if they're not used
  (foreach lay todel
    (if (= (vla-get-Used lay) :vlax-false)
      (vla-Delete lay)
    ) ;_ end of if
  ) ;_ end of foreach

  (princ)
) ;_ end of defun


mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: Import Layer States from DWG
« Reply #4 on: August 17, 2009, 07:58:37 PM »
how about using the create new drawing function, instead of using a DWT, change the file type to DWG, and use the file with the layerstates you want in it, save this as your new working template...
Be your Best


Michael Farrell
http://primeservicesglobal.com/

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: Import Layer States from DWG
« Reply #5 on: August 18, 2009, 02:09:23 PM »
I use ObjectDBX - but I don't import the layer state: I look at it.

OK, let me explain.  We have all our standard layers and layers states saved in a single "standard" drawing.  I use ObjectDBX to import layers, but when it comes to layer states if you import them who also import ALL the layers: and we have over 400 standard layers (multiple disciplines).  So what I do is open the "standards" drawing via ObjectDBX, change to the desired layer state, then compare the individual layer properties in the current drawing to mach the "standards" drawing.  It works great.  Let's say in the middle of a project one of a layers properties changes; linetype, plotstyle, etc.  With my method the layer states are dynamic. 

Now this is a real big mess of a program, but if you search here I know I've shared it.  Search for "jbLayerStates" or "jbWorkingStates".  My personal version is hooked into AutoCAD Architectures Project Navigator module but I'm sure I posted a simple AutoCAD version.

I'm not around here alot lately, but I'm sure there are others on here that use it.  I hope this helps.

jb
James Buzbee
Windows 8