D.S

adndevblog.typepad.com

Create Virtual Component by Code - Manufacturing DevBlog

Create Virtual Component by Code - Manufacturing DevBlog 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 « RangeBox includes WorkPlane, WorkAxis and Center of Gravity | Main | Synchronize Prompted Entry TextBox values » 04/18/2013 Create Virtual Component by Code By Xiaodong Liang The virtual component is defined by a VirtualComponentDefinition. Through the definition, you can also get the information of component settings. Sub VirtualC()     ' assume an assembly document is opened     Dim oAssDoc As AssemblyDocument     Set oAssDoc = ThisApplication.activeDocument     Dim oAssDef As AssemblyComponentDefinition     Set oAssDef = oAssDoc.ComponentDefinition     Dim oMatrix As matrix     Set oMatrix = ThisApplication.TransientGeometry.CreateMatrix     ' add one virtual occurrence     Dim oNewOcc As ComponentOccurrence     Set oNewOcc = oAssDef.Occurrences.AddVirtual("MyVirtual", oMatrix)     Dim oCVirtualCompDef As VirtualComponentDefinition     Set oCVirtualCompDef = oNewOcc.Definition     ' get BOMStructure     Debug.Print "BOMStructure of Virtual Component: " & oCVirtualCompDef.BOMStructure     Dim oQuantityType As BOMQuantityTypeEnum     Dim oBaseQuantity As Variant      ' get QuantityType and Evaluated Quantity     Call oCVirtualCompDef.BOMQuantity.GetBaseQuantity(oQuantityType, oBaseQuantity)     Dim oEvaluatedQuantityType As BOMQuantityTypeEnum      Debug.Print "QuantityType: " & oEvaluatedQuantityType     Dim oEvaluatedQuantity As Double     oEvaluatedQuantity = oCVirtualCompDef.BOMQuantity.GetEvaluatedBaseQuantity(oEvaluatedQuantityType)     Debug.Print "Quantity: " & oEvaluatedQuantity End Sub Posted at 02:08 AM in Inventor , Xiaodong Liang | Permalink | | | Comments Create Virtual Component by Code By Xiaodong Liang The virtual component is defined by a VirtualComponentDefinition. Through the definition, you can also get the information of component settings. Sub VirtualC()     ' assume an assembly document is opened     Dim oAssDoc As AssemblyDocument     Set oAssDoc = ThisApplication.activeDocument     Dim oAssDef As AssemblyComponentDefinition     Set oAssDef = oAssDoc.ComponentDefinition     Dim oMatrix As matrix     Set oMatrix = ThisApplication.TransientGeometry.CreateMatrix     ' add one virtual occurrence     Dim oNewOcc As ComponentOccurrence     Set oNewOcc = oAssDef.Occurrences.AddVirtual("MyVirtual", oMatrix)     Dim oCVirtualCompDef As VirtualComponentDefinition     Set oCVirtualCompDef = oNewOcc.Definition     ' get BOMStructure     Debug.Print "BOMStructure of Virtual Component: " & oCVirtualCompDef.BOMStructure     Dim oQuantityType As BOMQuantityTypeEnum     Dim oBaseQuantity As Variant      ' get QuantityType and Evaluated Quantity     Call oCVirtualCompDef.BOMQuantity.GetBaseQuantity(oQuantityType, oBaseQuantity)     Dim oEvaluatedQuantityType As BOMQuantityTypeEnum      Debug.Print "QuantityType: " & oEvaluatedQuantityType     Dim oEvaluatedQuantity As Double     oEvaluatedQuantity = oCVirtualCompDef.BOMQuantity.GetEvaluatedBaseQuantity(oEvaluatedQuantityType)     Debug.Print "Quantity: " & oEvaluatedQuantity End Sub View the entire comment thread. Please enable JavaScript if you would like to comment on this blog. Search Submit Mfg DevBloggers Adam Nagy Augusto Goncalves Balaji Ramamoorthy Daniel Du Philippe Leefsma Vladimir Ananyev Wayne Brill Xiaodong Liang November 2016 Sun Mon Tue Wed Thu Fri Sat     1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30       Autodesk Blogs ADN DevBlog - AEC Our DevBlog for Revit, Navisworks, AEC and BIM technology APIs. ADN DevBlog - AutoCAD Our DevBlog for AutoCAD and other platform technology APIs. ADN DevBlog - Cloud and Mobile Our DevBlog for Cloud and Mobile technologies. ADN DevBlog - Infrastructure Modeling Our DevBlog for Infrastructure Modeling technology APIs. ADN DevBlog - Manufacturing Our DevBlog for Design, Lifecycle and Simulation technologies. Around the Corner Cyrille Fauvel's Maya platform developer blog - Autodesk Media and Entertainment technology. Civilized Development Isaac Rodriguez's AutoCAD Civil 3D developer blog Dances with Elephants Jim Quanci's blog on partnering with large companies. It's All Just Ones and Zeros Doug Redmond's Vault developer blog Mod the Machine Brian Ekins' and Adam Nagy's Inventor developer blog The 360 View Mikako Harada's BIM 360 developer blog The 3D Web Coder Jeremy Tammik's web and mobile programming blog The Building Coder Jeremy Tammik's Revit developer blog Through the Interface Kean Walmsley's AutoCAD developer blog Yet more on autodesk.com ... Central blog list on autodesk.com Share Recent Posts iLogic: ActiveDocument.ComponentDefinition throws exception for specific document Fusion API: Usage of Table Control Introduction to Fusion 360 API Create Sketch Text on Face of Assembly Fusion API: Usage of Mouse Event