Drawing Annotation - Ilogic to VBA

Drawing Annotation - Ilogic to VBA

gopinathmY575P
Advocate Advocate
329 Views
4 Replies
Message 1 of 5

Drawing Annotation - Ilogic to VBA

gopinathmY575P
Advocate
Advocate

Hello Team, 

 

I'm working on annotation, specifically outer dimensions of part through ilogic using below code: 

 

Dim genDims = Sheet_1.DrawingDimensions.GeneralDimensions

Dim back = VIEW2.GetIntent("back")

now i want to convert this line to vba., getintent() function is not directly available.

 

If you have any idea on how to convert this? help me with some snippets.

 

 

Thanks in advance.,,,,,,

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

WCrihfield
Mentor
Mentor

Hi @gopinathmY575P.  The code you are showing there is defined within the iLogic API only.  We can not use iLogic API code in VBA macros.  So, you will need to use the higher level Inventor API equivalent (Sheet.CreateGeometryIntent), which is initiated from the Inventor API Sheet object, instead of from an iLogic only IManagedDrawingView object (which loosely resembles/represents the Inventor API DrawingView object).  When using iLogic methods, you generally only need to provide Strings, which are the names of objects, but when using Inventor API methods, you generally always have to provide the actual objects themselves, not just the names of the objects.  This usually means needing to use a little more code also.  Since your code example is just a partial example, and we do not know anything about the geometries involved, it would be difficult to show a VBA equivalent.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 5

gopinathmY575P
Advocate
Advocate

Hi @WCrihfield thanks for the detailed explanations. Actually, part belongs to sheet metal environment with defined names for faces such as front, back, bottom, e.tcsheetmetal.jpg

0 Likes
Message 4 of 5

WCrihfield
Mentor
Mentor

First of all, I would like to ask why you want to transition your code from an iLogic rule, where this type of task is much simpler, to a VBA macro, where doing these things will be more complicated and will require a lot more code?  If the reason is just so you can run the code from a macro button in your ribbon, then I would suggest only using the VBA macro to run your iLogic rule, and leaving your iLogic rule alone.  But that's up to you.

 

I assume you are referring to the quoted word "back" in your original line of code, and that word being a name that you have assigned to a Face object in your sheet metal part model.  Once again, finding those 'named' entities is much simpler to do using iLogic API code, but is much more complex, and will require a lot more code to do in a VBA macro.  In order to specify that named face (the actual Face object, not just its name) in the Inventor API method I mentioned, you will need to find and get that named Face object first, so that you can supply that to the method.

In an iLogic rule, we could have used the following line of code to get that named Face in the part, from the drawing:

Dim oBackFace As Face = iLogicVb.Automation.GetNamedEntities(ThisDrawing.ModelDocument).TryGetEntity("back")

But since we can't use iLogic API code in a VBA macro, we will have to do it the older, and longer way.  First, you will need to get a reference to the 'model' document that the views in your drawing are referencing.  Then use its Document.AttributeManager property to get its actual AttributeManager object.  Then, use its AttributeManager.FindObjects method.

Something similar to this:

Dim oDrawingDoc As DrawingDocument
Set oDrawingDoc = ThisApplication.ActiveDocument
Dim oModelDoc As Document
Set oModelDoc = oDrawingDoc.ReferencedDocuments.Item(1)
Dim oFoundObjs As Inventor.ObjectCollection
Set oFoundObjs = oModelDoc.AttributeManager.FindObjects("iLogicEntityNameSet", "iLogicEntityName", "back")
Dim oBackFace As Face
Set oBackFace = oFoundObjs.Item(1)

Then you can provide that oBackFace variable to the Sheet.CreateGeometryIntent method.

 

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 5

gopinathmY575P
Advocate
Advocate

Debugging is easier in vba than ilogic. That is the reason I raised this request. Anyways thank you very much for your support @WCrihfield . Yes, i agree that, as we discussed this topic earlier in-detail in direct messages, it requires complex codes to create this requests.

0 Likes