Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to run a rule that:
1) Checks if a Drawing file doesn't already exist
2) Creates a drawing file from a specified template
3) Places the front view of the current part in the center of the drawing
4) Saves this new drawing in the specified path
I would like this to happen all in the background, the end goal is to make the template part file have this script and automatically run it on each save using event triggers. This is my current code:
Sub Main() oFileName = ThisDoc.Path & "\Drawing Files\" & ThisDoc.FileName & ".dwg" If (System.IO.File.Exists(oFileName)) Then Exit Sub End If Template = ThisDoc.Path & "\.Resources\Templates\Sheet Metal Drawing.dwg" 'Dim oDrawingDoc As Document= ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, Template, False) Dim oDrawingDoc As Document= ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject) Dim oSheet As Sheet = oDrawingDoc.Sheets.Item(1) Dim oCenter As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(oSheet.Width / 2, oSheet.Height / 2) oSheet.DrawingViews.AddBaseView(ThisDoc.Document, oCenter, 1, kFrontViewOrientation, kHiddenLineRemovedDrawingViewStyle, "Front") oDrawingDoc.SaveAs(oFileName, True) End Sub
My code most works, only when I open the drawing file, the formatting seems wrong. the page border is missing and the background is black as if I saved a .dxf instead. Is there an alternate or correct way to save this drawing file?
Solved! Go to Solution.