Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Headers in iLogic rules

tomislav.peran
Advocate

Headers in iLogic rules

tomislav.peran
Advocate
Advocate

Hello,

 

Does anybody use Headers in the rules? 

 

In one rule that I got on the forum following is inserted in the header: 

 

Imports System.Text.RegularExpressions

It is needed to add the "Regex" class to the code which has the function or property (not sure how to name it properly) to replace the existing name of the edge (named entity) with a new one.

 

oNow = oEdgePrefix & Now()
oEdgeName = Regex.Replace(oNow, "[:/ ]", String.Empty)

But can somebody explain to me the function of Headers in general or give me a link with an explanation? 

Why is needed to insert "System.Text.RegularExpressions" in the Header in the first place?

Do we add in this way extra classes in iLogic codes that originally do not exist in iLogic?

 

I hope my question makes sense, if anybody knows please let me know,

 

Tom

0 Likes
Reply
Accepted solutions (1)
523 Views
4 Replies
Replies (4)

CattabianiI
Collaborator
Collaborator
Accepted solution
It is needed to add the "Regex" class to the code which has the function or property (not sure how to name it properly) to replace

Function 😉

Why is needed to insert "System.Text.RegularExpressions" in the Header in the first place?

Because otherwise you had to specify the full namespace when you call the Replace function:

System.Text.RegularExpressions.Regex.Replace(oNow, "[:/ ]", String.Empty)

 

Do we add in this way extra classes in iLogic codes that originally do not exist in iLogic?

It's more like you're enabling the use of class contained in System.Text.RegularExpressions without having to specify the namespace.
Source: 
https://learn.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/imports-statemen...


To load dlls with other types you can use AddReference keyword.
Check this link: https://knowledge.autodesk.com/support/inventor/learn-explore/caas/CloudHelp/cloudhelp/2018/ENU/Inve...

 

0 Likes

tomislav.peran
Advocate
Advocate

Hey Cattabiani,

 

Oke. I think I understand now. So in this way, you save some space in the code since you do not have to type the whole statement.

 

Thanks for the links. I will check them out. 

 

Just one more question please.  

 

"To load dlls with other types you can use AddReference keyword." -> are those Projects created in the Visual Studio?

So you can via Header run such a code? 

 

Tom

 

 

 

 

 

 

0 Likes

CattabianiI
Collaborator
Collaborator

are those Projects created in the Visual Studio?
Check out the second link.
I suppose the dlls should be .NET assemblies.
It could be a third party dll, Microsoft dll, or a dll developed by you.

With addReference you load the dll then you can eventually import the type you want and the use it in your code.
You can also specify the full path to the dll.

tomislav.peran
Advocate
Advocate

Okey,

 

Thanks a lot for explanation 🙂

 

Tom

0 Likes