Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: ObjectDBX - Open & Save DWG

  1. #1
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default ObjectDBX - Open & Save DWG

    After I "Resave All Sheets" using Sheet Set Manager (SSM), I loose my thumbnails in both the SSM (mouse over), and in the AutoCAD open dialogue window.

    Can someone help me complete a simple routine (using ObjectDBX) that will open, then save all drawing in a specified directory?

    I can make scripts, but they take too long! After watching an AU course and seeing how fast ObjectDBX is, I think it is exactly what I'm looking for.

    I've modified some source code from the above mentioned AU course; here's what I've got so far:
    Source Code Attribution: Robert Bell http://au.autodesk.com/?nd=class&session_id=5372

    Code:
    (defun i:CloseDBXDoc  (myDoc)
      (vl-catch-all-apply ‘vlax-Release-Object (list myDoc)))
     
    (defun C:Test3  (/ myDoc i fileName)
      (vl-load-com)
      (setq myDoc (vla-activate (vla-open (vla-get-documents (vlax-Get-Acad-Object)))))
      (setq i 1)
      (repeat 103
        (cond
          ((>= 9 i) 
            (setq fileName (strcat "[FilePath]\\[FilePrefix]-00400" (itoa i) ".dwg")))
          ((and (<= 10 i) (> 100 i)) 
            (setq fileName (strcat "[FilePath]\\[FilePrefix]-0040" (itoa i) ".dwg")))
          ((<= 100 i)
            (setq fileName (strcat "[FilePath]\\[FilePrefix]-004" (itoa i) ".dwg"))))
        (vla-open myDoc fileName)
        ;;(vla-saveas myDoc fileName nil)
        (vlax-invoke-method myDoc 'saveas fileName)
        (setq i (1+ i)))
        (setq myDoc (i:CloseDBXDoc myDoc))
        (princ))
     
    (C:Test3)
    The above cond statment is to filter the filename for my company's naming convention, as I have 100+ drawings in this particular project.

    This is my first attempt at ObjectDBX. I'm clearly missing something, as I continuously get this error:

    ; error: too few actual parameters
    Note - When attempting to use the original source code, I get this error:
    ; error: Automation Error. Description was not provided.
    Thanks in advance for your help!
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  2. #2
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,420
    Login to Give a bone
    0

    Default Re: ObjectDBX - Open & Save DWG

    Because ObjectDbx does not use the graphics editor, it cannot save a thumbnail.
    C:> ED WORKING....


    LinkedIn

  3. #3
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: ObjectDBX - Open & Save DWG

    Quote Originally Posted by Ed Jobe View Post
    Because ObjectDbx does not use the graphics editor, it cannot save a thumbnail.
    Understood. Thanks for the clarification.

    Can you still help me with the request, as I am sure I will need it in the future?
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  4. #4
    The Silent Type RobertB's Avatar
    Join Date
    2000-01
    Location
    Seattle WA USA
    Posts
    5,859
    Login to Give a bone
    0

    Default Re: ObjectDBX - Open & Save DWG

    What version of AutoCAD are you using?

    This line is a problem:
    Code:
      (setq myDoc (vla-activate (vla-open (vla-get-documents (vlax-Get-Acad-Object)))))
    I'm not sure what you are trying to do with this. The failure is that you are getting a collection of the open documents, and then attempting to open the collection (a no-no) but you already have the documents open.

    But if you are trying to use ObjectDBX, you cannot use the Activate method either. Not to mention that the posted code is not using ObjectDBX.
    R. Robert Bell
    Design Technology Manager
    Stantec
    Opinions expressed are mine alone and do not reflect the views of Stantec.

  5. #5
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: ObjectDBX - Open & Save DWG

    I am using AutoCAD Civil 3D Land Desktop Companion (LDC) 2009.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  6. #6
    The Silent Type RobertB's Avatar
    Join Date
    2000-01
    Location
    Seattle WA USA
    Posts
    5,859
    Login to Give a bone
    0

    Default Re: ObjectDBX - Open & Save DWG

    Quote Originally Posted by mat.kirkland View Post
    I am using AutoCAD Civil 3D Land Desktop Companion (LDC) 2009.
    If all you are doing, at this stage, is trying to open and save the each drawing, the following is what you would do. However, as Ed pointed out, ObjectDBX will not save the thumbnails since you are not opening the documents in the editor.
    Code:
    (defun C:Test  (/ fileNames myDoc)
     (vl-load-com)
     (cond ((and (setq fileNames (vl-directory-files "C:\\Temp" "<FilePrefix>-004*.dwg" 1))
                 (setq myDoc (vla-GetInterfaceObject
                              (vlax-Get-Acad-Object)
                              (strcat "ObjectDBX.AxDbDocument." (substr (getvar 'AcadVer) 1 2)))))
            (foreach fileName  fileNames
             (vla-Open myDoc fileName)
             (vla-SaveAs myDoc fileName))
            (setq myDoc (vl-catch-all-apply 'vlax-Release-Object (list myDoc))))
           (fileNames (princ "\nUnable to create ObjectDBX document."))
           (T (princ "\nNo matching filenames found.")))
     (princ))
    R. Robert Bell
    Design Technology Manager
    Stantec
    Opinions expressed are mine alone and do not reflect the views of Stantec.

  7. #7
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: ObjectDBX - Open & Save DWG

    Robert, for some reason when I replied with my version of AutoCAD this was the only comment that was shown:
    Quote Originally Posted by RobertB View Post
    What version of AutoCAD are you using?
    Even thought this effort would not resave the thumbnails as I had hoped, I am certain that I will have use for the ability to rapidly gether information in the near future.

    Quote Originally Posted by RobertB View Post
    I'm not sure what you are trying to do with this. The failure is that you are getting a collection of the open documents, and then attempting to open the collection (a no-no) but you already have the documents open.

    But if you are trying to use ObjectDBX, you cannot use the Activate method either. Not to mention that the posted code is not using ObjectDBX.
    Earlier searches resulted in the deviations from your original code (from your AU course). I regret the butchery of your source code, that certainly was not my intent.

    As stated above, this was my first attempt at ObjectDBX, as I do not have working knowledge of the object oriented, or application level components of the language. I am, however, very comfortable at the drawing level and have developed multiple solutions for my, and my coworkers production needs.

    Quote Originally Posted by RobertB View Post
    If all you are doing, at this stage, is trying to open and save the each drawing, the following is what you would do.

    Code:
    (defun C:Test  (/ fileNames myDoc)
     (vl-load-com)
     (cond ((and (setq fileNames (vl-directory-files "C:\\Temp" "<FilePrefix>-004*.dwg" 1))
                 (setq myDoc (vla-GetInterfaceObject
                              (vlax-Get-Acad-Object)
                              (strcat "ObjectDBX.AxDbDocument." (substr (getvar 'AcadVer) 1 2)))))
            (foreach fileName  fileNames
             (vla-Open myDoc fileName)
             (vla-SaveAs myDoc fileName))
            (setq myDoc (vl-catch-all-apply 'vlax-Release-Object (list myDoc))))
           (fileNames (princ "\nUnable to create ObjectDBX document."))
           (T (princ "\nNo matching filenames found.")))
     (princ))
    I understand that my request is very general, and lacking specificity. I appreciate your willingness to provide me with the stepping stone in the code above.

    Also Robert, if I may, I'd like to thank you personally. Much of my learning*** has come from your materials directly, both here on AUGI, and from Autodesk University. I'm thrilled to have the opportunity to interact with you in this manor. Your reputation is highly respected, and given much credence, among the senior CAD staff in my office.

    *** DISCLAIMER: For anyone else who may be new to coding, this thread should not reflect upon the quality of instruction, but rather upon the student.

    Thanks again to everyone who responded to my request, Cheers!
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  8. #8
    The Silent Type RobertB's Avatar
    Join Date
    2000-01
    Location
    Seattle WA USA
    Posts
    5,859
    Login to Give a bone
    0

    Default Re: ObjectDBX - Open & Save DWG

    Quote Originally Posted by mat.kirkland View Post
    Also Robert, if I may, I'd like to thank you personally. Much of my learning*** has come from your materials directly, both here on AUGI, and from Autodesk University. I'm thrilled to have the opportunity to interact with you in this [manner]. Your reputation is highly respected, and given much credence, among the senior CAD staff in my office.

    *** DISCLAIMER: For anyone else who may be new to coding, this thread should not reflect upon the quality of instruction, but rather upon the student.

    Thanks again to everyone who responded to my request, Cheers!
    Thanks. If there is anything further I can help with I'm usually here.

    P.S. The reason you didn't see the rest of my initial reply was because I edited it right after I posted it.
    R. Robert Bell
    Design Technology Manager
    Stantec
    Opinions expressed are mine alone and do not reflect the views of Stantec.

  9. #9
    Active Member
    Join Date
    2002-12
    Posts
    77
    Login to Give a bone
    0

    Default Re: ObjectDBX - Open & Save DWG

    If you are looking for some objectdbx code, here is some great example from jbuzbee to open a close a document

    Code:
    ;;; ------------ OPEN A DBXDOCUMENT
    (defun BLOCK_OpenDbx (dbxDrawingName / Application Document dbxDocument dbxOpen)
    	
    	(setq Application (vlax-get-acad-object))
    	(setq Document (vla-get-activedocument Application))
    	(if (/= dbxDrawingName (vla-get-fullname Document))
    		(progn 
    			(cond 
    				((= (substr (getvar "ACADVER") 1 5) "15.06")
    					(setq dbxDocument (vla-GetInterfaceObject Application "ObjectDBX.AxDbDocument"))
    					(setq dbxOpen (vl-catch-all-apply 'vla-open (list dbxDocument dbxDrawingName)))
    				)
    				(T
    					(setq dbxDocument (vla-GetInterfaceObject Application (strcat "ObjectDBX.AxDbDocument." (substr (getvar "acadver") 1 2))))
    					(setq dbxOpen (vl-catch-all-apply 'vla-open (list dbxDocument dbxDrawingName)))
    				)
    			)
    			(if (vl-catch-all-error-p dbxOpen)
    				(setq dbxDocument nil)
    			)
    		)
    	)
    	(vlax-release-object Application)
    	(vlax-release-object Document)
    	dbxDocument
    )
    ;;; ------------ CLOSE DBXDOCUMENT
    (defun BLOCK_CloseDbx (dbxDocument / dbxDocument)
    	
    	(if (= (type dbxDocument) 'VLA-OBJECT)
    		(progn 
    			(vlax-release-object dbxDocument)
    			(setq dbxDocument nil)
    		)
    	)
    )
    If you are looking to just do a quick save as then I suggest that you rename your old acaddoc.lsp. to acaddoc.lsp.old then save this:
    Code:
    (command "zoom" "e")
    (command "qsave")
    (command "close")
    as acaddoc.lsp. Then open the drawings that you want to save. This will step through every drawing, zoom it, save it, and close it. Then it will move onto the next one.

    Quick and painless. When you are done, just delete it and rename you old acaddoc.lsp.

  10. #10
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: ObjectDBX - Open & Save DWG

    Quote Originally Posted by TimSpangler View Post
    If you are looking for some objectdbx code, here is some great example from jbuzbee to open a close a document
    Code:
     *** Code in previous post *** 
    Tim, thanks for the feedback. I've not yet had the opportunity to test either Robert's or your code snippets.

    Quote Originally Posted by TimSpangler View Post
    If you are looking to just do a quick save as then I suggest that you rename your old acaddoc.lsp. to acaddoc.lsp.old then save this:
    Code:
    (command "zoom" "e")
    (command "qsave")
    (command "close") ; Not available in SDI mode
     
    ; This closes the drawing, but how do you "Open" another...?
    as acaddoc.lsp. Then open the drawings that you want to save. This will step through every drawing, zoom it, save it, and close it. Then it will move onto the next one.

    Quick and painless. When you are done, just delete it and rename you old acaddoc.lsp.
    I am confused on this part ... Even without ObjectDBX, why would I ever want to do this?

    First, I already have a macro that does quick saves. However, both my macro, and your suggested method (replacing acaddoc.lsp) still requires manual selection of the "Next" drawing, lacking automation altogether.
    Code:
    Command Name:  Next
    Macro:  ^C^C._qsave;._open
    Keyboard Shortcut: N, or CTRL+N
    (May require defun, and/or .PGP file modification)
    Second, why not just make a script (.SCR)? This is what I do presently, when I want to conduct repetitive action(s) on numerous drawings.
    Code:
    _open  -tab-  [Filepath]\[Filename01]  -tab-  _save
    _open  -tab-  [Filepath]\[Filename02]  -tab-  _save
    _open  -tab-  [Filepath]\[Filename03]  -tab-  _save
    ...etc
    Presto! In Ten to Fifteen minutes those 100+ drawings in my small project are done, and I can use AutoCAD again. My larger plan sets (550+ drawings) take even longer!

    This may provide the automation, but is still very slow, as compared to the speed provided by ObjectDBX. This is why i made my initial request.

    Cheers!
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

Page 1 of 2 12 LastLast

Similar Threads

  1. Save Timeline Position on Save/Open
    By stusic in forum 3ds Max - Wish List
    Replies: 5
    Last Post: 2009-08-04, 03:44 AM
  2. Fix Save method in ObjectDBX
    By mweaver in forum API Wish List
    Replies: 1
    Last Post: 2009-04-22, 06:31 PM
  3. Save As... / Open Dialog Box
    By saeborne in forum Revit Architecture - General
    Replies: 5
    Last Post: 2008-05-21, 04:17 PM
  4. Open and Save Groups
    By dpasa in forum Revit Architecture - Wish List
    Replies: 0
    Last Post: 2005-06-25, 08:10 AM
  5. Can't save & open files
    By mshoai in forum AutoCAD LT - General
    Replies: 5
    Last Post: 2004-09-03, 03:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •