public Inventor.Camera GetDocument(ref Inventor._Document Document, ref Inventor.Application invApplication) { Inventor.PartDocument PartDocument = null; Inventor.Camera Camera = null; mInvApplication = invApplication; if (Document.DocumentType == Inventor.DocumentTypeEnum.kPartDocumentObject) { PartDocument = (Inventor.PartDocument)Document; if (PartDocument != null) { if (PartDocument.ComponentDefinitions.Count > 0) { Camera = mInvApplication.ActiveView.Camera; Inventor.PartComponentDefinition PartComponentDefinition = PartDocument.ComponentDefinitions[1]; foreach (Inventor.SurfaceBody SurfaceBody in PartComponentDefinition.SurfaceBodies) { GetFaceToView(SurfaceBody, ref PartDocument, ref Camera); } return(Camera); } } } return(Camera); }
private void SetViewDirection(Inventor.Face FaceView) { Inventor.Camera Camera = mInvApplication.ActiveView.Camera; Inventor.Point Pnt; Inventor.View PlaneView = mInvApplication.ActiveView; // ' Set Eye or Target if (FaceView.IsParamReversed) { Pnt = Camera.Eye.Copy(); Pnt.TranslateBy(GetMidPointAtFaceNormal(ref FaceView).AsVector()); Camera.Target = Pnt; } else { Pnt = Camera.Target.Copy(); Pnt.TranslateBy(GetMidPointAtFaceNormal(ref FaceView).AsVector()); Camera.Eye = Pnt; } Camera.UpVector = GetLargestEdgeUnitVector(ref FaceView); Camera.Fit(); Camera.Apply(); PlaneView.SetCurrentAsTop(); PlaneView.SetCurrentAsHome(true); PlaneView.Update(); }
private void Changeview() { Inventor.Camera Camera = InvApp.ActiveView.Camera; Camera.Fit(); Camera.Apply(); }
private void DrawDocument(Inventor._Document Document, string TypeOfPart) { Inventor.ViewOrientationTypeEnum Orientation = Inventor.ViewOrientationTypeEnum.kDefaultViewOrientation; Inventor.DrawingDocument DrawingDocument; Inventor.Sheet Sheet; Inventor.DrawingView DrawingView; Inventor.TransientGeometry oTG = mInvApplication.TransientGeometry; CreateDrawingDocument(out DrawingDocument, out Sheet); //Inventor.DrawingStandardStyle DrawingStandardStyle; //DrawingStandardStyle = DrawingDocument.StylesManager.ActiveStandardStyle; if (TypeOfPart == "SheetMetal") { Inventor.NameValueMap BaseViewOptions = (Inventor.NameValueMap)mInvApplication.TransientObjects.CreateNameValueMap(); BaseViewOptions.Add("SheetMetalFoldedModel", false); DrawingView = AddDocumentBaseView(Document, Sheet, oTG, BaseViewOptions); } else if (TypeOfPart == "Plate") { CDrawingView CView = new CDrawingView(); Inventor.Camera Camera = null; Camera = CView.GetDocument(ref Document, ref mInvApplication); DrawingView = AddDocumentBaseView(Document, Sheet, oTG, Camera); } else { ViewOrientation(ref Orientation); DrawingView = AddDocumentBaseView(Document, Sheet, oTG, Orientation); } try { Inventor.DrawingCurve SelectedCurve = null; foreach (Inventor.DrawingCurve CurveLine in DrawingView.get_DrawingCurves(null)) { //Skip Circles if (CurveLine.StartPoint != null && CurveLine.EndPoint != null) { if (WithinTol(CurveLine.StartPoint.Y, CurveLine.EndPoint.Y, 0.001)) { if (SelectedCurve == null) { //This is the first horizontal curve found. SelectedCurve = CurveLine; } else { //Check to see if this curve is higher (smaller x value) than the current selected if (CurveLine.MidPoint.Y < SelectedCurve.MidPoint.X) { SelectedCurve = CurveLine; } } } } } //Create geometry intents point for the curve. Inventor.GeometryIntent oGeomIntent1 = Sheet.CreateGeometryIntent(SelectedCurve, Inventor.PointIntentEnum.kStartPointIntent); Inventor.GeometryIntent oGeomIntent2 = Sheet.CreateGeometryIntent(SelectedCurve, Inventor.PointIntentEnum.kEndPointIntent); Inventor.Point2d oDimPos = oTG.CreatePoint2d(SelectedCurve.MidPoint.X - 2, SelectedCurve.MidPoint.Y); Inventor.GeneralDimensions oGeneralDimensions = Sheet.DrawingDimensions.GeneralDimensions; Inventor.LinearGeneralDimension oLinearDim; oLinearDim = oGeneralDimensions.AddLinear(oDimPos, oGeomIntent1, oGeomIntent2, Inventor.DimensionTypeEnum.kAlignedDimensionType, true); } catch (Exception) { } mInvApplication.SilentOperation = true; string partURL = Document.FullFileName; int NameLength = Document.FullFileName.Length; string partURLTrimed = partURL.Remove(NameLength - 4); //DrawingDocument.Save(); DrawingDocument.SaveAs(partURLTrimed + ".idw", false); DrawingDocument.Close(true); Document.Close(false); mInvApplication.SilentOperation = false; //Sheet.RevisionTables.Add(oTG.CreatePoint2d(Sheet.Width, Sheet.Height)); //1mm div 10//1 row = 4 //Inventor.DimensionStyle dimstyle = DrawingDocument.StylesManager.DimensionStyles[cmbDimStyles.Text]; //Inventor.Layer layer = DrawingDocument.StylesManager.Layers[cmbLayers.Text]; }
private static Inventor.DrawingView AddDocumentBaseView(Inventor._Document Document, Inventor.Sheet Sheet, Inventor.TransientGeometry TransientGeometry, Inventor.Camera Camera) { double ViewWidth = 17; Inventor.DrawingView DrawingView = Sheet.DrawingViews.AddBaseView(Document as Inventor._Document, GetDrawingCenterPoint(Sheet, TransientGeometry), 0.2, Inventor.ViewOrientationTypeEnum.kArbitraryViewOrientation, Inventor.DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle, "", Camera, null); DrawingView.Scale = ViewWidth / DrawingView.Width * DrawingView.Scale; SetViewScale(Sheet, ref DrawingView); return(DrawingView); }
private void SetDrawingView(Inventor.SurfaceBody mSurfaceBody, ref Inventor.Camera Camera, Inventor.Face TargetFace) { if (TargetFace != null) { if (!TargetFace.IsParamReversed) { if (TargetFace.Geometry is Inventor.Plane) { //Inventor.Face TargetFace = Face; Inventor.Point FacePoint = TargetFace.PointOnFace; Inventor.UnitVector Normal = GetFaceNormal(ref TargetFace, ref FacePoint); Inventor.UnitVector UplDirection = mInvApplication.TransientGeometry.CreateUnitVector(0, 1, 0); Inventor.UnitVector Z_PosDirection = mInvApplication.TransientGeometry.CreateUnitVector(0, 0, 1); Inventor.UnitVector Z_NegDirection = mInvApplication.TransientGeometry.CreateUnitVector(0, 0, -1); Inventor.UnitVector X_PosDirection = mInvApplication.TransientGeometry.CreateUnitVector(1, 0, 0); Inventor.UnitVector Y_PosDirection = mInvApplication.TransientGeometry.CreateUnitVector(0, 1, 0); Inventor.UnitVector X_NegDirection = mInvApplication.TransientGeometry.CreateUnitVector(-1, 0, 0); Inventor.UnitVector Y_NegDirection = mInvApplication.TransientGeometry.CreateUnitVector(0, -1, 0); if (Z_PosDirection.IsEqualTo(Normal)) { if (GetExtents(mSurfaceBody) == "X") { UplDirection = Y_NegDirection; } else if (GetExtents(mSurfaceBody) == "Y") { UplDirection = X_NegDirection; } else if (GetExtents(mSurfaceBody) == "Z") { UplDirection = GetXDir(ref TargetFace, ref FacePoint); } FacePoint = Camera.Eye.Copy(); FacePoint.TranslateBy(GetMidPointAtFaceNormal(ref TargetFace).AsVector()); Camera.Target = FacePoint; Camera.UpVector = UplDirection; Camera.Fit(); Camera.Apply(); } else if (Z_NegDirection.IsEqualTo(Normal)) { if (GetExtents(mSurfaceBody) == "X") { UplDirection = Y_PosDirection; } else if (GetExtents(mSurfaceBody) == "Y") { UplDirection = X_PosDirection; } else if (GetExtents(mSurfaceBody) == "Z") { UplDirection = GetXDir(ref TargetFace, ref FacePoint); } FacePoint = Camera.Eye.Copy(); FacePoint.TranslateBy(GetMidPointAtFaceNormal(ref TargetFace).AsVector()); Camera.Target = FacePoint; Camera.UpVector = UplDirection; Camera.Fit(); Camera.Apply(); } } } } }
private void GetFaceToView(Inventor.SurfaceBody mSurfaceBody, ref Inventor.PartDocument PartDocument, ref Inventor.Camera Camera) { double Max = mSurfaceBody.Faces[1].Evaluator.Area * 100; double currentValue = 0; GetExtents(mSurfaceBody); Inventor.Face TargetFace = null; foreach (Inventor.Face Face in mSurfaceBody.Faces) { currentValue = Face.Evaluator.Area * 100; if (currentValue >= Max) { Max = Face.Evaluator.Area * 100; TargetFace = Face; } } SetDrawingView(mSurfaceBody, ref Camera, TargetFace); }
private void SetCameraView(Inventor.Camera Camera, Inventor.Face Face) { }