ILogic Automation code error

ILogic Automation code error

gereon.cramer
Explorer Explorer
562 Views
2 Replies
Message 1 of 3

ILogic Automation code error

gereon.cramer
Explorer
Explorer

Hello everyone,

I am relatively inexperienced in programming and have just tried to "automate" the creation of a railing and the updating of the production drawing based on a template using an iLogic code with the help of ChatGPT. However, I am now at the point where I still have three error messages that I just can't get rid of, and when ChatGPT tries to solve them, all the old errors come back again. Can you help me figure out if what I have in mind is even possible and where the mistake might be? I am attaching the code as a screenshot, and you can find the error messages directly below it. I would appreciate any feedback. Version: Inventor Professional 2026

Best regards

 

Error in line 17: 'FindOccurrenceRecursive' was not declared. Access may not be possible due to its protection level.
Error in line 38: 'FindOccurrenceRecursive' was not declared. Access may not be possible due to its protection level.
Error in line 74: The value of type 'ViewOrientationTypeEnum' cannot be converted to 'Point2d'.

0 Likes
563 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor

Hi @gereon.cramer.  It is very difficult to debug code by just an 'image' of it, especially when it is just an image of 'portions' of the code, rather than the whole thing.  When you need help with some code, it is always best to post the whole code, as selectable text.  There are two main ways to do that here.  The main (and most popular) way, is to use the forum reply tool that looks like this </>.  When you click that tool, it inserts a 'code window' into your post or reply, where you can 'paste' your code into.  When you do that, the code will maintain its formatting, making it easier to read through.  Then other users can easily select your code and copy it, so they can paste it into a new iLogic rule to test and debug.  The other popular option, is to copy & paste your whole code into a new Notepad file (text file) and save it, then attach that text file to your post/reply.  Then the rest of us can download your text file, open it, copy & paste it into a code window to test.  This is usually the best option when the code is really long, so it does not take up the whole screen in the forum discussion.

The first thing I saw that does not look right is the line of code starting with the following:

Dim oBOMView As BOMView = oSheet.BOMViews.Add(oSheet, oBaseView, kBOMType_PartsOnly,...

What were you trying to do there?  A BOMView is something that only exists within an Assembly, not within a Drawing.  It is not a type of drawing view.  It is one of the tabs within the assembly BOM dialog that presents that type of data in a specific way.  If we want to include a representation of an assembly BOM in a drawing, we do that through a PartsList.  Other than that, there was an excessive use of the following code phrase:

ThisApplication.ActiveDocument

Instead of using that in so many places, it usually only needs to be used once, then capture the value of that Property to a variable.  Then use that variable everywhere else in your code that needs to use that Inventor.Document object.  This is important not only for efficiency, but also because of Document Type.  The generic Inventor.Document Type does not have that many properties, because it is not specific enough.  If the active document is an assembly, then you should capture that as an Inventor.AssemblyDocument, which will have a whole lot more properties, and will work much better in places that need to access things that are unique to assemblies (not found in parts or drawings).  AI is just a tool to help, but does not replace the need to understand the code involved, for this reason and many other reasons.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

gereon.cramer
Explorer
Explorer

Hi,

 

@WCrihfield , thanks for your answer. I have attached my code as a text file.

What I tried to achieve with BOMView is to have a parts list displayed in the drawing.

Is there another possibility to use iLogic with a template where all the different views are already placed and it just updates them?

 

0 Likes