I have a requirement such that I have to place two base views of assemblies(.iam) on a template file(.idw). The first assembly view should be on the top half and the other should be on the lower half of the template. I am able to place views but I am not sure how to get the center point of the template(.idw). I tried following the code given in
The code I am writing is
string pth = folderpath + "\\" +comboBox1.SelectedItem;
NameValueMap oMap = oApp.TransientObjects.CreateNameValueMap();
DrawingDocument oDrawDoc =(DrawingDocument)oApp.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject,pth);
oDrawDoc = (DrawingDocument)oApp.ActiveDocument;
Sheet oSheet = (Sheet)oDrawDoc.ActiveSheet;
Point2d oCenter = oApp.TransientGeometry.CreatePoint2d(10.0,10.0);
Point2d oPlacementPoint1 = oApp.TransientGeometry.CreatePoint2d(4.0,20.0);
Point2d oPlacementPoint2 = oApp.TransientGeometry.CreatePoint2d(oCenter.X, oCenter.Y);
ViewScale1 = 1.0;
ViewScale2 = 1.0;
ViewOrientationTypeEnum ViewOrientation1 = ViewOrientationTypeEnum.kLeftViewOrientation;
ViewOrientationTypeEnum ViewOrientation2 = ViewOrientationTypeEnum.kRightViewOrientation;
DrawingViewStyleEnum ViewStyle1 = DrawingViewStyleEnum.kHiddenLineDrawingViewStyle;
DrawingViewStyleEnum ViewStyle2 = DrawingViewStyleEnum.kShadedDrawingViewStyle;
AssemblyDocument oAssDoc =(AssemblyDocument)oApp.Documents.Open(textBox1.Text,false);
AssemblyDocument oAssDoc2 = (AssemblyDocument)oApp.Documents.Open(textBox2.Text, false);
DrawingView oView=oSheet.DrawingViews.AddBaseView((_Document)oAssDoc,oPlacementPoint1,ViewScale1,ViewOrientation1,ViewStyle1);
DrawingView oView2 = oSheet.DrawingViews.AddBaseView((_Document)oAssDoc2, oPlacementPoint2, ViewScale2, ViewOrientation2, ViewStyle2);
oAssDoc.Close();
oAssDoc2.Close();
The problem I am facing is on the line
It throws an exception cannot cast a _COM to Inventor.DrawingView. Any idea how to get the center points of the template??
Any help is appreciated. Thanks in advance