Anonymous
247 Views, 1 Reply
06-21-2019
01:14 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
06-21-2019
01:14 AM
Create part subassembly
I want to create a new part in the active subassembly? This is the code i have so far:
Dim oDoc As Document oDoc = ThisApplication.ActiveEditDocument If oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then Dim oNewPart As PartDocument 'set to millimeter oNewPart = ThisApplication.Documents.Add(kPartDocumentObject,ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject) , False) oNewPart.UnitsOfMeasure.LengthUnits =UnitsTypeEnum.kMillimeterLengthUnits Dim oNewPartDef As PartComponentDefinition oNewPartDef = oNewPart.ComponentDefinition Dim oMartrix As Matrix oMatrix = ThisApplication.TransientGeometry.CreateMatrix() Call oMatrix.SetTranslation(ThisApplication.TransientGeometry.CreateVector(0,0,0)) 'add the new part to the assembly Dim oNewOcc As ComponentOccurrence oNewOcc = oDoc.ComponentDefinition.Occurrences.AddByComponentDefinition(oNewPartDef,oMatrix) oNewOcc.Edit End If