//把模型中的点转换到草图中的坐标。 public object TransformPoint(Sketch Sketch1, double X, double Y, double Z) { ISldWorks swApp = iSwApp; MathUtility swMathUtil; object @params; MathTransform swMathTrans; MathPoint swMathPt; double[] ptArr = new double[3]; ptArr[0] = X; ptArr[1] = Y; ptArr[2] = Z; swMathUtil = (MathUtility)swApp.GetMathUtility(); swMathPt = (MathPoint)swMathUtil.CreatePoint((ptArr)); object NewPt; @params = swMathPt.ArrayData; swMathTrans = Sketch1.ModelToSketchTransform; swMathPt = (MathPoint)swMathPt.MultiplyTransform(swMathTrans); NewPt = swMathPt.ArrayData; return(NewPt); }
private Vector GetDirection(object inputObj) { if (inputObj is IFace2) { ISurface surf = (inputObj as IFace2).GetSurface() as ISurface; if (surf.IsCylinder()) { double[] cylParams = surf.CylinderParams as double[]; return(new Vector(cylParams[3], cylParams[4], cylParams[5])); } } else if (inputObj is IFeature) { IRefPlane refPlane = (inputObj as IFeature).GetSpecificFeature2() as IRefPlane; if (refPlane != null) { IMathUtility mathUtils = m_App.GetMathUtility() as IMathUtility; IMathVector vec = mathUtils.CreateVector(new double[] { 0, 0, 1 }) as IMathVector; vec = vec.MultiplyTransform(refPlane.Transform) as IMathVector; return(new Vector(vec.ArrayData as double[])); } } throw new NullReferenceException("Failed to find the direction. Please select cylindrical face or plane"); }
public static void SetManipulatorPositionToBodyCenter(ISldWorks sldWorks, TriadManipulatorTs manipulator, IBody2 body, IModelDoc2 model) { var box = body.GetBodyBoxTs(); manipulator.Origin = (MathPoint)((IMathUtility)sldWorks.GetMathUtility()).CreatePoint(box.Center.ToDoubles()); manipulator.UpdatePosition(); }
public void changePois(ISldWorks swApp) //将点变为绝对坐标下 { MathUtility mathUtil = (MathUtility)swApp.GetMathUtility(); for (int i = 0; i < pois.Count; i++) { double[] vPnt = new double[3]; vPnt[0] = pois[i].x; vPnt[1] = pois[i].y; vPnt[2] = pois[i].z; MathPoint mp = (MathPoint)mathUtil.CreatePoint(vPnt); //double[] temPoi = mp.ArrayData; //MathTransform trans = sket.ModelToSketchTransform; MathTransform trans = sket.ModelToSketchTransform.Inverse(); mp = mp.MultiplyTransform(trans); double[] temPoi = mp.ArrayData; pois[i].setLocation(temPoi[0], temPoi[1], temPoi[2]); Debug.Print("Point " + i + ": " + pois[i].ox + ", " + pois[i].oy + ", " + pois[i].oz); } }
private void ConstructExporter(SldWorks iSldWorksApp) { iSwApp = iSldWorksApp; ActiveSWModel = (ModelDoc2)iSwApp.ActiveDoc; swMath = iSwApp.GetMathUtility(); }
private void constructExporter(ISldWorks iSldWorksApp) { iSwApp = iSldWorksApp; ActiveSWModel = (ModelDoc2)iSwApp.ActiveDoc; swMath = iSwApp.GetMathUtility(); }
public static void SetManipulatorPositionToBodyCenter(ISldWorks sldWorks, TriadManipulatorTs manipulator, IBody2 body, IModelDoc2 model) { var box = body.GetBodyBoxTs(); manipulator.Origin = (MathPoint) ((IMathUtility) sldWorks.GetMathUtility()).CreatePoint(box.Center.ToDoubles()); manipulator.UpdatePosition(); }