Access IManagedDrawingView from External Rule

Access IManagedDrawingView from External Rule

jhomerWAP8S
Explorer Explorer
293 Views
5 Replies
Message 1 of 6

Access IManagedDrawingView from External Rule

jhomerWAP8S
Explorer
Explorer

Hello!

I am trying to automate some design tasks and would like to create a series of drawings from a rule run from an assembly document. I would like to access the IManagedDrawingView of each drawing I create, in order to run GetIntent from each view. Is there any way to access this without using ThisDrawing?

Thanks

0 Likes
Accepted solutions (1)
294 Views
5 Replies
Replies (5)
Message 2 of 6

WCrihfield
Mentor
Mentor
Accepted solution

Hi @jhomerWAP8S.  Most of those iLogic shortcut snippets seem to have been designed primarily for use in internal iLogic rules, instead of external ones, but there is almost always a way to do the same thing using normal Inventor API code.  It usually requires a bit more code, and possibly more complication to go the API route, but sometimes it can seem more clear.  If you feel you must stick with the iLogic snippets though, there is another fairly recent tool you might find useful, to help clear up the whole document reference question.  It became available in 2021 version of Inventor I believe.  It is an "iStandardObjectProvider" and it is created using the "StandardObjectFactory.Create()" method, where you input the Document object that you want it to reference, then you can start many of the most common iLogic shortcut snippets from that object reference that it creates.  Below is a quickie example:

oDoc = ThisDoc.Document
SOP = StandardObjectFactory.Create(oDoc)
oManagedDView = SOP.ThisDrawing.Sheet("SheetName").View("ViewName")

The first line is just a basic example to get a Document object, but you can get the Document object any way you feel is the most accurate in the situation.  The term 'ThisDoc' is not super well documented, but can be used to point to different documents in different situations.  The other most common term 'ThisApplication.ActiveDocument' can seem pretty clear, but there are a few situations where using that may not be pointing to the Document you are expecting also.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 6

JBerns
Advisor
Advisor

@WCrihfield,

 

Is 'StandardObjectFactory.Create' similar to 'iLogicVb.CreateObjectProvider" ?

 

iLogicVb.CreateObjectProvider(ThisDoc.Document)

I have seen examples from @ryan.rittenhouse that used the latter. Just trying to determine the benefit of each.

 

Regards,

Jerry

-----------------------------------------------------------------------------------------
CAD Administrator
Using AutoCAD & Inventor 2025
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes
Message 4 of 6

ryan.rittenhouse
Advocate
Advocate

As far as I know, they are interchangeable and return an identical result.

If this solved your problem, or answered your question, please click Accept Solution.
0 Likes
Message 5 of 6

WCrihfield
Mentor
Mentor

As far as I know, they both work exactly the same.

The 'iLogicVb' object (ILowLevelSupport Interface) is one of the 'Rule Objects' listed at the following Inventor iLogic API online help page:

Rule Objects 

The iLogicVb and InventorVb rule objects both represent the same exact thing, and are essentially just Class level variables that get declared and defined within our iLogic rules, in the other portion of the Public Partial Class named 'ThisRule', which we usually do not see.  When we look at the 'Temp' file that gets created in the background when we run iLogic rules, there are hints to that Class and other things that the iLogic add-in does for us automaticaly, as a helper.  But the full rule with both sections included can be seen at the source, within a Document level Attribute value.  And the StandardObjectFactory is a Class instead of an Interface (Autodesk.iLogic.Interfaces.StandardObjectFactory) which is also defined within the Autodesk.iLogic.Interfaces Namespace that Implements the IStandardObjectProvider Interface, which is also defined within the Autodesk.iLogic.Interfaces Namespace.  This object seems to be either already 'initialized' or its method is Shared, or something like that, because we never need to create an instance of that Class before we can use it to call that method from.  So both routes get us to the same result, but just start from different beginnings.  When I first started creating external iLogic rules that I intended to for referencing with the 'AddVbFile' line in the header of other rules, I first considered 'passing' that StandardObjectFactory object to that external resource, because it seemed to already exist, and had that Create method for accessing all those other iLogic tools.  But it is a bit more limited in it reach, when compared to the 'iLogicVb' rule object which is at a lower level, and has access to more iLogic resources.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 6 of 6

JBerns
Advisor
Advisor

Thank you, @ryan.rittenhouse and @WCrihfield.

I appreciate the quick replies and detailed explanation. 

 

From an assembly, I run an external rule to:

  • create a drawing from a template (working)
  • place views (working)
  • add parts list (working)
  • add center marks and centerlines
  • add dimensions
  • add balloons using Named Entities
  • add sketched symbols using Named Entities (working)

As you can imagine, without accessing the correct document level and IManaged info, I was struggling to create annotations.

 

As always, much appreciated.

 

Regards,

Jerry

-----------------------------------------------------------------------------------------
CAD Administrator
Using AutoCAD & Inventor 2025
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes