11-23-2018
09:37 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
11-23-2018
09:37 PM
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