如何拆分IDW模板,以便可以在其上放置两个视图 [英] How do I split an IDW template such that two vies can be placed on it
问题描述
我有一个要求,我必须在模板文件(.idw)上放置程序集(.iam)的两个基本视图。第一个装配视图应位于上半部分,另一个应位于模板的下半部分。我能够放置视图,但我不知道如何获得模板的中心点(.idw)。我尝试按照 中给出的代码进行操作。 >
我写的代码是
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;
//DrawingView dv = default(DrawingView);
//dv = (DrawingView)oSheet.DrawingViews;
Point2d oCenter = oApp.TransientGeometry.CreatePoint2d(10.0,10.0);
//Point2d oCenter = (Point2d)dv.Center;
//Point2d oPlacementPoint1 = oApp.TransientGeometry.CreatePoint2d(oCenter.X - 1, oCenter.Y);
//Point2d oPlacementPoint2 = oApp.TransientGeometry.CreatePoint2d(oCenter.X + 1, oCenter.Y);
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
//DrawingView dv = default(DrawingView);
//dv = (DrawingView)oSheet.DrawingViews;
抛出异常无法将_COM强制转换为Inventor.DrawingView。知道如何获得模板的中心点吗?
任何帮助表示赞赏。在此先感谢
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
推荐答案
这篇关于如何拆分IDW模板,以便可以在其上放置两个视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!