Community
Navisworks API
Welcome to Autodeskā€™s Navisworks API Forums. Share your knowledge, ask questions, and explore popular Navisworks API topics.
cancel
Showing results forĀ 
ShowĀ Ā onlyĀ  | Search instead forĀ 
Did you mean:Ā 

AutoCAD Drawing Database

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
tim-bot
3159 Views, 11 Replies

AutoCAD Drawing Database

i'm wanting to load up a drawing database in navis to look at its xrefs and load only the xrefs that are attached (not overlayed) since navis doesn't do this properly. i found (by referencing the acdbmgd.dll in lcdbx2014) if i try to create a database immediatly it crashes navis. if, however, i load a drawing file into the viewer and then create a database everything goes good, i'm able to load up the drawing. my question is, how can i open a drawing database right off the bat? thanks!

11 REPLIES 11
Message 2 of 12
tim-bot
in reply to: tim-bot

Also, I can't seem to start a transaction so I can grab the blocktablerecord. I also tried to bypass that using the open and close technique to no avail. thanks!
Message 3 of 12
xiaodong_liang
in reply to: tim-bot

Hi,

I am struggling to understand the scenario. It sounds you read a database of the AutoCAD DWG in a Navisworks plugin. But if there is no any document loaded in Navisworks, the plugin will crash.

I am not sure if Navisworks plugin supports to work with AutoCAD API together, but have you debugged to check when there is no document loaded, whether your code tries to get the active document (Navisworks document) ? If so, the crash is not strange.

Or, could you isolate and provide a small project sample?
Message 4 of 12
tim-bot
in reply to: xiaodong_liang

<Autodesk.Navisworks.Api.Plugins.Plugin("BaseCrashCase", "RKMI")>
Public Class BasicCrashCase
    Inherits Autodesk.Navisworks.Api.Plugins.AddInPlugin

    Public Overrides Function Execute(ParamArray parameters() As String) As Integer
        MsgBox("Creating Database")
        Using AcDB As New Autodesk.AutoCAD.DatabaseServices.Database ' Crashes here if no drawings have been loaded into the session since the program opened
            MsgBox("Loading Database")
            AcDB.ReadDwgFile("D:\Test.dwg", Autodesk.AutoCAD.DatabaseServices.FileOpenMode.OpenForReadAndAllShare, False, "")
            MsgBox("Starting Transaction")
            Using AcTrans As Autodesk.AutoCAD.DatabaseServices.Transaction = AcDB.TransactionManager.StartTransaction ' Crashes here if a drawing has previously been loaded into the session
                MsgBox("Getting Block Table")
                Dim BT As Autodesk.AutoCAD.DatabaseServices.BlockTable = AcTrans.GetObject(AcDB.BlockTableId, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead)
                MsgBox("Getting Modelspace")
                Dim MS As Autodesk.AutoCAD.DatabaseServices.BlockTableRecord = AcTrans.GetObject(BT(Autodesk.AutoCAD.DatabaseServices.BlockTableRecord.ModelSpace), Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead)
                MsgBox("Finished!")
            End Using
        End Using
        Return 0
    End Function

End Class

 

 

 you'll have to change the path to a valid dwg path there. i've noted where it's actually crashing durring different situations. really i'm trying to overcome a shortfall of navisworks inability to exclude overlaid xrefs. what i'm actually attempting to do is programatically build a file tree of a dwg file correctly loading in only attached xrefs. wasn't sure if it was possible, just hoping that it was since it's become a necessity going forward for us.

 

i've attached a blank drawing to use for testing, but it could be any drawing.

Message 5 of 12
xiaodong_liang
in reply to: tim-bot

Hi,

 

Firstly, the acdbmgd.dll is a kind of assembly used for an AutoCAD.NET plugin. It cannot run out of AutoCAD. So it is not strange it crashed in Navisworks.

 

You may be wondering why it looks working if a DWG has been opened in Navisworks. Note: only DWG. I guess, the reason may probably because Navisworks would build a tiny environment of AutoCAD, in order to interop with some features of DWG. This is just my guess, though. So, I believe the code happens to work if a DWG is opened already, but it is NOT our support scenario if using AutoCAD.NET out of AutoCAD. Sorry for this.

 

If your machine installs AutoCAD as well, you could

-        Either, by COM API , start an instance of AutoCAD behind and operate the DWGs there, and shut down the instance when it is not needed.

-        Or, by AutoCAD core console, to work with the DWG. That would be more efficient.

http://through-the-interface.typepad.com/through_the_interface/2012/02/the-autocad-2013-core-console...

Message 6 of 12
tim-bot
in reply to: xiaodong_liang

i thought that might be the situation, just hoped that there may be a chance. thank you for your help on this.

perhaps you could pass the need for the option to exclude overlaid xrefs on to the naviswork developers?

 

a little more background:

i think in-house i could certainly accompolish this using the core console of autocad, but we have a number of external people we work with that potentially wouldn't have autocad installed but still need to load our drawings into navisworks. our goal here is to have a single source of information in our drawings. we batch out various areas of our designs into smaller drawings after they've been laid out. currently we have to have 2 seperate drawings that have to be changed just because navisworks brings in both overlaid and attached xrefs. that's causeing us a number of issues, so we want to be able to attach the batch drawings, but leave the rest of the xrefs as overlay's (things like reference backgrounds, or other building levels that are just for connecting to). i guess we'll have to figure something else out.

Message 7 of 12
xiaodong_liang
in reply to: tim-bot

Hi,

if you could provide the necessary test file (DWG), or some steps how to produce the issue ( load only the xrefs that are attached (not overlayed) ), I can log a wish to ask for the option.
I roughly understand the steps, but I'd prefer to using your test data, in case I missed something.
Message 8 of 12
tim-bot
in reply to: xiaodong_liang

here you go, extract these drawings, then open the Main Drawing.dwg. there's 2 xrefs in there named how they're referenced, you should see both the Attach.dwg and Overlay.dwg in navis. If you open the Nested Main.dwg file, you will see that it brings in the Main Drawing.dwg and only the Attach.dwg that's attached to it. the prefered result would be to have the Main Drawing.dwg only bring the Attach.dwg when it's loaded, and complely skip the Overlay.dwg. Perhaps an option in the dwg file reader for this functionality, but this is how autocad works, the overlays are in there as reference for drawing, but never intended to be associated with the drawing outside of the autocad editor, whereas Attachments are inteded to be permanantly associated with the drawing no matter where it's referenced. thanks!

Message 9 of 12
xiaodong_liang
in reply to: tim-bot

Hi,

 

Thanks for the dataset.

 

I need to reproduce before logging the issue. Whe I opened Nested Main.dwg, the selection tree is as below. It looks to me it does NOT enclose the overlaid drawing. While you said:

 

the prefered result would be to have the Main Drawing.dwg only bring the Attach.dwg when it's loaded, and complely skip the Overlay.dwg.

 

Could you highlight with some snapshots to help me understand?

 

 

ADNTest.jpg

Message 10 of 12
tim-bot
in reply to: xiaodong_liang

yes, that is (sort of) the desired behavior. but if you open the Main Drawing.dwg by itself (instead of nested in another drawing) you will see the real issue, it brings along the overlaid xref. it would be more common to be attaching the drawing directly than to have it nested in a blank drawing first.

Main Drawing

originally i included the Nested Main.dwg just to show what we want it to do. typically we have hundreds of design drawings for a building the mostly have overlaid xrefs in them that we wouldn't want included in navisworks when the drawing is referenced in. but there's a few xrefs nested in some drawing types that need to be referenced in. but we can't include any at all at the moment since we would get huge numbers of overlaid references that we don't need to follow along.

 

Message 11 of 12
xiaodong_liang
in reply to: tim-bot

Hi,

I logged a wish # NW-47890 with our engineer team.
Message 12 of 12
tim-bot
in reply to: xiaodong_liang

excellent, thank you very much!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report