How to create a drawing using iLogic (simple instructions)

How to create a drawing using iLogic (simple instructions)

Paul.Bennett3YZEV
Explorer Explorer
10,423 Views
10 Replies
Message 1 of 11

How to create a drawing using iLogic (simple instructions)

Paul.Bennett3YZEV
Explorer
Explorer

I have been searching around for a tutorial that identifies all the steps for automating a drawing file using iLogic and I can't seem to find anything,  what I do find is information that is steps ahead but doesn't start from the very beginning. I understand it is a complex topic but I am looking for a tutorial that identifies and explains all the steps. 

 

If anyone can provide some information(video, PDF, ...etc) on

- Creating a drawing from an .ipt

- Place a few views in the .idw

 

I have no coding experience and have tried messing around with iLogic on my own but I am struggling.

I am running Inventor 2019.

 

Any help would be very much appreciated. 

0 Likes
Accepted solutions (1)
10,424 Views
10 Replies
Replies (10)
Message 2 of 11

Sergio.D.Suárez
Mentor
Mentor

Hi, this is an example in ilogic.
It can be executed in a part or assembly file.
"oSep" is the separation between views.
It is an example, a more complex code can be made as more functions are added, but it can serve as a starting point for learning.

Dim oDoc As Document = ThisDoc.Document  ' Part Document or Assembly Document

Dim oSep As Double = 2

'Create a drawing from the drawing template
Dim oFileDlg As Inventor.FileDialog = Nothing
ThisApplication.CreateFileDialog(oFileDlg)
oFileDlg.Filter =  "Inventor Files (*.idw)|*.idw"
oFileDlg.DialogTitle = "Select Drawing Template"
oFileDlg.InitialDirectory = ThisApplication.FileOptions.TemplatesPath
oFileDlg.CancelError = True
On Error Resume Next
oFileDlg.ShowOpen()
If Err.Number <> 0 Then
	Exit Sub
ElseIf oFileDlg.FileName <> "" Then
MasterFile = oFileDlg.FileName
End If

Dim oDrawingDoc As DrawingDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject,templateFile,True)

oDrawingDoc.Activate()
Dim oSheet As Sheet = oDrawingDoc.Sheets.Item(1)

Dim oCentralPoint As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(oSheet.Width/2, oSheet.Height/2)

Dim oView As DrawingView
oView = oSheet.DrawingViews.AddBaseView(oDoc,oCentralPoint, 1, ViewOrientationTypeEnum.kBottomViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle)

Dim V1Point2D As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(oView.Center.X + 10, oView.Center.Y)
Dim V2Point2D As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(oView.Center.X, oView.Center.Y - 10)
Dim V3Point2D As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(oView.Center.X + 10, oView.Center.Y - 10)

Dim oView1 As DrawingView = oSheet.DrawingViews.AddProjectedView(oView, V1Point2D, DrawingViewStyleEnum.kFromBaseDrawingViewStyle)
Dim oView2 As DrawingView = oSheet.DrawingViews.AddProjectedView(oView, V2Point2D, DrawingViewStyleEnum.kFromBaseDrawingViewStyle)
Dim oView3 As DrawingView = oSheet.DrawingViews.AddProjectedView(oView, V3Point2D, DrawingViewStyleEnum.kFromBaseDrawingViewStyle)

oView1.Position= ThisApplication.TransientGeometry.CreatePoint2d(oView.Center.X + oView.Width / 2 + oSep + oView1.Width / 2, oView1.Center.Y)
oView2.Position = ThisApplication.TransientGeometry.CreatePoint2d(oView.Center.X, oView.Center.Y - oView.Height / 2 - oSep - oView2.Height / 2)

oView3.Position = ThisApplication.TransientGeometry.CreatePoint2d(oView.Center.X + oView.Width / 2 + oSep + oView3.Width / 2, _
oView.Center.Y - oView.Height / 2 - oSep - oView3.Height / 2)
oView3.ViewStyle = oView.ViewStyle 

I hope this can be useful. Cheers!


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

Message 3 of 11

Paul.Bennett3YZEV
Explorer
Explorer

Thank you for the reply Sergio.

 

I appreciate you providing that code but I am looking for information that would go through each line and break down what it is and why it is used. Everything I have found skips this portion and assume the user understands this already, this is what I am struggling with as I do not have a coding background.

 

I have been trying to teach myself but i am struggling with the language.

 

Again, any basic/beginner information or direction on this would be of great help.

 

0 Likes
Message 4 of 11

Sergio.D.Suárez
Mentor
Mentor
Accepted solution

There are no "simple" instructions for what you just asked. In fact it is one of the things that are often asked, and I tried to create a code as simple as possible to achieve that and shared it.
Why are there no simple instructions? because the ilogic language is based on object language based on VB.net, and each object that provides each given access must be identified.
Ilogic has "shortcuts" of the accesses to access certain properties of a file, but not all the properties and all the different and complex accesses have ilogic shortcuts.
I think you should familiarize yourself with the inventor API, it's a lot of material, but even today I consult it daily.

1.jpg

The question you should have asked would be:
How to learn programming? or where to consult bibliography to learn programming in inventor?

Check any material related to programming in VBA, ilogic, VB.net, there is a lot of material on the internet.
Place doubts about codes you experience in the customization threads


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

Message 5 of 11

Paul.Bennett3YZEV
Explorer
Explorer

Thank you again for your reply.

 

Indeed, it does appear to be not as "simple" as I was hoping but it couldn't hurt to ask the community, maybe there was something out there I hadn't found.

 

I will continue to familiarize myself with the API, it's tough but I'll work on it.

 

I appreciate your time Sergio. Thank you.

0 Likes
Message 6 of 11

Sergio.D.Suárez
Mentor
Mentor

In the case of the previous code, you first identify the active document

 

Dim oDoc As Document = ThisDoc.Document ' Part Document or Assembly Document

 

Now you define the separation between the views

 

Dim oSep As Double = 2

 

Now you need to open the dialog box to select a drawing template, look in the template path, look at the detail in red

'Create a drawing from the drawing template
Dim oFileDlg As Inventor.FileDialog = Nothing
ThisApplication.CreateFileDialog(oFileDlg)
oFileDlg.Filter = "Inventor Files (*.idw)|*.idw"
oFileDlg.DialogTitle = "Select Drawing Template"
oFileDlg.InitialDirectory = ThisApplication.FileOptions.TemplatesPath
oFileDlg.CancelError = True
On Error Resume Next
oFileDlg.ShowOpen()

 

If there is an error or you do not select anything, leave the code without returning an error box


If Err.Number <> 0 Then
Exit Sub
ElseIf oFileDlg.FileName <> "" Then
MasterFile = oFileDlg.FileName
End If

 

Now you will create a new drawing file from the selected template

 

Dim oDrawingDoc As DrawingDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject,templateFile,True)

 

Now activate the drawing

 

oDrawingDoc.Activate()
Dim oSheet As Sheet = oDrawingDoc.Sheets.Item(1)

 

Now take the center point of the sheet

 

Dim oCentralPoint As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(oSheet.Width/2, oSheet.Height/2)

 

Now place the base view at the center point of the sheet

 

Dim oView As DrawingView
oView = oSheet.DrawingViews.AddBaseView(oDoc,oCentralPoint, 1, ViewOrientationTypeEnum.kBottomViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle)

 

Create projected views in arbitrary locations

 

Dim V1Point2D As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(oView.Center.X + 10, oView.Center.Y)
Dim V2Point2D As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(oView.Center.X, oView.Center.Y - 10)
Dim V3Point2D As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(oView.Center.X + 10, oView.Center.Y - 10)

Dim oView1 As DrawingView = oSheet.DrawingViews.AddProjectedView(oView, V1Point2D, DrawingViewStyleEnum.kFromBaseDrawingViewStyle)
Dim oView2 As DrawingView = oSheet.DrawingViews.AddProjectedView(oView, V2Point2D, DrawingViewStyleEnum.kFromBaseDrawingViewStyle)
Dim oView3 As DrawingView = oSheet.DrawingViews.AddProjectedView(oView, V3Point2D, DrawingViewStyleEnum.kFromBaseDrawingViewStyle)

 

Correct the positions of the views according to the separation entered and depending on the width and length of each view

 

 

oView1.Position= ThisApplication.TransientGeometry.CreatePoint2d(oView.Center.X + oView.Width / 2 + oSep + oView1.Width / 2, oView1.Center.Y)
oView2.Position = ThisApplication.TransientGeometry.CreatePoint2d(oView.Center.X, oView.Center.Y - oView.Height / 2 - oSep - oView2.Height / 2)

oView3.Position = ThisApplication.TransientGeometry.CreatePoint2d(oView.Center.X + oView.Width / 2 + oSep + oView3.Width / 2, _
oView.Center.Y - oView.Height / 2 - oSep - oView3.Height / 2)
oView3.ViewStyle = oView.ViewStyle


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

Message 7 of 11

mcgyvr
Consultant
Consultant

There are a few AU classes/demos like this about the topic..

https://www.autodesk.com/autodesk-university/class/Taking-It-Next-Level-Drawing-Automation-Inventor-...

 

A google search of "Inventor Drawing Automation ilogic" yielded quite a few links to relevant training information.. Enough to keep you busy for hours and hours..



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
0 Likes
Message 8 of 11

Sergio.D.Suárez
Mentor
Mentor

These are places that I consult a lot and are very good, I hope they can serve you

 

https://modthemachine.typepad.com/

 

http://inventortrenches.blogspot.com/

 

Here a pdf that seems interesting, I have not studied it yet

 

https://forums.autodesk.com/autodesk/attachments/autodesk/120/66335/1/SIDB9F74F1CA9F56A74E367EA6688F...

 

 

 

 

 


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

Message 9 of 11

Anonymous
Not applicable

Are these code working? I tried it with Inventor 2020, it only run up to "Select Drawing Template". I selected a template nothing happend when I click OK.

Message 10 of 11

prudhvi_galiFSSED
Participant
Participant
Same problem for me. Nothing happens after clicking OK.
Message 11 of 11

CaWa_TB
Explorer
Explorer

Same problem. Any solutions?

0 Likes