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: 

Retrieve dimension does not work

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
Anonymous
817 Views, 7 Replies

Retrieve dimension does not work

I need to retrieve specific dimensions using GeneralDimensions.Retrieve function.

But when collection of specific object of dimensions is sent as variable in the function, it retrieves all the dimensions between any two specific dimensions.

 

For e.g If dimension[1] and dimension[10] is to be retrieved and an object collection of these two dimension is sent as variable, the function retrieves dimensions from dimension[1] to dimension[10].

 

Does anyone have any solution to it?

Thanks in advance

 

 

 

                ObjectCollection retrievableDimensions = activeSheet.DrawingDimensions.GeneralDimensions.GetRetrievableDimensions(targetView);
ObjectCollection Finaldimensions = activeSheet.DrawingDimensions.GeneralDimensions.GetRetrievableDimensions(targetView);
                Finaldimensions.Clear();
                Finaldimensions.Add(retrievableDimensions[1]);
                Finaldimensions.Add(retrievableDimensions[10]);
                retirevedDiemsions = activeSheet.DrawingDimensions.GeneralDimensions.Retrieve(targetView,Finaldimensions);
7 REPLIES 7
Message 2 of 8
YuhanZhang
in reply to: Anonymous

Can you attach the data(don't attach confidential data) to reproduce the problem?



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 3 of 8
Anonymous
in reply to: YuhanZhang

@YuhanZhang thank you for your response

You can use any part model with drawing to test just use the below code and You will get set of dimensions in drawing instead of just the two dimensions which was specified in dimensions object collection

ObjectCollection retrievableDimensions = activeSheet.DrawingDimensions.GeneralDimensions.GetRetrievableDimensions(Viewobject);
// to get all the retreivable dimensions
                ObjectCollection Finaldimensions = activeSheet.DrawingDimensions.GeneralDimensions.GetRetrievableDimensions(Viewobject);
                Finaldimensions.Clear();
                Finaldimensions.Add(retrievableDimensions[1]);
                Finaldimensions.Add(retrievableDimensions[10]);
// here we add two specific dimensions in the object collection that is to be retrieved.
                retirevedDiemsions = activeSheet.DrawingDimensions.GeneralDimensions.Retrieve(Viewobject,Finaldimensions);
// here the dimensions are retrieved

Awaiting your reply.

Thank you

Message 4 of 8
YuhanZhang
in reply to: Anonymous

I tested with the code already and can't reproduce the problem, so it is better you provide a data(don't send us confidential data) that can reproduce the problem for us or capture a video for us to know where the problem happens.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 5 of 8
Anonymous
in reply to: YuhanZhang

You can find Test models and drawings attached for testing purpose.

First test was to retrieve first and last dimension of first occurencein an assembly which worked fine

Second test includes retreival of first dimensions of both the occurence which in result retrieved all the dimensions of first occurence and first dimension of second occurence.

 

test1_code.pngtest1_result.JPGtest2_code.pngtest2_result.JPG

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//using InvConnectLib;
using Mapper;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using Inventor;
using System.Runtime.InteropServices;

namespace TestingInvLib
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Inventor.Application Iapp = Marshal.GetActiveObject("Inventor.Application") as Inventor.Application;

                String filePath = @"D:\Forum\assembly_drawing.idw";

                //Test 1 is for retreiving first and last dimension of first occurance in that view1
                Test1(Iapp,filePath);

                //Test 2 is for retreiving first dimension of first occurance and first dimension of second occurance in that view1
                Test2(Iapp, filePath);

            }
            catch (Exception ex) { Console.WriteLine(ex.Message);Console.WriteLine(ex.Source);Console.ReadLine(); }
        }

        private static void Test1(Inventor.Application Iapp, String filePath)
        {
            DrawingDocument drawing = Iapp.Documents.Open(filePath) as DrawingDocument;
            Sheet activeSheet = (Sheet)drawing.ActiveSheet;
            DrawingView targetView = activeSheet.DrawingViews[1]; //the first view named VIEW1

            ObjectCollection retrievableDimen = activeSheet.DrawingDimensions.GeneralDimensions.GetRetrievableDimensions(targetView);

            ObjectCollection diminsionToRetrieve = Iapp.TransientObjects.CreateObjectCollection();
            diminsionToRetrieve.Add(retrievableDimen[1]);
            diminsionToRetrieve.Add(retrievableDimen[6]);

            GeneralDimensionsEnumerator retirevedDiemsions = 
                activeSheet.DrawingDimensions.GeneralDimensions.Retrieve(targetView, diminsionToRetrieve);

            int retrieveCount = retirevedDiemsions.Count;
        }

        private static void Test2(Inventor.Application Iapp, String filePath)
        {
            DrawingDocument drawing = Iapp.Documents.Open(filePath) as DrawingDocument;
            Sheet activeSheet = (Sheet)drawing.ActiveSheet;
            DrawingView targetView = activeSheet.DrawingViews[1]; //the first view named VIEW1

            ObjectCollection retrievableDimen = activeSheet.DrawingDimensions.GeneralDimensions.GetRetrievableDimensions(targetView);

            ObjectCollection diminsionToRetrieve = Iapp.TransientObjects.CreateObjectCollection();
            diminsionToRetrieve.Add(retrievableDimen[1]);
            diminsionToRetrieve.Add(retrievableDimen[7]);

            GeneralDimensionsEnumerator retirevedDiemsions =
                activeSheet.DrawingDimensions.GeneralDimensions.Retrieve(targetView, diminsionToRetrieve);

            int retrieveCount = retirevedDiemsions.Count;
        }
    }
}

 Awaiting your reply.

Thank you

Message 6 of 8
YuhanZhang
in reply to: Anonymous

Hi, I tested your code with your data in Inventor 2017.4, 2018.2 and 2019 and can't reproduce the problem at all. I see your data was saved in "2017 (Build 210142000, 142)" , can you update your product to latest Inventor 2017 version to see if the problem is solved there? You can find the updates from your Autodesk accounts:

 

https://manage.autodesk.com

 

Please let me if you update to Inventor 2017.4 if the problem still exists?



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 7 of 8
Anonymous
in reply to: YuhanZhang

@YuhanZhang Yes updating it to latest version solved the issue.

Thanks a lot!!!

Message 8 of 8
Anonymous
in reply to: YuhanZhang

@YuhanZhang Yes updating it to latest version solved the issue.

Thanks a lot!!1

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

Post to forums  

Autodesk Design & Make Report