12-14-2021
05:21 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
12-14-2021
05:21 PM
Here is a post to a simple drawing creation. I would suggest just run it on a part file first as its own rule. Then you can try integrate into your own rule when your happy it works.
https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/ilogic-create-drawing-from-part/td-p/10...
Imports System.IO
Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveDocument
Try 'to open the drawing
ThisApplication.Documents.Open _
(ThisDoc.PathAndFileName(True).Replace("ipt", "idw"))
Return 'exit rule
Catch
End Try
'since nothing found create it...
oNewDrawing = ThisDoc.ChangeExtension(".idw")
oTemplateFolder = ThisApplication.FileOptions.TemplatesPath
Dim oList As New ArrayList
Dim Folder As New IO.DirectoryInfo(oTemplateFolder)
For Each File As IO.FileInfo In Folder.GetFiles("*.idw", IO.SearchOption.AllDirectories)
Dim sName As New FileInfo(File.Name)
oList.Add(sName.Name)
Next
oTemplate = InputListBox("Select a template", oList, oList(0),"iLogic", "List")
oTemplate = oTemplateFolder & oTemplate
Dim oDrawingDoc As DrawingDocument
oDrawingDoc = ThisApplication.Documents.Add _
(DocumentTypeEnum.kDrawingDocumentObject, oTemplate, True)
oDrawingDoc.Activate()
Dim oSheet As Sheet
oSheet = oDrawingDoc.Sheets.Item(1)
Dim oPoint As Point2d
oPoint = ThisApplication.TransientGeometry.CreatePoint2d(10, 10)
Dim oView As DrawingView
oView = oSheet.DrawingViews.AddBaseView(oDoc, oPoint, 1, _
ViewOrientationTypeEnum.kFrontViewOrientation, _
DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle)
oDrawingDoc.SaveAs(oNewDrawing, False)
MessageBox.Show("This new file saved as: "& oNewDrawing, "iLogic")
If this solved a problem, please click (accept) as solution.
Or if this helped you, please, click (like)
Regards
Alan
Or if this helped you, please, click (like)
Regards
Alan