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

iLogic - Need to get ThisDoc.Document throught the API

Anonymous

iLogic - Need to get ThisDoc.Document throught the API

Anonymous
Not applicable

Hi All, 

 

I wrote my own RunRule for iLogic through the Inventor API (I have my reasons), and I am having a hell of a time keeping track of the document in which the rule is currently running in. Looking through the ilogic API there is an Interface called Autodesk.iLogic.Interfaces.ICadDoc which has the member Document (exactly what I need), but I can't figure out how I can get this object through the API to save my life. Any help would be highly appreciated. Answers in any (Computer) language are welcome.

 

Nik

0 Likes
Reply
1,012 Views
5 Replies
Replies (5)

MechMachineMan
Advisor
Advisor

I often use

 

Dim oDoc As Document

oDoc = ThisApplication.ActiveDocument

 

 

If you will be running a rule in a part that's activated from within an assembly file, you should also perform a check on the ActivatedObject/ActiveEditDocument to ensure that the rule is pulling the PART as the oDoc, since calling ActiveDocument will grab the ASSEMBLY.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes

Anonymous
Not applicable

Thanks for the reply Justin, but this solution doesn't quite work for me. I have a routine (written with the API as a dll) that is run from the main assembly. This routine will call iLogic rules from every part and subassembly, and those rules may call other rules and so on. Unfortunatelly, Active document always points to the main assembly, and ActivatedObject/ActiveEditDocument only works if edits are happening. Often times, It will run a rule in a part that only reads data, thus can't use either of those members for my application. For the time being I keep track of ThisDoc by carefully maintaining a global variable within my code. What I am doing is working just fine, but it's very difficult to keep everything straight in my head. Getting iLogic's ThisDoc member would be ideal for me.

0 Likes

shiftctrl.io
Enthusiast
Enthusiast

Did you ever find a solution to your problem?

0 Likes

Anonymous
Not applicable

Unfortunately no.  I ended up writing code that keep track of my version of ThisDoc. Not saying it's not possible, but I wasn't able to find anything I could use from the API.

 

It was a bit confusing to do, but it's now been working flawlessly for years. Good luck!

0 Likes

shiftctrl.io
Enthusiast
Enthusiast

I imported the Autodesk.ilogic.Interfaces  DLL as a reference in Visual Studio and am able to get the ICadDoc interface but not sure how to initialize a document to be the equivalent of "ThisDoc"

 

At any rate thanks for the quick response. 

 

If anyone else has had any luck with this - a solution would be appreciated. 

 

 

0 Likes