Author Topic: ObjectDBX and Save as ac2000_dwg  (Read 592 times)

0 Members and 1 Guest are viewing this topic.

domenicomaria

  • Swamp Rat
  • Posts: 723
ObjectDBX and Save as ac2000_dwg
« on: January 26, 2023, 03:08:31 AM »
Code - Auto/Visual Lisp: [Select]
  1. (defun C:DWG-FOLDER-SAVE-AS-ACAD-2000 (/ a2k-dwg obj-dbx result src-dwg-lst tmp x)
  2.  
  3.    ;       (setenv "DefaultFormatForSave" "12")
  4.  
  5.    (if (not (vl-file-directory-p *dsa2k-path*))
  6.       (setq *dsa2k-path* (getvar "dwgprefix"))
  7.    )
  8.  
  9.    (if (setq tmp (dcl-browsefolder "   select a folder :" *dsa2k-path*))
  10.       (setq *dsa2k-path* tmp)
  11.    )
  12.    
  13.    (setq   src-dwg-lst
  14.            (mapcar '(lambda (x) (strcat *dsa2k-path* "\\" x))
  15.                    (vl-directory-files *dsa2k-path* "*.dwg" 1)
  16.            )
  17.    )
  18.    
  19.    (setq   obj-dbx (vl-catch-all-apply
  20.                     'vla-getinterfaceobject
  21.                     (list (vlax-get-acad-object)
  22.                           (strcat "objectdbx.axdbdocument." (substr (getvar 'acadver) 1 2))
  23.  
  24.                     )
  25.                  )
  26.    )
  27.  
  28.    (if (or (null obj-dbx) (vl-catch-all-error-p obj-dbx))
  29.       (progn (prompt "\nUnable to interface with ObjectDBX.") (exit))
  30.    )
  31.  
  32.  
  33.    (foreach   src-dwg src-dwg-lst
  34.       (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-open (list obj-dbx src-dwg)))
  35.          (progn (prompt (strcat "\nError opening file: " (vl-filename-base src-dwg) ".dwg"))
  36.                 (exit)
  37.          )
  38.       )
  39.  
  40.    ;       (setenv "DefaultFormatForSave" "12")    !
  41.          ac2000_dwg
  42.       )
  43.  
  44.       (setq a2k-dwg (strcat (vl-string-right-trim ".dwg" src-dwg) " - - - [ACAD-2000].dwg"))
  45.       (vla-saveas obj-dbx a2k-dwg)
  46.  
  47.       (setq result (append result (list (list a2k-dwg (LM:DWGVERSION a2k-dwg)))))
  48.    )
  49.  
  50.    (if (= 'vla-object (type obj-dbx))
  51.       (vlax-release-object obj-dbx)
  52.    )
  53.  
  54.  
  55.    result
  56.  
  57. )
  58. (defun C:DFS2K () (C:DWG-FOLDER-SAVE-AS-ACAD-2000))
  59.  

It apparently works, but it save as ac2018_dwg !
Where is the mistake ?

I tryed to use
(setenv "DefaultFormatForSave" "12")
and
(vla-put-saveastype
   (vla-get-opensave (vla-get-preferences (vlax-get-acad-object) ) )
   ac2000_dwg
)

but however it saves as ac2018_dwg
« Last Edit: January 26, 2023, 10:50:42 AM by domenicomaria »

mhupp

  • Bull Frog
  • Posts: 250
Re: ObjectDBX and Save as ac2000_dwg
« Reply #1 on: January 26, 2023, 08:55:48 AM »
setenv just saves the value 12 to your registry in a folder called DefaultFormatForSave.
https://help.autodesk.com/view/OARX/2022/ENU/?guid=GUID-0C2E8222-62A8-4529-8A8A-58AAB2A5F23B
you want to use (setvar 'saveformat 12)

Don't forget to change it back do your default settings after the lisp is run.

domenicomaria

  • Swamp Rat
  • Posts: 723
Re: ObjectDBX and Save as ac2000_dwg
« Reply #2 on: January 26, 2023, 10:49:19 AM »
I tryed to use
(setenv "DefaultFormatForSave" "12")
and
(vla-put-saveastype
   (vla-get-opensave (vla-get-preferences (vlax-get-acad-object) ) )
   ac2000_dwg
)
but however it saves as ac2018_dwg
. . .
(and however in this context it is not possible to use SETVAR . . . )

mhupp

  • Bull Frog
  • Posts: 250
Re: ObjectDBX and Save as ac2000_dwg
« Reply #3 on: January 26, 2023, 11:56:56 AM »
looked a little more closely at your code you don't need the following lines anymore.

32
41-45
57

update line 48
Code - Auto/Visual Lisp: [Select]
  1. (vla-saveas obj-dbx a2k-dwg ac2000_dwg)

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: ObjectDBX and Save as ac2000_dwg
« Reply #4 on: January 26, 2023, 12:31:50 PM »
This is a known bug with the ObjectDBX interface - it will only ever save to native format (i.e. the highest version available in the host application).

domenicomaria

  • Swamp Rat
  • Posts: 723
Re: ObjectDBX and Save as ac2000_dwg
« Reply #5 on: January 26, 2023, 12:51:01 PM »
This is a known bug with the ObjectDBX interface - it will only ever save to native format (i.e. the highest version available in the host application).

thank you

and I suppose that there is no workaround !

57gmc

  • Bull Frog
  • Posts: 358
Re: ObjectDBX and Save as ac2000_dwg
« Reply #6 on: January 26, 2023, 02:35:33 PM »
There is no workaround, since ObjectArx is a separate library. That's the way it is written. The only alternative is to use .NET. It has it's own api and doesn't rely on ObjectARX.