Message 1 of 13
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
Its that time again when I get to a point with my macro (VBA) and cannot seem to figure out what I am doing wrong.
The following routine is run from an IDW with a base drawing view.
I am trying to automate the placement of the associated flat pattern
1) Open open the part
2) Delete if present and then generate the flat pattern
3) Place the flat pattern at the correct scale on the sheet at an arbitraty position
My code is as follows but it fails on the final call to place the view with 'Object doesn't support property or method'
Public Sub test() ' trying to place flat pattern from base drawing view
Dim oPartDoc As PartDocument
Dim oDwgDoc As DrawingDocument
Set oDwgDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
Set oSheet = oDwgDoc.ActiveSheet 'On Error Resume Next 'GoTo err:
Dim oDrawingView As DrawingView
Set oDrawingView = oSheet.DrawingViews(1)
Dim oViewScale As Double
Set oViewScale = oDrawingView.Scale
Debug.Print oViewScale
Set oPartDoc = oSheet.DrawingViews(1).ReferencedDocumentDescriptor.ReferencedDocument
Debug.Print oPartDoc.FullFilename
ThisApplication.Documents.Open (oPartDoc.FullFilename)
Dim oCompDef As SheetMetalComponentDefinition
Set oCompDef = oPartDoc.ComponentDefinition
oPartDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"
If oCompDef.HasFlatPattern Then
oCompDef.FlatPattern.Delete
Else
oCompDef.Unfold
oCompDef.FlatPattern.ExitEdit
End If
'oPartDoc.Close
Dim oOptions As NameValueMap
Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap
Call oOptions.Add("SheetMetalFoldedModel", False)
Dim oFlatPatternPoint As Point2d
Set oFlatPatternPoint = ThisApplication.TransientGeometry.CreatePoint2d(50, 50)
oDwgDoc.Activate
Dim oFlatPatternView As DrawingView
Set oFlatPatternView = oSheet.oDrawingViews.AddBaseView(oPartDoc, oFlatPatternPoint, 0.125, kDefaultViewOrientation, _
kHiddenLineRemovedDrawingViewStyle, , , oOptions)
End Sub
Anybody solved this problem before?
Regards
Mark
Solved! Go to Solution.