Inventor Customization

Reply
Valued Contributor
Posts: 51
Registered: ‎11-09-2009
Message 1 of 3 (219 Views)
Accepted Solution

VBA -> C#: Get me the scalestring!

219 Views, 2 Replies
08-09-2011 02:37 AM

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??

Employee
Posts: 308
Registered: ‎07-29-2008
Message 2 of 3 (207 Views)

Re: VBA -> C#: Get me the scalestring!

08-11-2011 04:08 AM 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

Valued Contributor
Posts: 51
Registered: ‎11-09-2009
Message 3 of 3 (204 Views)

Re: VBA -> C#: Get me the scalestring!

08-11-2011 04:56 AM in reply to: jeff.pek

Works like a charm! Thanks!

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube