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);
Solved! Go to Solution.
Solved by YuhanZhang. Go to Solution.
Can you attach the data(don't attach confidential data) to reproduce the problem?
@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
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.
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.
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
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:
Please let me if you update to Inventor 2017.4 if the problem still exists?
@YuhanZhang Yes updating it to latest version solved the issue.
Thanks a lot!!!
@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.