Author Topic: extract layer from files  (Read 3924 times)

0 Members and 1 Guest are viewing this topic.

danny

  • Guest
extract layer from files
« on: March 24, 2005, 06:38:24 PM »
I'm am using a custom Desktop tool, ACAD 2000i, to keep track of revisions made to drawings.  What I need to do is extract the revision cloud from all drawings and put them into one file so I can create the Desktop schedule.
Code: [Select]
go to paper space
grab all ojects on layer Rev13-Cloud
create wblock
saveas Rev(drawing name)

The Desktop schedule is able to read xrefs, so i figure if the lisp can make a wblock, then I can run a script to all files, and then start a new file and xref all shets in...
maybe some one has a better idea? :?

danny

  • Guest
extract layer from files
« Reply #1 on: March 24, 2005, 11:07:28 PM »
ok...
how can I use this, but instead of selecting/picking the layer, can it be entered at the command prompt.  or even the option to pick or enter layer name?
Code: [Select]
(while (setq ent (entsel "\nSelect entity on layer..."))
(setq layer_string
(if layer_string
(strcat layer_string ","
(vla-get-layer (vlax-ename->vla-object (car ent)))
)
(vla-get-layer (vlax-ename->vla-object (car ent)))

danny

  • Guest
extract layer from files
« Reply #2 on: March 25, 2005, 03:22:39 AM »
ok..
would something like this be a good way to create the wblock
Code: [Select]
(progn
         (setq jdwg (getvar "DWGNAME"))
         (setq jpath (getvar "DWGPREFIX"))
         (setq jfile (strcat jpath jdwg))
         (if (findfile jfile )
            (command "-wblock" jfile "" "Rev13-cloud" "")

I beleive this will save the wblock as the current drawing so i need to add a prefix...could i do it this way
Code: [Select]
(setq jdwg (strcat Rev(getvar "DWGNAME")))

danny

  • Guest
extract layer from files
« Reply #3 on: March 25, 2005, 03:24:41 AM »
after looking at that last post, I think I should go and catch up on some zzzzz

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
extract layer from files
« Reply #4 on: March 25, 2005, 08:50:15 AM »
danny
You're talking to your self again. Better stop that or they will come and take you away. :)

Seriously though, there is a problem with wblock and having the objects in another space.
If you try this :
Code: [Select]
(defun c:wblk (/ ss)
  (prompt "\nGetting objects, please wait.... ")
  (setq fname "my Test2"
        lyr "Rev13-cloud")
  ;; retrieve all entities in paperspace layouts on layer lyr
  (if (setq ss (ssget "_X" (list (cons 8  lyr) '(67 . 1))))
    (progn
      (Command "-wblock" fname "" "0,0" ss "")
      (command ".oops")
    )
  )
  (princ)
)


You'll see that wblock complains about items not in the current space.
I suppose you could create a new Tab and entmake the items in ss in that paper space
then wblock the objects, but would be in the new DWG but the location would be Model space
in the new DWG.
I can't see a solution right off.
You would have to create a drawing with the same Layouts in it & then recreate the entities.
It would be easy to save the entity data to a txt file. But to recreate a dwg with matching
layouts is beyond Lisp, me thinks. At least in one step.
Perhaps someone else has an idea.
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.

danny

  • Guest
extract layer from files
« Reply #5 on: March 25, 2005, 12:50:46 PM »
Quote
You're talking to your self again. Better stop that or they will come and take you away.

maybe thats what i need...hopefully "they" will be three beautiful lady's.  sorry just woke up and still dreaming...
I tried your code and it seemed that it worked ok, couldn't find where the file went though.
Quote
You would have to create a drawing with the same Layouts in it & then recreate the entities.
It would be easy to save the entity data to a txt file. But to recreate a dwg with matching
layouts is beyond Lisp, me thinks

I will have to xref the new wblocks so the the items will have to go into model space.  don't need the same layouts..

danny

  • Guest
extract layer from files
« Reply #6 on: March 25, 2005, 04:31:46 PM »
CAB,
I revised the code to get a prefix (Rev) in front of the filename and locate it in the same directory as the drawing.
Code: [Select]
(defun c:wblk (/ ss)
  (prompt "\nGetting objects, please wait.... ")
  (setq jdwg (strcat Rev(getvar "DWGNAME")))
  (setq jpath (getvar "DWGPREFIX"))
  (setq fname (strcat jpath jdwg))  
        lyr "Rev13-cloud")
  ;; retrieve all entities in paperspace layouts on layer lyr
  (if (setq ss (ssget "_X" (list (cons 8  lyr) '(67 . 1))))
    (progn
      (Command "-wblock" fname "" "0,0" ss "")
      (command ".oops")
    )
  )
  (princ)
)

I'm getting an error message
Code: [Select]
bad SSGET list value
; error: An error has occurred inside the *error* functionAutoCAD variable setting rejected: "blipmode" nil

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
extract layer from files
« Reply #7 on: March 25, 2005, 04:42:11 PM »
You have another Lisp error handler defined.
Add this to the 2nd line of the lisp & run it again to find the error.
Code: [Select]
(setq *error* nil)
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.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
extract layer from files
« Reply #8 on: March 25, 2005, 04:50:22 PM »
Try this:
Code: [Select]
(defun c:wblk (/ ss)
  (setq *error* nil) ; stop any lisp error handlers
  (prompt "\nGetting objects, please wait.... ")
  (setq fname   (strcat (getvar "DWGPREFIX") Rev (getvar "DWGNAME"))
        lyr "Rev13-cloud")
  ;; retrieve all entities in paperspace layouts on layer lyr
  (if (setq ss (ssget "_X" (list (cons 8  lyr) '(67 . 1))))
    (progn
      (Command "-wblock" fname "" "0,0" ss "")
      (command ".oops")
    )
  )
  (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.

danny

  • Guest
extract layer from files
« Reply #9 on: March 25, 2005, 04:55:18 PM »
What does this mean?
Code: [Select]
1 form loaded from #<editor "<Untitled-0> loading...">

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
extract layer from files
« Reply #10 on: March 25, 2005, 05:31:14 PM »
Normal return value when loading a lisp.
First part is the number of routines in the lisp >>--> (defun )
Second part is the Name of the lisp in the editor
If you get the _$ on the next line the lisp loaded successfully.
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.

danny

  • Guest
extract layer from files
« Reply #11 on: March 25, 2005, 06:37:21 PM »
ok..
it loaded successfully, but I got an error message when I ran the command
Code: [Select]
error: bad argument type: stringp nil

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
extract layer from files
« Reply #12 on: March 25, 2005, 06:52:40 PM »
Is  'Rev'  a global variable?
I though it was.
If not you need to define it.

Code: [Select]
(setq Rev "01") ; your revision number
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.

danny

  • Guest
extract layer from files
« Reply #13 on: March 25, 2005, 07:08:14 PM »
thanks CAB...that worked great. :)