- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all
I have an Inventor ilogic problem I hope someone could help with.
I have a part that has a form to change the height, depth & length and a set of ilogic rules that also change the flange sizes and hole sizes and pitches within this flange.
What I need to do now is attach a drawing to this that will automatically generate to suit the sizes inputted into the form.
I admit that I am very new to ilogic code but is this possible using ilogic rules? The code seems very complicated and in depth for my level of knowledge.
What code would attach a drawing to a part and allow it to generate a drawing with two views with dimensions?
Thank you for any advice.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi! I believe this is doable. I have seen customer examples doing exactly like what you want. Could you share an example here? We have quite a few iLogic experts who can show you how to do that. Without an example, it is very hard to find a solution.
Many thanks!

Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi Johnson, thank you for your reply.
Below is a screenshot of the part I am working with, it's a very simple part. The form has the 3 variables and a set of illogic rules changes the flange sizes, corner holes position and central holes pitches to suit sizes (50mm increments).
I've decided to split this down into workable sections of code, as below:-
1. Code to attach the correct drawing to the part.
2. Code to set up the views (a view on flange holes & a view on side)
3. Code to attach dimensions to these views.
I have managed to add the first rule to attach the drawing to the part, which seems to work with one error which I'm not sure how to fix?:-
Error in rule: Rule22, in document: Silencer.ipt
Public member 'Add' on type 'Application' not found.
The code I've done is here:-
Imports Inventor.ViewOrientationTypeEnumImportsInventor.DrawingViewStyleEnum
Dim oDrawingDoc As DrawingDocument
Dim oPartDoc As Document
Dim oSheet As Sheet
Dim oTG As TransientGeometry
Dim oView1 As DrawingView
Dim oView2 As DrawingView
Dim oView3 As DrawingView
Dim oView4 As DrawingView
ViewScale=3/16
'Ask to create drawing?
dwgQuery=MsgBox("Would you like to Create a drawing for this MODEL?", vbYesNo,"Drawing Selection")
If dwgQuery=vbYes
ThenoPartDoc=ThisDoc.Document
'Define IDW Template File Location
oDrawingDoc=ThisApplication.Add.kDrawingDocument("C:\VaultWorkingFolder\Designs\Templates\SilencerAssembly.idw", True)
oSheet=oDrawingDoc.Sheets.Item(1)
'Define 2d view bottom left corner points for four views
oPoint1=ThisApplication.TransientGeometry.CreatePoint2d(1, 1)
oPoint2=ThisApplication.TransientGeometry.CreatePoint2d(1, 6)
oPoint3=ThisApplication.TransientGeometry.CreatePoint2d(5, 1)
oBaseView=oSheet.DrawingViews.AddBaseView(oPartDoc,oPoint1, 3/16,kFrontViewOrientation, kHiddenLineDrawingViewStyle)
', KTANGENTEDGESON)
oView2=oSheet.DrawingView.AddProjectedView(oBaseView,oPoint2, kHiddenLineDrawingViewStyle, 3/16)
oView3=oSheet.DrawingView.AddProjectedView(oBaseView,oPoint3, kHiddenLineDrawingViewStyle, 3/16)
End If
If I can fix this error that will be task 1 done. I'm really not sure about the others yet though!!
Thank you for your help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Step 1 to automatically generate a drawing is working with this code:-
'Ask to create drawing?
dwgQuery=MsgBox("Would you like to Create a drawing for this MODEL?", vbYesNo,"Drawing Selection")
If dwgQuery=vbYes
ThenoPartDoc=ThisDoc.Document
'Define IDW Template File Location
ThisDoc.Launch("C:\VaultWorkingFolder\Designs\Templates\Silencer Drawing.idw")
End If
The next step is to automatically generate a front and side view on that drawing. Can anyone help?
Even just one view would do the trick!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all
I am not having much luck in working out the correct illogic code to add views to an automatically generated drawing sheet. I only really need to add a base view and a projected view with width, height, depth and length dimensions fixed to them.
Does anyone have any ideas that may help?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi! Let me ping @Sergio.D.Suárez. He is very active on the forum and he knows iLogic very well.
Hi Sergio,
Do you have an example showing the Drawing automation workflow?
Many thanks!

Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, This code could be useful to you, at least it does not throw me errors. I retouch it a bit to simplify it.
Dim templateFile As String 'Create a drawing from the drawing template templateFile = "C:\VaultWorkingFolder\Designs\Templates\SilencerAssembly.idw" '''Place the path of your template idw Dim ViewScale As Double = 3 / 16 dwgQuery = MsgBox("Would you like to Create a drawing for this MODEL?", vbYesNo, "Drawing Selection") If dwgQuery=vbYes Dim oDoc As Document = ThisDoc.Document ' Part Document or Assembly Document Dim oDrawingDoc As DrawingDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject,templateFile,True) oDrawingDoc.Activate() Dim oSheet As Sheet = oDrawingDoc.Sheets.Item(1) Dim oPoint1 As Point2d=ThisApplication.TransientGeometry.CreatePoint2d(1, 1) Dim oPoint2 As Point2d=ThisApplication.TransientGeometry.CreatePoint2d(1, 6) Dim oPoint3 As Point2d=ThisApplication.TransientGeometry.CreatePoint2d(5, 1) Dim oBaseView As DrawingView =oSheet.DrawingViews.AddBaseView(oDoc,oPoint1,ViewScale,ViewOrientationTypeEnum.kFrontViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle) Dim oView2 As DrawingView =oSheet.DrawingViews.AddProjectedView(oBaseView,oPoint2, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle,ViewScale) Dim oView3 As DrawingView =oSheet.DrawingViews.AddProjectedView(oBaseView,oPoint3, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle,ViewScale) End If
The idea that you propose is good, you could load all these fragments as subroutines sub - end sub and command them from a main sub main.
That's why I'll add a code below to place dimensions in the drawing views.
Sub main() Dim oDoc As Document = ThisDoc.Document If oDoc.DocumentType = Inventor.DocumentTypeEnum.kDrawingDocumentObject Then Dim oSheet As Sheet oSheet = oDoc.ActiveSheet Dim oViews As DrawingViews Dim oView As DrawingView Line1 : oView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select view") If oView Is Nothing Then Exit Sub Dim oGeneralDimensionsEnum As GeneralDimensionsEnumerator oGeneralDimensionsEnum = oSheet.DrawingDimensions.GeneralDimensions.Retrieve(oView) GoTo Line1 centrar_Cotas Else MessageBox.Show("Please, open a drawing file", "Retrieve dimensions") End If End Sub Sub centrar_Cotas Dim oDoc As DrawingDocument = ThisDoc.Document ' Set a reference to the active sheet Dim oSheet As Sheet = oDoc.ActiveSheet ' Iterate over all dimensions in the drawing and ' center them if they are linear or angular. For Each oDrawingDim As DrawingDimension In oSheet.DrawingDimensions If TypeOf oDrawingDim Is LinearGeneralDimension Or _ TypeOf oDrawingDim Is AngularGeneralDimension Then Call oDrawingDim.CenterText End If Next End Sub
This is a difficult issue, what this code does is to retrieve the dimensions of the drawing, something very useful when the workflow is directed thinking about how the part will be represented in a drawing.
With the code you select the views of the sheet where you need to retrieve the dimensions
I hope some of this help. regards
Please accept as solution and give likes if applicable.
I am attaching my Upwork profile for specific queries.
Sergio Daniel Suarez
Mechanical Designer
| Upwork Profile | LinkedIn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi Sergio
I've not had chance to try this yet but just wanted to thank you for your help.
I will let you know how it goes when I get around to giving it a try but wanted to let you know that your help is appreciated.
I'll keep you posted.
Thanks