Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

VBA -> C#: Get me the scalestring!

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
bjr001
536 Views, 2 Replies

VBA -> C#: Get me the scalestring!

I don't get it why it doesn't work ..

 

In VBA I have the following code that works fine:

    Dim oDoc As DrawingDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oSheet As DrawingViews
    Set oSheet = oDoc.ActiveSheet.DrawingViews
    
    Dim oCount As DrawingViews
    Set oCount = oSheet

    Dim oItem As DrawingView
    Set oItem = oSheet.Item(1)
    
    MsgBox ("Scale: " & oItem.ScaleString)

 

Trying this in C# (connecting with VS and also have a reference to "Autodesk.Inventor.Interop.dll"), I get stuck at the point where I want the "Item(1)". The Object Drawing View doesn't know any "Item". Looking in the object catalog there is only a "this[int]" between Count an Type. I guess the "this[int]"-stuff is what I'm looking for, but I don't have any idea how to handle with this.

 

Does anyone of you guys have an idea??

2 REPLIES 2
Message 2 of 3
jeff.pek
in reply to: bjr001

Hi -

 

You're on the right track. In C#, you use list[index] instead of list.Item(index).

 

So, for your case, it would be something like:

 

DrawingDocument oDoc = inventorApplication.ActiveDocument as DrawingDocument;

DrawingView firstView = oDoc.ActiveSheet.DrawingViews[1];

 

Note that indexing is still 1-based, and not 0-based.

 

Jeff

Message 3 of 3
bjr001
in reply to: jeff.pek

Works like a charm! Thanks!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report