
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
This is my first Macro. This Macro creates several parts and then assembles them in an assembly. It then exports a BOM. Until here everything works. I am having problems creating a drawing with a base view of the assembly. There is something basic that I am missing. Please see the code below.
Private Sub UserButtonz1_Click()
'
Create parts
'
Save parts
'
(opens assy)
Dim oDoc2 As AssemblyDocument
Set oDoc2 = ThisApplication.Documents.Add(kAssemblyDocumentObject, ThisApplication.FileManager.GetTemplateFile(kAssemblyDocumentObject))
'
(Saves assy)
Call oDoc2.SaveAs("C:\Documents and Settings\fu0328\Desktop\C\" & TextBox4 & ".iam", True)
'
Creates export BOM
'
(saves BOM)
oPartsOnlyBOMView.Export "C:\Documents and Settings\fu0328\Desktop\C\" & TextBox4 & ".xls", kMicrosoftExcelFormat
'
(Creates Drawing)
Dim oPartDoc As DrawingDocument
Set oPartDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, ThisApplication.FileManager.GetTemplateFile(kDrawingDocumentObject))
Dim oSheet As Sheet
Set oSheet = oPartDoc.ActiveSheet
Dim oPnt As Point2d
Set oPnt = ThisApplication.TransientGeometry.CreatePoint2d(10, 10)
Dim scaleFactor As Double
scaleFactor = 4#
Dim oBaseView As DrawingView
(This is where the error occures. I think the problem is at "oDoc2")
Set oBaseView = oSheet.DrawingViews.AddBaseView(oDoc2, oPnt, scaleFactor, kFrontViewOrientation, kHiddenLineDrawingViewStyle)
End Sub
Thank you for your time
WGM
Solved! Go to Solution.