Author Topic: Batch: Open DWG plus Lisp from another lisp?  (Read 7145 times)

0 Members and 1 Guest are viewing this topic.

Peter2

  • Swamp Rat
  • Posts: 654
Batch: Open DWG plus Lisp from another lisp?
« on: March 24, 2014, 08:20:45 AM »
Hi

this is a question out of the batch-family "run script from lisp / run lisp from script / run script from script / run lisp from lisp" ...

The first, common question is:
Who knows an info / link / doc which describes the basic behaviour and possibilities of these features?

The second, detailed questions is:
How to "open a batch of DWGs and run a defined lisp ("sub.lsp") and close the DWGs" from a lisp ("main.lsp")?

My current ideas / answers are:

a) Create and run a script:
"main.lsp" creates and writes a script like: "open test.dwg (load "sub.lsp") sub qsave close test.dwg"
Then I have "(command "script" "myscript.scr")
This could work, but I don't have control over a script which could crash or hang or ....

b) Use Starting-group
I use the starting-group (is this the right name in English?) where I add my "sub.lsp" which starts immediately when the DWG will be opened.
In "main.lsp" I use "(command open test.dwg)" to open the DWG which starts the lisp.

c) ObjectDBX:
The "sub.lsp" (there are many of it ...) should also be used within AutoCAD and this is why the code should be the same without optimization for ObjectDBX.

d) Others ???
I also use OpenDCL and DosLib on a low level (and don't know all commands at the moment), but it would be fine to have commands like:
Code: [Select]
open test.dwg
start sub.lsp inside test.dwg
close test.dwg

This ( d) ) would be perfect ...

Any help would be appreciated  :-D


EDIT:
Here is a solution with VBA (from the year 2007), but VBA is nearly dead ...
Execute commands on all open drawings
« Last Edit: March 24, 2014, 11:18:49 AM by Peter2 »
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23

Locke

  • Guest
Re: Batch: Open DWG plus Lisp from another lisp?
« Reply #1 on: March 24, 2014, 11:51:50 AM »
I've seen option 'A' work well in a production environment.  The benefit is that it's very flexible, and can be modified quickly depending on the needs of the project. 

The downside is as you mentioned; no way to diagnose the job while it's running and react. 

Not sure how comfortable you are in .NET, but using a ServicedComponent interface bridge between AutoCAD in-process calls and interop, this sort of automation becomes effortless.

Peter2

  • Swamp Rat
  • Posts: 654
Re: Batch: Open DWG plus Lisp from another lisp?
« Reply #2 on: March 24, 2014, 11:57:23 AM »
Not sure how comfortable you are in .NET ...
:embarrassed:  :-(  :embarrassed:
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23

Locke

  • Guest
Re: Batch: Open DWG plus Lisp from another lisp?
« Reply #3 on: March 24, 2014, 03:09:52 PM »
Have you considered using something like Viru's ScriptPro?  When I originally looked at the source, I remember it invokes AutoCAD via Process.Start(), but it still has some intelligence for checking the health of AutoCAD, and restarting on failure.

Peter2

  • Swamp Rat
  • Posts: 654
Re: Batch: Open DWG plus Lisp from another lisp?
« Reply #4 on: March 24, 2014, 03:56:13 PM »
...something like Viru's ScriptPro?  ....
Who? Where? What?
I only know ScriptPro from Autodesk, which is fine in its way but not the solution that I need.
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23

Locke

  • Guest
Re: Batch: Open DWG plus Lisp from another lisp?
« Reply #5 on: March 24, 2014, 04:52:58 PM »
...something like Viru's ScriptPro?  ....
Who? Where? What?
I only know ScriptPro from Autodesk, which is fine in its way but not the solution that I need.

This is what I was referring to: http://through-the-interface.typepad.com/through_the_interface/2010/10/novembers-plugin-of-the-month-live-on-autodesk-labs-scriptpro-20-for-autocad.html

Also as I'm just realizing this is specifically in the forum section for Vanilla/AutoLISP I'll let someone with more brains take over so I don't muck up your thread any more.  :wink:

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Batch: Open DWG plus Lisp from another lisp?
« Reply #6 on: March 24, 2014, 07:02:11 PM »
Perhaps AutoBatch from Ductisoft would help: http://www.ductisoft.com/en/drafters/Batch/AutoBatch.html

It seems to be the most robust system that I have seen.

Peter2

  • Swamp Rat
  • Posts: 654
Re: Batch: Open DWG plus Lisp from another lisp?
« Reply #7 on: March 25, 2014, 05:18:01 AM »
Hi
thanks for your hints, but I don't search a full-functional-batch software, I need the described (small?) function to integrate it into my own software.
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23

Bhull1985

  • Guest
Re: Batch: Open DWG plus Lisp from another lisp?
« Reply #8 on: March 25, 2014, 07:24:17 AM »
http://www.lee-mac.com/odbxbase.html

Lee Mac's Object DBX wrapper.
Simply wrap your "sub.lsp" using this tool and batch process all required dwgs.

Peter2

  • Swamp Rat
  • Posts: 654
Re: Batch: Open DWG plus Lisp from another lisp?
« Reply #9 on: March 25, 2014, 07:30:09 AM »
...Lee Mac's Object DBX wrapper....
This would be great, but will it work for all lisps? Lee writes there there a "no selection sets, no commands, no ent*-methods, no system-variables". If this is "a must" then I have a problem, because I need the "forbidden functions".
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23

Bhull1985

  • Guest
Re: Batch: Open DWG plus Lisp from another lisp?
« Reply #10 on: March 25, 2014, 08:21:07 AM »
Use the VLA/VLAX equivalents

Peter2

  • Swamp Rat
  • Posts: 654
Re: Batch: Open DWG plus Lisp from another lisp?
« Reply #11 on: March 25, 2014, 09:35:33 AM »
Use the VLA/VLAX equivalents
The idea is that any existing lisp should be used without recoding. I will see if I can keep this idea alive - or if I have to bury it.
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: Batch: Open DWG plus Lisp from another lisp?
« Reply #12 on: March 25, 2014, 01:07:45 PM »
Publish?
James Buzbee
Windows 8

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: Batch: Open DWG plus Lisp from another lisp?
« Reply #13 on: March 25, 2014, 06:26:15 PM »
An old Script-based application without the restrictions of ObjectDBX: Script Writer

Peter2

  • Swamp Rat
  • Posts: 654
Re: Batch: Open DWG plus Lisp from another lisp?
« Reply #14 on: March 26, 2014, 04:31:38 AM »
At first: Thanks to all for replies. The "lucky bag" ("jack of all trades device") is still missing: Script has pros and ccons, ObjectDBX too ...

At the moment I have a trivial(?) problem on the lower level. My lisp creates a script and starts it:
Code - Auto/Visual Lisp: [Select]
  1. ; write the script with open - call a lisp - close
  2. (setq x (open (strcat dwgr_sourcefolder "\\automat.scr") "w"))
  3. (princ (strcat "_.open " eintrag " taskerlisp _.close ") x)
  4. (close x)
  5.  
  6. ; start the script
  7. (if foundflag
  8.     (progn
  9.         (vl-registry-write "HKEY_CURRENT_USER\\Software\\cadtool\\automat\\monitor" "workingflag"  1)
  10.         (princ "\n1\n")
  11.         (setq x (strcat dwgr_sourcefolder "\\automat"))
  12.         (command "_.Script" x)
  13.         (princ "\n2\n")
  14.     )
  15. )

The result is:
Code - Auto/Visual Lisp: [Select]
  1. 1
  2. ; Error: invalid AutoCAD command: nil

When I copy&paste the line (command "_script"...) to the command-line it works fine: the script exists, the script works, the lisp inside the script works - but I can not start the script via my mainlisp, although I found some lisp which starts script  ...
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23