Author Topic: Open DWG Read-Only, Do Something, Close, Wash, Rinse, Repeat...  (Read 5729 times)

0 Members and 1 Guest are viewing this topic.

Guest

  • Guest
Open DWG Read-Only, Do Something, Close, Wash, Rinse, Repeat...
« on: February 14, 2008, 03:02:15 PM »
Now I'll be first to admit that I don't know much about VLisp so please be gentle!!

I'm in the process of creating a proggy that will open files, grab some info, close, then move on to the next file.

I found this...

(vla-activate (vla-open (vla-get-documents (vlax-get-acad-object)) "C:\My Path\My File.dwg" :VLAX-TRUE))

I'm running in MDI mode, and when the previous line is called, it opens the file - great, halfway there.  However, the following lines (the ones that grab info) aren't called in the read-only drawing.  When I switch back to the previous drawing (the one that was open when this whole thing started), then the "info-grabbing" code begins running.  Soooo..... What the flip??!?

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Open DWG Read-Only, Do Something, Close, Wash, Rinse, Repeat...
« Reply #1 on: February 14, 2008, 03:08:57 PM »
Sorry Matt, I don't have time to pen the response you deserve (I mean that in a nice way) so I'm by-passing all the discussion and going straight to the bottom line as I see it. IF you're intention is to open multiple files via lisp AND you only need 'read-only' access THEN use ObjectDBX to harvest what ya need. Fast, fast, fast and no MDI headaches. Otherwise? Oh look, a bird.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Guest

  • Guest
Re: Open DWG Read-Only, Do Something, Close, Wash, Rinse, Repeat...
« Reply #2 on: February 14, 2008, 03:14:47 PM »
Sorry Matt, I don't have time to pen the response you deserve (I mean that in a nice way) so I'm by-passing all the discussion and going straight to the bottom line as I see it. IF you're intention is to open multiple files via lisp AND you only need 'read-only' access THEN use ObjectDBX to harvest what ya need. Fast, fast, fast and no MDI headaches. Otherwise? Oh look, a bird.

I would but (and I forgot to mention this) there may be a need to print a layout tab whilst harvesting aforementioned information.  Oops!   :oops:

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Open DWG Read-Only, Do Something, Close, Wash, Rinse, Repeat...
« Reply #3 on: February 14, 2008, 03:17:10 PM »
I would but (and I forgot to mention this) there may be a need to print a layout tab whilst harvesting aforementioned information.  Oops!   :oops:

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

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Open DWG Read-Only, Do Something, Close, Wash, Rinse, Repeat...
« Reply #4 on: February 14, 2008, 03:20:13 PM »
So what you actually want is batch plot + data harvesting via LISP when SDI=0?
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Guest

  • Guest
Re: Open DWG Read-Only, Do Something, Close, Wash, Rinse, Repeat...
« Reply #5 on: February 14, 2008, 03:24:47 PM »
So what you actually want is batch plot + data harvesting via LISP when SDI=0?

Basically.... And I've got most of what I need already... I'm getting hung up on the active document not running the commands.

Guest

  • Guest
Re: Open DWG Read-Only, Do Something, Close, Wash, Rinse, Repeat...
« Reply #6 on: February 14, 2008, 03:44:05 PM »
Well.... I'm resorting to this method for the time being until I find out if there's a better way (I have to believe that there is, I just haven't figured it out/seen it yet).

(command "vbastmt" "documents.open .....

Scratch that idea...

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Open DWG Read-Only, Do Something, Close, Wash, Rinse, Repeat...
« Reply #7 on: February 14, 2008, 03:51:25 PM »
No real way to do what you want with lisp, unless you change the sdi to 1, and go that way.  That is how I had to do it when I did my batch plot routine.
Tim

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

Please think about donating if this post helped you.

deegeecees

  • Guest
Re: Open DWG Read-Only, Do Something, Close, Wash, Rinse, Repeat...
« Reply #8 on: February 14, 2008, 03:54:16 PM »
Would something like this help?

Quote
;batch_anything.lsp
;Created XXXXXXXX
;Date:   Sept of 2002
;Description:   Batch Process
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;start prog

(DEFUN C:batch_anything ()

;;;;;;;;;;;;;;;;;;;;;;;;;Select directory to be processed

   (setq dfil (getfiled "Select A File In The Directory You Want To Batch Process" "p:/" "dwg" 0))
   (setq wutdir (vl-filename-directory dfil))
   (setq wutfiles (vl-directory-files wutdir "*.dwg"))

   (setq scrfile (open "c:\\scrfile.scr" "w"))
   (close scrfile)
   (setq scrfile (open "c:\\scrfile.scr" "a"))

(foreach n wutfiles
   (setq n2 (strcat "\""wutdir "\\" n "\""))
   (setq n2 (vl-string-translate "\\" "\\" n2))
   (setq scrline (strcat "open" " " n2 " " "(load\"batch_core\")" " " "batch_insert" " " "qsave" " " "close"));;;;;;;COMMANDS FOR BATCH GO HERE
   (write-line scrline scrfile)
   (princ)
)

   (close scrfile)
(command "script" "c:\\scrfile")

(princ "\n***Batch complete.***")
(princ)


);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;DEFUN

Patrick_35

  • Guest
Re: Open DWG Read-Only, Do Something, Close, Wash, Rinse, Repeat...
« Reply #9 on: February 15, 2008, 07:38:36 AM »
Hello

I don't understand what you want to do

Code: [Select]
(setq my_dwg (vla-open (vla-get-documents (vlax-get-acad-object)) "C:/My Path/My File.dwg")And a (vlax-dump-object my_dwg) as the same as (vlax-dump-object (vla-get-activedocument (vlax-get-acad-object))) :?

@+