Author Topic: Create A New Drawing & Save Without Opening it  (Read 1560 times)

0 Members and 1 Guest are viewing this topic.

JohnSnow

  • Newt
  • Posts: 52
Create A New Drawing & Save Without Opening it
« on: January 22, 2022, 10:14:31 PM »
Currently I am using the following codes to create new drawings and save them after doing something. It works fine but the screen keeps updating showing file being created. Is there anyway to do it in the background in silent without being seen? Any example codes are much appreciated.

(setq AcadApp (vlax-get-acad-object))
(setq acadDocs (vla-get-documents AcadApp))
(setq dwg (vl-catch-all-apply 'vla-add (list AcadDocs (getenv "LastTemplate"))))
(setq dwgname xxx)
(do_something)
(vla-saveas dwg dwgname)
(vla-close dwg)

LinhPham

  • Mosquito
  • Posts: 10
Re: Create A New Drawing & Save Without Opening it
« Reply #1 on: January 23, 2022, 03:18:50 AM »
People do it with .NET. I never know anyone can do it with AutoLisp. There is VBA AcadDBX or something can do it, but it is very cubersome API.
AutoCAD Plugin Developer Freelancer

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Create A New Drawing & Save Without Opening it
« Reply #2 on: January 23, 2022, 06:58:25 AM »
It's possible to accomplish this in LISP by using ObjectDBX, however, the feasibility of this would depend on the operations being performed by your (do_something) expression, as ObjectDBX generally only permits the use of ActiveX properties & methods, and even then, not every aspect of the document object model is exposed through the ObjectDBX interface.

JohnSnow

  • Newt
  • Posts: 52
Re: Create A New Drawing & Save Without Opening it
« Reply #3 on: January 23, 2022, 09:00:04 AM »
Thank you very much. Understood.

Is there any place that I can find the full list of ActiveX properties and methods that are available by ObjectDBX?
I simply want to add lines, texts, layers etc and set the active layer and other basic things like that.
« Last Edit: January 23, 2022, 09:06:28 AM by JohnSnow »

baitang36

  • Bull Frog
  • Posts: 213
Re: Create A New Drawing & Save Without Opening it
« Reply #4 on: January 24, 2022, 02:42:04 AM »
Currently I am using the following codes to create new drawings and save them after doing something. It works fine but the screen keeps updating showing file being created. Is there anyway to do it in the background in silent without being seen? Any example codes are much appreciated.

(setq AcadApp (vlax-get-acad-object))
(setq acadDocs (vla-get-documents AcadApp))
(setq dwg (vl-catch-all-apply 'vla-add (list AcadDocs (getenv "LastTemplate"))))
(setq dwgname xxx)
(do_something)
(vla-saveas dwg dwgname)
(vla-close dwg)
  try accoreconsole.exe

d2010

  • Bull Frog
  • Posts: 326
Re: Create A New Drawing & Save Without Opening it
« Reply #5 on: January 24, 2022, 03:03:02 AM »
I believe, the feature "opening many Drawings with OneScript.lsp",
bankrupt the AutoCad/BrisCad or ZwCad.
The autodesk.team do not understand, the CATIA, Z-Cad, SolidWork "steal the money$" from the market after Autodesk-insert this feature inside Autocad.
 :glarestraight:
Code: [Select]
If you like this opinion, then you replay-me, here

Create A New Drawing & Save Without Opening it
Thank you very much. Understood.

Is there any place that I can find the full list of ActiveX properties and methods that are available by ObjectDBX?
I simply want to add lines, texts, layers etc and set the active layer and other basic things like that.
« Last Edit: January 24, 2022, 03:06:06 AM by d2010 »

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Create A New Drawing & Save Without Opening it
« Reply #6 on: January 24, 2022, 12:20:16 PM »
Is there any place that I can find the full list of ActiveX properties and methods that are available by ObjectDBX?
I simply want to add lines, texts, layers etc and set the active layer and other basic things like that.

I'm not aware of the existence of official documentation on ObjectDBX (I don't think development of the interface was ever properly completed, as there are also still many bugs), but generally speaking, the following applies:
  • No Selection Sets (use of ssget, ssname, ssdel etc)
  • No Command calls (command "_.line" ... etc)
  • No ent* methods (entmod, entupd etc) - though these are successful under some circumstances
  • No access to System Variables (getvar, setvar, vla-getvariable, vla-setvariable etc)
As such, you'll be able to create the various objects you have described, but you won't be able to set the current layer.

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Create A New Drawing & Save Without Opening it
« Reply #7 on: January 24, 2022, 05:15:43 PM »
Interesting.... Thanks for sharing that Lee. I thought you could do some layer control.
Civil3D 2020

BIGAL

  • Swamp Rat
  • Posts: 1409
  • 40 + years of using Autocad
Re: Create A New Drawing & Save Without Opening it
« Reply #8 on: January 24, 2022, 06:13:45 PM »
Like baitang36 look into accoreconsole uses lisp etc should be able to set current layer.
A man who never made a mistake never made anything

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: Create A New Drawing & Save Without Opening it
« Reply #9 on: January 24, 2022, 06:18:20 PM »
I would at least have thought there would be access to database sysvars, like  textstyle,  tablestyle
Setting layers is a database operation, seems like there would be access to that as well.. analog to opening side databases in ARX.
No partying with the document or editor

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: Create A New Drawing & Save Without Opening it
« Reply #10 on: January 25, 2022, 05:29:34 PM »
I would at least have thought there would be access to database sysvars, like  textstyle,  tablestyle
Setting layers is a database operation, seems like there would be access to that as well.. analog to opening side databases in ARX.

Code - Auto/Visual Lisp: [Select]
  1. _$ (setq dbx (LM:getdocumentobject "drawing1.dwg"))
  2. #<VLA-OBJECT IAxDbDocument 000000002df20680>
  3. _$ (vla-setvariable dbx "clayer" "0")
  4. ; error: ActiveX Server returned the error: unknown name: SetVariable
  5. ; error: ActiveX Server returned the error: unknown name: ActiveLayer

:-(

JohnSnow

  • Newt
  • Posts: 52
Re: Create A New Drawing & Save Without Opening it
« Reply #11 on: January 28, 2022, 02:04:52 AM »
Thank you everyone. I will check out accoreconsole