Author Topic: 2012 DWG open edit close problem  (Read 2551 times)

0 Members and 1 Guest are viewing this topic.

David Bethel

  • Swamp Rat
  • Posts: 656
2012 DWG open edit close problem
« on: January 16, 2015, 03:26:38 PM »
Greetings.

I now remember why I don't like the newer versions of ACAD  yuck!

I need to open all files in a given directory, load a .lsp, issue a autolisp call, save the changes, close the dwg.

I will use DosLIB to obtain the directory and file info

In earlier version it is pretty straight forward.

I have to make this work in 2012...

psudo code
  Get user input of the directory work with ( i can get this from getfiled )
  Write to a script file for each dwg;

  _.OPEN command
  dwg name
 (load "myfoo")
 (my_foo)
 _.CLOSE command


Then the user can manually run the .SCR file ( multiple times if necessary )

I've found some info on the sysvar SDI.  I'm really not sure if this is way to go.  When it errors out, it really doesn't give good info

By hand i can get 'CLOSE does not work with SDI 1'

By hand open does not need SDI =1, but it does in a script or code ?

How do you guys approach this scenario ?


Script so far ( not working )

Code: [Select]
(if (getvar "SDI") (setvar "SDI" 1))
(if (/= (getvar "DBMOD") 0)
    (command "_.OPEN" "_Yes" "C:/ACADPROJ/TO/PARENT/GCIR001E")
    (command "_.OPEN" "C:/ACADPROJ/TO/PARENT/GCIR001E"))
(if (getvar "SDI") (setvar "SDI" 0))
(load "NW_FOO")
(nw_foo "C:/ACADPROJ/TO/CHILD/")
(if (/= (getvar "DBMOD") 0)
    (command "_.CLOSE" "_N")
    (command "_.CLOSE"))
(if (getvar "SDI") (setvar "SDI" 1))
(if (/= (getvar "DBMOD") 0)
    (command "_.OPEN" "_Yes" "C:/ACADPROJ/TO/PARENT/GCIR001P")
    (command "_.OPEN" "C:/ACADPROJ/TO/PARENT/GCIR001P"))
(if (getvar "SDI") (setvar "SDI" 0))
(load "NW_FOO")
(nw_foo "C:/ACADPROJ/TO/CHILD/")
(if (/= (getvar "DBMOD") 0)
    (command "_.CLOSE" "_N")
    (command "_.CLOSE"))
« Last Edit: January 16, 2015, 03:30:03 PM by David Bethel »
R12 Dos - A2K

ronjonp

  • Needs a day job
  • Posts: 7531
Re: 2012 DWG open edit close problem
« Reply #1 on: January 16, 2015, 03:35:45 PM »
One thing I notice is your filenames do not have the ".dwg"

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

David Bethel

  • Swamp Rat
  • Posts: 656
Re: 2012 DWG open edit close problem
« Reply #2 on: January 16, 2015, 04:35:26 PM »
I didn't think that .dwg was ever required .  Am I that far behind times ?

Hopefully there is a fancy dancy vl call that works like the old days

Thanks!  -David
R12 Dos - A2K

T.Willey

  • Needs a day job
  • Posts: 5251
Re: 2012 DWG open edit close problem
« Reply #3 on: January 16, 2015, 05:06:52 PM »
Here is how one section of a script I have used in the past on 2012 looks like, the rest is the same just a different drawing name.  Some of the commands are native commands and others are lisp commands that load per an .mnl file.
Code: [Select]
_.open
"H:\Work\3M\Kelli\Irvine\Flexpack\aps\12-2718-5160-7_019.dwg"
(vlax-for lo (vla-get-Layouts (vla-get-ActiveDocument (vlax-get-Acad-Object))) (if (/= (vla-get-Name lo) "Model") (vla-Delete lo)))
measurement 0
insunits 1
ctab layout1
.-insert "C:\ACADSUPP2011\TEMPLATE\3M-TITLEBLOCK-E.dwg" 0,0 1 1 0
.explode (entlast)
_3MTitleLayers P
_.mview 0.7628,33.1694 43.2372,5.1613
_.mspace
_.plan _world
_.zoom .95x
_.pspace
_.-layer new Defpoints
.chprop (entlast)  Layer Defpoints
_.zoom extents
updnum
_.qsave
_.close
Tim

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

Please think about donating if this post helped you.

David Bethel

  • Swamp Rat
  • Posts: 656
Re: 2012 DWG open edit close problem
« Reply #4 on: January 17, 2015, 08:53:37 AM »
I did away with all (command  open qsave close ) calls and went back to the native commands in the script and got it to work.

Now how to figure out a redefine block scenario using insert block=block without using a (command) to exit as it causes the script stop processing..

Thanks!  -David
R12 Dos - A2K

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: 2012 DWG open edit close problem
« Reply #5 on: January 17, 2015, 08:57:06 AM »
Now how to figure out a redefine block scenario using insert block=block without using a (command) to exit as it causes the script stop processing..

Insert & erase  :wink:

David Bethel

  • Swamp Rat
  • Posts: 656
Re: 2012 DWG open edit close problem
« Reply #6 on: January 17, 2015, 10:24:39 AM »
Yes Lee, that's where I'm at. If the child has ATTRIButes, its a bit more complicated.

If you use:
Code: [Select]
(while (> (getvar "CMDACTIVE) 0)
         (command ""))

The script stops processing.  And you have manually type RESUME

Still, we're getting there.  Thanks!  -David
R12 Dos - A2K

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: 2012 DWG open edit close problem
« Reply #7 on: January 17, 2015, 10:30:06 AM »
Code: [Select]
(setvar 'attreq 0)

David Bethel

  • Swamp Rat
  • Posts: 656
Re: 2012 DWG open edit close problem
« Reply #8 on: January 17, 2015, 12:27:06 PM »
Code: [Select]
(setvar 'attreq 0)

Wow!  didn't about that 1 !  Great !  -David
R12 Dos - A2K