USING VBA with DesignCenter find all layouts in a given dwt, preferably with ACAD ie Interop

USING VBA with DesignCenter find all layouts in a given dwt, preferably with ACAD ie Interop

QNashJSRL8
Contributor Contributor
710 Views
3 Replies
Message 1 of 4

USING VBA with DesignCenter find all layouts in a given dwt, preferably with ACAD ie Interop

QNashJSRL8
Contributor
Contributor

I want to be able to use VBA to navigate withing DESIGNCENTER to locate a specific dwt then view all of the layout tabs that are associated with that specific dwt.

I know I can open a specific path in designcenter with the following

acadDoc.SendCommand("adcnavigate" & vbCr & dwtTemplateLocations & vbCr)

ie opens DESIGNCENTER to where my templates are. In there I could navigate to my specific dwt and expand it to view its info. (Blocks, layers, layouts, etc)

Would anyone know a way I could get to this info strictly through VBA with something like

NOTE this part is made up but would something like this be possible

SomeObject like AcadDesignCenter dsObject

dsobject.SomeProperty  That lets me view the files at a location

.Something that lets me view the designCenter info associated with the dwt at said location

QNashJSRL8_0-1710959492229.png 

I want to be able to find the above info without strictly opening the said template.

 

0 Likes
Accepted solutions (1)
711 Views
3 Replies
Replies (3)
Message 2 of 4

norman.yuan
Mentor
Mentor

You can use ObjectDBX to read/open (in memory, not visually in AutoCAD editor) a drawing file (*.dwg, or *.dwt), and collect the information (layers, blocks, DimStyles...) that are available vis Design Center. 

 

Search this forum for "ObjectDBX" for code example of how to open drawing file with ObjectDBX.

 

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 4

QNashJSRL8
Contributor
Contributor

Thank you for pointing me into ObjectDbx.

doc = acadApp.GetInterfaceObject("ObjectDBX.AxDbDocument.24")
doc.Open(dbxFilePath)
For Each test As Object In doc.Layouts
            Dim name As String = test.Name
        Next

Just on some testing now, as of now I found that *.dwg will work and you can access the layouts, but when I use my *.dwt. I cannot access the layouts

doc.Layouts.count is 2
item(0) being Nothing

item(1) being the model space

 

I would expect it to also give me the other layout tabs, but it does not.

Here is some info I found about dwt issues
Insert Layout from various Templates (augi.com)

I am confident there is a work around to this, it wouldn't make sense to me that dwt info is limited.

If anyone knows anything about this let me know. I will post a solution if I find one.

0 Likes
Message 4 of 4

Ed__Jobe
Mentor
Mentor
Accepted solution

ObjectDbx STILL can't open a dwt. However, a template is just a dwg with a different extension. You can temporarily save the dwt as a dwg, open it, do your stuff, and then delete the temp file. I created a class that automatically handles this case in the xOpen method. The attached zip file is an updated version of the one I posted at AUGI.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature