iLogic is a foreign language to me

iLogic is a foreign language to me

BK-MTFNE
Advocate Advocate
739 Views
4 Replies
Message 1 of 5

iLogic is a foreign language to me

BK-MTFNE
Advocate
Advocate

I don't know if this is the forum to put this in but hopefully someone can help.

 

I know nothing about coding, programing, VBA or any of those things. I am trying to learn but there doesnt seem to be any lessons I can find that actually explains these things. Sure I can search for iLogics and hope there is one for what I am trying to accomplish but usually there is not. I have tried to take something similar to what I need and change it to what I need it to do but honestly its the same as trying to fix gramatical errors in a paper written in a language I don't know. Every tutorial out there either assumes some sort of "programming" knowledge or its for something simple like adding a form to prompt what color to put in the parameters, nothing explaining stuff like what "As String" or "Dim" or "If...Then...End" or any of the other "Keywords" actually means and does. Everyone has to start somewhere and if anyone out there can point me in the right direction I would appreciate it.

0 Likes
740 Views
4 Replies
Replies (4)
Message 2 of 5

Frederick_Law
Mentor
Mentor

Look for VB, VB.NET and VBA course.

iLogic assume user has basic programming knowledge.

0 Likes
Message 3 of 5

A.Acheson
Mentor
Mentor

Hi @BK-MTFNE 

 

You are not alone in your thoughts many users start of in the same way wanting to automate there tasks but not having any knowledge of code languages and principles. I was one of those people back in 2019 starting off with having  iproperties in excel and not wanting to copy and paste each cell into a document. Really the best way to start is to copy and paste a piece of code and just see what it does. It gets harder when you want to customize the code to your needs. 

 

To start with the iLogic rule editor or integrated Development Environment (IDE) is the built in tool for writing code within inventor. Small snippets of code are available on the browser of the editor and these are code written for the iLogic API. The iLogic rule editor also allows you to run another language called VB.NET and this is used to code using the Inventor API. You can switch between the iLogic API and Inventor API in the same rule and in fact lots of  forum rules take advantage of that fact. 

 

The difference between the methods and language can be seen below.

 

iLogic API to add and read an iproperty called part number.

 

partNo = iProperties.Value("Project",Part Number")
MessageBox.Show("Part Number",partNo ) 

 

 

 

VB.NET Language and Inventor API to read an iproperty called part number.

 

Sub Main
    GetPropertySample()
End Sub
Sub GetPropertySample()
    ' Get the active document.
    Dim invDoc As Document = ThisApplication.ActiveDocument
    
    ' Get the design tracking property set.
    Dim invDesignInfo As PropertySet = invDoc.PropertySets.Item("Design Tracking Properties")
    
    ' Get the part number property.
    Dim invPartNumberProperty As [Property] = invDesignInfo.Item("Part Number")
    
    MsgBox ("Part Number: " & invPartNumberProperty.value)
End Sub

 

VBA Language and Inventor API to read an iproperty called part number.

 

Public Sub GetPropertySample()
    ' Get the active document.
    Dim invDoc As Document
    Set invDoc = ThisApplication.ActiveDocument
    
    ' Get the design tracking property set.
    Dim invDesignInfo As PropertySet
    Set invDesignInfo = invDoc.PropertySets.Item("Design Tracking Properties")
    
    ' Get the part number property.
    Dim invPartNumberProperty As Property
    Set invPartNumberProperty = invDesignInfo.Item("Part Number")
    
    MsgBox "Part Number: " & invPartNumberProperty.value
End Sub

 

The User Manual for the API link here will give you a good background as to how to begin using the Inventor API. Note that a wealth of samples exist but most are written in VBA language so you will need to convert to VB.NET to be able to use the ilogic editor. For the most part this is removing the word "SET" and driving the sub routine from Sub Main or inserting the code directly with no sub routines. The User Manual for the iLogic API link here in my opinion is not as easy to understand from the instructions and very few samples exist as you would write it in the code editor so it is more of a reference document for more experienced use.

AAcheson_0-1687112543637.png

This forum is likely the best place for learning specific coding within inventor but I would certainly use any source that helps you in your specific learning styles like you tube videos and written literature. 

Some specific blogs are 

https://modthemachine.typepad.com/my_weblog/2013/02/inventor-api-training-lesson-1.html

https://adndevblog.typepad.com/files/cp2544_ilogic_inventor_api.pdf 

https://adndevblog.typepad.com/manufacturing/2018/04/accessing-iproperties-through-ilogic-code.html

 

For coding/programming  related questions like what is Dim or how to use If Then End If statements I would usually do an internet search of a similar language on stack overflow forum like excel VBA and then transcribe the methods over. See video here of declaring string, integer, boolean etc. Or you can also use official sources like Microsoft Help Files-Variable Declaration

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 4 of 5

Michael.Navara
Advisor
Advisor

Another useful source is here. It is an intro to VB.NET how it works in general. It is not focused on using Inventor API or iLogic, but it can help you to understand how the pure VB.NET works

https://www.tutorialspoint.com/vb.net/index.htm

 

0 Likes
Message 5 of 5

quockhanhmech
Explorer
Explorer

You can use chat GPT or Bing Search to create the functions you want and you can learn from this. 

0 Likes