D.S

adndevblog.typepad.com

Manufacturing DevBlog: November 2013

Manufacturing DevBlog: November 2013 Manufacturing DevBlog The resource for software developers working with Design, Lifecycle and Simulation technologies from Autodesk. Home Subscribe Follow Useful Links Autodesk About this Blog « October 2013 | Main | December 2013 » November 2013 11/15/2013 Disable BOMs of a 3D-model in a DWF By Xiaodong Liang Question: I'm writing a small tool for Inventor 2012 in VB.net, using the TranslatorAddIn, to export a drawing and its 3D-model to DWF. Unfortunately, when I export the drawing of an assembly, the BOM of the model is included as well, wich I would like to disable. The options "BOM_Structured" and "BOM_Parts_Only" seem to work only if I export the 3D-model, not the drawing... Solution: There is not such option for the DWF translator currently. The workaround is to disable the top assembly’s BOMs temporarily before exporting the drawing to DWF in this case. The following is a VBA demo. It disables the BOM view of all assemblies in the drawing before exporting to DWF, and restore after exporting.   Public Sub PublishDWFWithoutBOM()     ' Get the DWF translator Add-In.     Dim DWFAddIn As TranslatorAddIn     Set DWFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD95-2F4D-42CE-8BE0-8AEA580399E4}")     'Set a reference to the active document (the document to be published).     Dim oDocument As DrawingDocument     Set oDocument = ThisApplication.ActiveDocument         'disables the BOM view of all assemblies in the drawing before exporting to DWF     Dim oEachRefDoc As Document     For Each oEachRefDoc In oDocument.ReferencedDocuments         If TypeOf oEachRefDoc Is AssemblyDocument Then             Dim oAssDoc As AssemblyDocument             Set oAssDoc = oEachRefDoc                         Dim oBOM As BOM             Set oBOM = oAssDoc.ComponentDefinition.BOM                         oBOM.StructuredViewEnabled = False             oBOM.StructuredViewFirstLevelOnly = False             oBOM.PartsOnlyViewEnabled = False                         oAssDoc.Save                     End If             Next        oDocument.Update            Dim oContext As TranslationContext     Set oContext = ThisApplication.TransientObjects.CreateTranslationContext     oContext.Type = kFileBrowseIOMechanism     ' Create a NameValueMap object     Dim oOptions As NameValueMap     Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap     ' Create a DataMedium object     Dim oDataMedium As DataMedium     Set oDataMedium = ThisApplication.TransientObjects.CreateDataMedium     ' Check whether the translator has 'SaveCopyAs' options     If DWFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then         oOptions.Value("Launch_Viewer") = 1               If TypeOf oDocument Is DrawingDocument Then             ' Drawing options             oOptions.Value("Publish_Mode") = kCustomDWFPublish             oOptions.Value("Publish_All_Sheets") = 0             ' The specified sheets will be ignored if             ' the option "Publish_All_Sheets" is True (1)             Dim oSheets As NameValueMap             Set oSheets = ThisApplication.TransientObjects.CreateNameValueMap             ' Publish the first sheet AND its 3D model             Dim oSheet1Options As NameValueMap             Set oSheet1Options = ThisApplication.TransientObjects.CreateNameValueMap             oSheet1Options.Add "Name", "Sheet:1"             oSheet1Options.Add "3DModel", True             oSheets.Value("Sheet1") = oSheet1Options         End If     End If     'Set the destination file name     oDataMedium.FileName = "c:\temp\temptest.dwf"     'Publish document.     Call DWFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)         'restore after exporting      For Each oEachRefDoc In oDocument.ReferencedDocuments         If TypeOf oEachRefDoc Is AssemblyDocument Then             Set oAssDoc = oEachRefDoc                           Set oBOM = oAssDoc.ComponentDefinition.BOM                         oBOM.StructuredViewEnabled = True             oBOM.StructuredViewFirstLevelOnly = True             oBOM.PartsOnlyViewEnabled = True                          oAssDoc.Save                     End If             Next     End Sub Posted at 07:33 AM in Inventor , Xiaodong Liang | Permalink | Comments (0) | | | 11/07/2013 Create title border in AutoCAD Mechanical By  Adam Nagy There is a comprehensive .NET sample using the AutoCAD Mechanical COM API in the SDK under "acadmapi\sample\dotNet" called "netTitleBorder":  http://usa.autodesk.com/adsk/servlet/index?id=14952981&siteID=123112 Here is also a simpler VBA code that shows how the relevant API works: Public Sub CreateTitleBorder() ' Requires a reference to: ' - Autodesk SymBBAuto Type Library ' - Autodesk AutoCAD Mechanical Type Library 'Get Application Object Dim oApp As AcadmApplication Set oApp = ThisDrawing.Application.GetInterfaceObject( _ "AcadmAuto.AcadmApplication") 'Reference to the Symbol Manager Dim symMgr As McadSymbolBBMgr Set symMgr = ThisDrawin