/// <summary> /// Attaches the specified Xref to the current space in the current drawing. /// </summary> /// <param name="path">Path to the drawing file to attach as an Xref.</param> /// <param name="pos">Position of Xref in WCS coordinates.</param> /// <param name="name">Optional name for the Xref.</param> /// <param name="idBtrXref">Блок внешней ссылки - BlockTableRecord</param> /// <returns>Whether the attach operation succeeded.</returns> public static bool XrefAttachAndInsert(this Database db, string path, Point3d pos, out ObjectId idBtrXref, out ObjectId idBlRefXref, string name = null) { idBtrXref = ObjectId.Null; idBlRefXref = ObjectId.Null; var ret = false; if (!File.Exists(path)) return ret; if (String.IsNullOrEmpty(name)) name = Path.GetFileNameWithoutExtension(path); using (var t = db.TransactionManager.StartOpenCloseTransaction()) { idBtrXref = db.AttachXref(path, name); if (idBtrXref.IsValid) { var ms = (BlockTableRecord)t.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForWrite); var br = new BlockReference(pos, idBtrXref); idBlRefXref = ms.AppendEntity(br); t.AddNewlyCreatedDBObject(br, true); ret = true; } t.Commit(); } return ret; }
private float GetValue(Point3d pt, double minX, double maxX, double minY, double maxY) { int x = (int)Util.Number.Map(pt.X, minX, maxX, 0, bitmap.Width - 1, false); int y = (int)(bitmap.Height - Util.Number.Map(pt.Y, minY, maxY, 0, bitmap.Height - 1, false)); Color color = crossed ? Color.White : Color.Black; if (vehicle.Environment.Wrap) { if (x < 0) { x += bitmap.Width; } else if (x >= bitmap.Width) { x -= bitmap.Width; } if (y < 0) { y += bitmap.Height; } else if (y >= bitmap.Height) { y -= bitmap.Height; } } if ((0 <= x && x < bitmap.Width) && (0 <= y && y < bitmap.Height)) { color = bitmap.GetPixel(x, y); } return color.GetBrightness(); }
/// <summary> /// Draws the concentric circles given the center-point and the colors /// for each circle. It is assumed that the colors are ordered with /// the outer-most circle's color first, working it way toward the /// inner-most circle. /// </summary> /// <param name="center">Center-Point for all circles</param> /// <param name="colors"> /// Colors for each circle ordered by outer-most circle's color first /// </param> public static void DrawConcentricCircles(Point3d center, Color[] colors) { // get current document and DB var acDocument = Application.DocumentManager.MdiActiveDocument; var acCurrentDB = acDocument.Database; // start a transaction in which the concentric circles will // be created using (var acTransaction = acCurrentDB.TransactionManager.StartTransaction()) { var acBlockTable = acTransaction.GetObject(acCurrentDB.BlockTableId, OpenMode.ForRead) as BlockTable; var acBlockTableRecord = acTransaction.GetObject(acBlockTable[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; // create a circle for each color and commit the transaction int i = 0; foreach (var color in colors) { var circle = CreateCircle(i, center, color); acBlockTableRecord.AppendEntity(circle); acTransaction.AddNewlyCreatedDBObject(circle, true); i++; } acTransaction.Commit(); } }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { //Input Point3d supportPt = new Point3d(); DA.GetData(0, ref supportPt); bool isXFixed = true; DA.GetData(1, ref isXFixed); bool isYFixed = true; DA.GetData(2, ref isYFixed); bool isZFixed = true; DA.GetData(3, ref isZFixed); double weight = 1.0; DA.GetData(4, ref weight); //Warning if no direction is fixed if (!isXFixed && !isYFixed && !isZFixed) { this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "The specified point is free to move!"); } //Create simple support goal GoalObject support = new SupportGoal(supportPt, isXFixed, isYFixed, isZFixed, weight); //Output DA.SetData(0, support); }
public Polygon2D(int s, Point3d c, Double a) { this.Sides = s; this.Center = c; this.Apotema = a; CreateGeometry(); }
public static Rhino.Commands.Result AddLinearDimension2(Rhino.RhinoDoc doc) { Point3d origin = new Point3d(1,1,0); Point3d offset = new Point3d(11,1,0); Point3d pt = new Point3d((offset.X-origin.X)/2,3,0); Plane plane = Plane.WorldXY; plane.Origin = origin; double u,v; plane.ClosestParameter(origin, out u, out v); Point2d ext1 = new Point2d(u, v); plane.ClosestParameter(offset, out u, out v); Point2d ext2 = new Point2d(u, v); plane.ClosestParameter(pt, out u, out v); Point2d linePt = new Point2d(u, v); LinearDimension dimension = new LinearDimension(plane, ext1, ext2, linePt); if (doc.Objects.AddLinearDimension(dimension) != Guid.Empty) { doc.Views.Redraw(); return Rhino.Commands.Result.Success; } return Rhino.Commands.Result.Failure; }
public override Mesh Generate(Point3d P, Vector3d V) { Vector3d diffx; Vector3d diffy; Vector3d diffz = new Vector3d(V); double proj; diffx = new Vector3d(0, 0, 1); proj = System.Math.Abs(Vector3d.Multiply(diffz, diffx)); if (0.99 < proj && 1.01 > proj) diffx = new Vector3d(1, 0, 0); diffy = diffz; diffy = Vector3d.CrossProduct(diffy, diffx); diffx = Vector3d.CrossProduct(diffy, diffz); diffx.Unitize(); diffy.Unitize(); diffz.Unitize(); Mesh M = new Mesh(); M.Vertices.SetVertex(0, P + diffz * 0.25); M.Vertices.SetVertex(1, P + (diffx * 0.7072 + diffy * -.5 + diffz * -.5) * 0.25); M.Vertices.SetVertex(2, P + (diffy + diffz * -.5) * 0.25); M.Vertices.SetVertex(3, P + (diffx * -0.7072 + diffy * -.5 + diffz * -.5) * 0.25); M.Faces.SetFace(0, 0, 1, 2); M.Faces.SetFace(1, 0, 2, 3); M.Faces.SetFace(2, 0, 3, 1); M.Faces.SetFace(3, 3, 2, 1); M.FaceNormals.ComputeFaceNormals(); //M.ComputeVertexNormals(); return M; }
public PolyLine3d(Point3d p1, Point3d p2, Color clr) { m_points = new ArrayList(); m_color = clr; m_points.Add(p1); m_points.Add(p2); }
public static Point3d Center(this Point3d pt, Point3d other) { return new Point3d( pt.X + (other.X - pt.X) * 0.5, pt.Y + (other.Y - pt.Y) * 0.5, pt.Z + (other.Z - pt.Z) * 0.5); }
protected override Vector3d CalculateDesiredVelocity() { Vector3d desired = new Vector3d(); //Predict the vehicle's future location Vector3d predict = agent.Velocity3D; predict.Unitize(); predict = predict * predictionDistance; predictLoc = agent.Position3D + predict; //Find the normal point along the path double t; path.ClosestPoint(predictLoc, out t); pathPt = path.PointAt(t); //Move a little further along the path and set a target //If we are off the path, seek that target in order to stay on the path double distance = pathPt.DistanceTo(predictLoc); if (distance > radius) { pathPt = path.PointAt(t + pathTargetDistance); pathPt = agent.Environment.MapTo2D(pathPt); // Seek that point desired = Util.Agent.Seek(agent, pathPt); } return desired; }
public Point3d[] GetValues() { Point3d[] result = new Point3d[4]; for (int i = 0; i <= 3; i++) result[i] = this[i]; return result; }
public bool Init(ObjectId id, Point3d pt) { Database db = HostApplicationServices.WorkingDatabase; using (Transaction tr = db.TransactionManager.StartTransaction()) { try { m_Pos = id; RebarPos pos = tr.GetObject(m_Pos, OpenMode.ForRead) as RebarPos; if (pos == null) { return false; } txtPosMarker.Text = pos.Pos; hit = pos.HitTest(pt); } catch (System.Exception ex) { MessageBox.Show("Error: " + ex.Message, "RebarPos", MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } } return true; }
/// <summary> /// 根据板件的尺寸和水平孔的位置,获取水平孔以MP为原点时的坐标,如果在边沿就等于0或者板件长宽 /// </summary> /// <returns></returns> public Point3d GetBorePosition() { Point3d holePosition = new Point3d(); if (!this.Part.MachinePoint.IsRotated) { if (FaceNumber == 1) holePosition = new Point3d(Position, 0, ZValue); else if (FaceNumber == 2) holePosition = new Point3d(Position, Part.Width, ZValue); else if (FaceNumber == 3) holePosition = new Point3d(0, Position, ZValue); else if (FaceNumber == 4) holePosition = new Point3d(Part.Length, Position, ZValue); } else { if (FaceNumber == 1) holePosition = new Point3d(Position, 0, ZValue); else if (FaceNumber == 2) holePosition = new Point3d(Position, Part.Length, ZValue); else if (FaceNumber == 3) holePosition = new Point3d(0, Position, ZValue); else if (FaceNumber == 4) holePosition = new Point3d(Part.Width, Position, ZValue); } return holePosition; }
// public Movil(ref ObjectId line, ref ObjectId mobile, double minSeparation, double maxSeparation, bool loopTravel) { this.line = line; this.mobile = mobile; this.dPromMin = minSeparation; this.dPromMax = maxSeparation; this.loopTravel = loopTravel; this.goal = false; this.ruta = Lab3.DBMan.OpenEnity(line) as Polyline; this.bloque = Lab3.DBMan.OpenEnity(mobile) as BlockReference; this.bloqueCentro = new Point3d((bloque.GeometricExtents.MinPoint.X + bloque.GeometricExtents.MaxPoint.X) / 2, (bloque.GeometricExtents.MinPoint.Y + bloque.GeometricExtents.MaxPoint.Y) / 2, 0); this.numeroSegmentos = this.ruta.NumberOfVertices - 1; this.segmentoActualIndex = 0; this.segmentoActual = this.ruta.GetLineSegment2dAt(segmentoActualIndex); Lab3.DBMan.UpdateBlockPosition(new Point3d(this.segmentoActual.StartPoint.X, this.segmentoActual.StartPoint.Y, 0), mobile); // AttributeManager attribute = new AttributeManager(mobile); attribute.SetAttribute("Velocity", this.velocity+" [Kms/hr]"); // this.pointActualCurve = 0; this.velocityScale = 0.00001f; this.velocity = this.UpdateDireccion(); Lab3.DBMan.UpdateBlockRotation(new Vector2d(this.velocity.X, this.velocity.Y).Angle, this.mobile); }
protected override bool GetInputs(IGH_DataAccess da) { if(!base.GetInputs(da)) return false; // First, we need to retrieve all data from the input parameters. // Then we need to access the input parameters individually. // When data cannot be extracted from a parameter, we should abort this method. if (!da.GetData(nextInputIndex++, ref vehicle)) return false; if (!da.GetData(nextInputIndex++, ref visionRadiusMultiplier)) return false; if (!da.GetData(nextInputIndex++, ref visionAngleMultiplier)) return false; if (!da.GetData(nextInputIndex++, ref crossed)) return false; if (!(0.0 <= visionRadiusMultiplier && visionRadiusMultiplier <= 1.0)) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, RS.visionRadiusMultiplierErrorMessage); return false; } if (!(0.0 <= visionAngleMultiplier && visionAngleMultiplier <= 1.0)) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, RS.visionAngleMultiplierErrorMessage); return false; } sensorLeftPos = vehicle.GetSensorPosition(visionRadiusMultiplier, visionAngleMultiplier); sensorRightPos = vehicle.GetSensorPosition(visionRadiusMultiplier, -visionAngleMultiplier); return true; }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="da">The DA object is used to retrieve from inputs and store in outputs.</param> protected override bool GetInputs(IGH_DataAccess da) { if (!base.GetInputs(da)) return false; if (!da.GetData(nextInputIndex++, ref targetPt)) return false; targetPt = agent.Environment.MapTo2D(targetPt); return true; }
public BorderPromptResult(PromptResultStatus queryStatus) { this.queryStatus = queryStatus; this.firstPoint = Point3d.Origin; this.secondPoint = Point3d.Origin; this.stringResult = ""; }
public BorderPromptResult(Point3d firstPoint, Point3d secondPoint) { this.queryStatus = PromptResultStatus.OK; this.firstPoint = firstPoint; this.secondPoint = secondPoint; this.stringResult = ""; }
/// <summary> /// コンストラクタ /// </summary> public EffectObject() { Children = new EffectCollection(this); Scenario = new Scenario(); LocalTransform = new Matrix44d(); BaseScale = new Point3d(1.0, 1.0, 1.0); Scale = new Point3d(1.0, 1.0, 1.0); Opacity = 1.0; //Transform = new Matrix44d(); InheritedOpacity = 1.0; // 値をForeverにすると、子要素があってもなくてもオブジェクトが // 終了しなくなります。 // また0にすると最初のフレームでオブジェクトが破棄されてしまうため、 // 初期化の仕方によってはDurationの設定に失敗することがあります。 // そのため、ここでは非常に小さいけれど0より大きい値を設定しています。 Duration = TimeSpan.FromSeconds(0.001); this.AddPropertyChangedHandler("Parent", (_, __) => { OnDataContextChanged(true); UpdateInheritedOpacity(); }); this.AddPropertyChangedHandler("BasePath", (_, __) => OnBasePathChanged(BasePath)); this.AddPropertyChangedHandler("DataContext", (_, __) => OnDataContextChanged(false)); this.AddPropertyChangedHandler("Opacity", (_, __) => UpdateInheritedOpacity()); lock (instanceList) { instanceList.Add(new WeakReference(this)); } }
public static Plane QuaternionToPlane(Point3d point, Quaternion quaternion) { Plane plane; quaternion.GetRotation(out plane); plane.Origin = point; return plane; }
/// <summary> /// 在AutoCAD图形中插入块参照 /// </summary> /// <param name="spaceId">块参照要加入的模型空间或图纸空间的Id</param> /// <param name="layer">块参照要加入的图层名</param> /// <param name="blockName">块参照所属的块名</param> /// <param name="position">插入点</param> /// <param name="scale">缩放比例</param> /// <param name="rotateAngle">旋转角度</param> /// <param name="attNameValues">属性的名称与取值</param> /// <returns>返回块参照的Id</returns> public static ObjectId InsertBlockReference(this ObjectId spaceId, string layer, string blockName, Point3d position, Scale3d scale, double rotateAngle) { DocumentLock docLock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument(); ObjectId blockRefId; Database db = spaceId.Database; BlockTable bt = (BlockTable)db.BlockTableId.GetObject(OpenMode.ForRead); if (!bt.Has(blockName)) return ObjectId.Null; BlockTableRecord space = (BlockTableRecord)spaceId.GetObject(OpenMode.ForWrite); BlockReference br = new BlockReference(position, bt[blockName]); br.ScaleFactors = scale; br.Layer = layer; br.Rotation = rotateAngle; ObjectId btrId = bt[blockName]; BlockTableRecord record = (BlockTableRecord)btrId.GetObject(OpenMode.ForRead); if (record.Annotative == AnnotativeStates.True) { ObjectContextCollection contextCollection = db.ObjectContextManager.GetContextCollection("ACDB_ANNOTATIONSCALES"); ObjectContexts.AddContext(br, contextCollection.GetContext("1:1")); } blockRefId = space.AppendEntity(br); db.TransactionManager.AddNewlyCreatedDBObject(br, true); space.DowngradeOpen(); docLock.Dispose(); return blockRefId; }
public static Result Leader(RhinoDoc doc) { var points = new Point3d[] { new Point3d(1, 1, 0), new Point3d(5, 1, 0), new Point3d(5, 5, 0), new Point3d(9, 5, 0) }; var xy_plane = Plane.WorldXY; var points2d = new List<Point2d>(); foreach (var point3d in points) { double x, y; if (xy_plane.ClosestParameter(point3d, out x, out y)) { var point2d = new Point2d(x, y); if (points2d.Count < 1 || point2d.DistanceTo(points2d.Last<Point2d>()) > RhinoMath.SqrtEpsilon) points2d.Add(point2d); } } doc.Objects.AddLeader(xy_plane, points2d); doc.Views.Redraw(); return Result.Success; }
private bool checkIfOnLine(Point3d pt1, Point3d pt2, Point3d pttested) { double num = pttested.DistanceTo(pt1); double num2 = pttested.DistanceTo(pt2); double num3 = pt1.DistanceTo(pt2); return ((num + num2) > num3); }
public BWCad12(Transaction trans, short barNumber, double scale, short barAmount, short tierAmount, double barDiameter, double spanStep, Point3d barPoint1, Point3d barPoint2, Point3d spanPoint1, Point3d spanPoint2, Point3d descriptionSignPoint, double descriptionSignRotation, bool adaptate) { InitializeBWCad12(trans, barNumber, scale, barAmount, tierAmount, barDiameter, spanStep, barPoint1, barPoint2, spanPoint1, spanPoint2, descriptionSignPoint, descriptionSignRotation, adaptate); }
public Point3d(Point3d vec_in) { this.f_x = vec_in.x; this.f_y = vec_in.y; this.f_z = vec_in.z; this.f_mag = vec_in.mag; }
public static double AngleBetweenTwoTriangles(Point3d A, Point3d B, Point3d M, Point3d N) { return AngleBetweenTwoVectors( M - ClosestPointOnLine(M, A, B), N - ClosestPointOnLine(N, A, B) ); }
public BorderPromptResult(string stringResult) { this.queryStatus = PromptResultStatus.Keyword; this.stringResult = stringResult; this.firstPoint = Point3d.Origin; this.secondPoint = Point3d.Origin; }
public Point3d(Point3d p) { this.X = p.X; this.Y = p.Y; this.Z = p.Z; Index = p.Index; }
/// <summary> /// El constructor para crear una casita, especificando un tamaño /// y el punto de inserción /// </summary> /// <param name="size">El tamaño de la casita</param> /// <param name="insPt">El punto de inserción de la casita</param> public Casita(double size, Point3d insPt) { this.Size = size; this.Geometry = new Point3d[] { //4 Puntos inferiores insPt, //0 new Point3d(insPt.X + this.Size, insPt.Y, 0), //1 new Point3d(insPt.X + this.Size, insPt.Y + this.Size, 0), //2 new Point3d(insPt.X, insPt.Y + this.Size, 0), //3 //4 Puntos superiores new Point3d(insPt.X, insPt.Y, this.Size), //4 new Point3d(insPt.X + this.Size, insPt.Y, this.Size), //5 new Point3d(insPt.X + this.Size, insPt.Y + this.Size, this.Size), //6 new Point3d(insPt.X, insPt.Y + this.Size, this.Size), //7 //2 Puntos del techo new Point3d(insPt.X + this.Size / 2, insPt.Y + this.Size / 4, this.Size + this.Size / 3), //8 new Point3d(insPt.X + this.Size / 2, insPt.Y + 3 * this.Size / 4, this.Size + this.Size / 3), //9 }; this.Faces = new List<Face>(); //Frontal QUAD(0, 1, 5, 4, Cafe); TRI(5, 8, 4, Rojo); //Trasera QUAD(3, 2, 6, 7, Cafe); TRI(6, 9, 7, Rojo); //Lateral Izq QUAD(0, 3, 7, 4, Cafe); QUAD(7, 4, 8, 9, Rojo); //Lateral Derecha QUAD(1, 5, 6, 2, Cafe); QUAD(6, 5, 8, 9, Rojo); }
/// <summary> /// Constructs a boundingbox from a collection of points. /// </summary> /// <param name="points">Points to include in the boundingbox.</param> public BoundingBox(System.Collections.Generic.IEnumerable<Point3d> points) : this() { bool first = true; foreach (Point3d pt in points) { if (first) { m_min = pt; m_max = pt; first = false; } else { if (m_min.m_x > pt.m_x) m_min.m_x = pt.m_x; if (m_min.m_y > pt.m_y) m_min.m_y = pt.m_y; if (m_min.m_z > pt.m_z) m_min.m_z = pt.m_z; if (m_max.m_x < pt.m_x) m_max.m_x = pt.m_x; if (m_max.m_y < pt.m_y) m_max.m_y = pt.m_y; if (m_max.m_z < pt.m_z) m_max.m_z = pt.m_z; } } }
// Sampler函数用于检测用户的输入. protected override SamplerStatus Sampler(JigPrompts prompts) { if (mPromptCounter == 0) { // 定义一个点拖动交互类. JigPromptPointOptions optJigPoint = new JigPromptPointOptions("\n请指定椭圆弧轴上一点"); // 设置拖拽的光标类型. optJigPoint.Cursor = CursorType.RubberBand; // 设置拖动光标基点. optJigPoint.BasePoint = mCenterPt; optJigPoint.UseBasePoint = true; // 用AcquirePoint函数得到用户输入的点. PromptPointResult resJigPoint = prompts.AcquirePoint(optJigPoint); Point3d curPt = resJigPoint.Value; if (curPt != mMajorPt) { // mMajorPt = curPt; } else { return(SamplerStatus.NoChange); } if (resJigPoint.Status == PromptStatus.Cancel) { return(SamplerStatus.Cancel); } else { return(SamplerStatus.OK); } } else if (mPromptCounter == 1) { // 定义一个距离拖动交互类. JigPromptDistanceOptions optJigDis = new JigPromptDistanceOptions("\n请指定另一条半轴的长度"); // 设置对拖拽的约束:禁止输入零和负值. optJigDis.UserInputControls = UserInputControls.NoZeroResponseAccepted | UserInputControls.NoNegativeResponseAccepted; // 设置拖拽的光标类型. optJigDis.Cursor = CursorType.RubberBand; // 设置拖动光标基点. optJigDis.BasePoint = mCenterPt; optJigDis.UseBasePoint = true; // 用AcquireDistance函数得到用户输入的距离值. PromptDoubleResult resJigDis = prompts.AcquireDistance(optJigDis); double mRadiusRatioTemp = resJigDis.Value; if (mRadiusRatioTemp != mRadiusRatio) { // 保存当前距离值. mRadiusRatio = mRadiusRatioTemp; } else { return(SamplerStatus.NoChange); } if (resJigDis.Status == PromptStatus.Cancel) { return(SamplerStatus.Cancel); } else { return(SamplerStatus.OK); } } else if (mPromptCounter == 2) { // 设置椭圆弧0度基准角. double baseAng; Vector2d mMajorAxis2d = new Vector2d(mMajorAxis.X, mMajorAxis.Y); if (radiusRatio < 1) { baseAng = mMajorAxis2d.Angle; } else { baseAng = mMajorAxis2d.Angle + 0.5 * Math.PI; } // 设置系统变量“ANGBASE”. Application.SetSystemVariable("ANGBASE", baseAng); // 定义一个角度拖动交互类. JigPromptAngleOptions optJigAngle1 = new JigPromptAngleOptions("\n请指定椭圆弧的起始角度"); // 设置拖拽的光标类型. optJigAngle1.Cursor = CursorType.RubberBand; // 设置拖动光标基点. optJigAngle1.BasePoint = mCenterPt; optJigAngle1.UseBasePoint = true; // 用AcquireAngle函数得到用户输入的角度值. PromptDoubleResult resJigAngle1 = prompts.AcquireAngle(optJigAngle1); ang1 = resJigAngle1.Value; if (startAng != ang1) { // 保存当前角度值. startAng = ang1; } else { return(SamplerStatus.NoChange); } if (resJigAngle1.Status == PromptStatus.Cancel) { return(SamplerStatus.Cancel); } else { return(SamplerStatus.OK); } } else if (mPromptCounter == 3) { // 定义一个角度拖动交互类. JigPromptAngleOptions optJigAngle2 = new JigPromptAngleOptions("\n请指定椭圆弧的终止角度"); // 设置拖拽的光标类型. optJigAngle2.Cursor = CursorType.RubberBand; // 设置拖动光标基点. optJigAngle2.BasePoint = mCenterPt; optJigAngle2.UseBasePoint = true; // 用AcquireAngle函数得到用户输入的角度值. PromptDoubleResult resJigAngle2 = prompts.AcquireAngle(optJigAngle2); ang2 = resJigAngle2.Value; if (endAng != ang2) { // 保存当前角度值. endAng = ang2; } else { return(SamplerStatus.NoChange); } if (resJigAngle2.Status == PromptStatus.Cancel) { return(SamplerStatus.Cancel); } else { return(SamplerStatus.OK); } } else { return(SamplerStatus.NoChange); } }
buildArea3dLimit(ObjectId idPoly, string nameSurface, string nameSurfaceX, string nameLayer = "") { //3d Boundary bool exists; idPoly.checkIfClosed(); List <Point3d> pnts3dPoly = idPoly.getCoordinates3dList(); string strLayName = idPoly.getLayer(); List <Point3d> pnts3dBNDY = new List <Point3d>(); Color color = new Color(); color = Color.FromColorIndex(ColorMethod.ByBlock, 5); //each polyline segment TinSurface tinSurf = Surf.getTinSurface(nameSurface, out exists); for (int j = 1; j < pnts3dPoly.Count; j++) { Point3d pnt3dBEG = pnts3dPoly[j - 1]; Point3d pnt3dEND = pnts3dPoly[j]; ObjectId idLine = Draw.addLine(pnt3dBEG, pnt3dEND); Point3dCollection pnts3d = tinSurf.SampleElevations(idLine); if (pnts3d.Count > 0) { for (int k = 0; k < pnts3d.Count; k++) { if (pnts3d[k].Z > 0) { pnts3dBNDY.Add(pnts3d[k]); } else { string mess = string.Format("Area Limit outside surface at X={0}, Y={1}\n EXITING PROGRAM", pnts3d[k].X, pnts3d[k].Z); Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog(mess); } } idLine.delete(); } else { Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("intUBnd not > 0 at: " + j + " -See Blue lines where boundary is outside surface limit"); idLine.changeProp(color, "DEBUG-0", LineWeight.LineWeight211); } } ObjectId id3dPline = pnts3dBNDY.addPoly3d(); id3dPline.changeProp(color, nameSurfaceX + "-BRKLINE-AREA"); TypedValue[] tvs = new TypedValue[3] { new TypedValue(1001, "makeBOT"), new TypedValue(1000, nameLayer), new TypedValue(1000, "LIM") }; id3dPline.setXData(tvs, "makeBOT"); return(id3dPline); }
protected IfcPlacement(DatabaseIfc db, Point3d position) : base(db) { Location = new IfcCartesianPoint(db, position); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { Curve boundary = null; DA.GetData <Curve>(0, ref boundary); string folderPath = string.Empty; DA.GetData <string>(1, ref folderPath); if (!folderPath.EndsWith(@"\")) { folderPath = folderPath + @"\"; } string prefix = string.Empty; DA.GetData <string>(2, ref prefix); if (prefix == "") { prefix = osmSource; } string searchTerm = string.Empty; DA.GetData <string>(3, ref searchTerm); if (String.IsNullOrEmpty(searchTerm) == false) { searchTerm = System.Net.WebUtility.UrlEncode("[" + searchTerm + "]"); } bool run = false; DA.GetData <bool>("Run", ref run); /// hardcoded timout integer /// TODO: add this as a menu item that can be customized int timeout = 60; string URL = osmURL; GH_Structure <GH_String> osmList = new GH_Structure <GH_String>(); GH_Structure <GH_String> osmQuery = new GH_Structure <GH_String>(); /// Check boundary to make sure it's valid if (!boundary.GetBoundingBox(true).IsValid) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Boundary is not valid."); return; } //offset boundary to ensure data from opentopography fully contains query boundary //double offsetD = 200 * Rhino.RhinoMath.UnitScale(UnitSystem.Meters, Rhino.RhinoDoc.ActiveDoc.ModelUnitSystem); //Curve offsetB = boundary.Offset(Plane.WorldXY, offsetD, 1, CurveOffsetCornerStyle.Sharp)[0]; //offsetB = boundary; //Get OSM frame for given boundary Point3d min = Heron.Convert.XYZToWGS(boundary.GetBoundingBox(true).Min); Point3d max = Heron.Convert.XYZToWGS(boundary.GetBoundingBox(true).Max); string left = min.X.ToString(); string bottom = min.Y.ToString(); string right = max.X.ToString(); string north = max.Y.ToString(); string bbox = min.Y + "," + min.X + "," + max.Y + "," + max.X; //string oQ = String.Format(osmURL, timeout, searchTerm, bbox); string oQ = Convert.GetOSMURL(timeout, searchTerm, left, bottom, right, north, osmURL); osmQuery.Append(new GH_String(oQ)); DA.SetDataTree(1, osmQuery); if (run) { System.Net.WebClient webClient = new System.Net.WebClient(); webClient.DownloadFile(oQ, folderPath + prefix + ".osm"); webClient.Dispose(); } osmList.Append(new GH_String(folderPath + prefix + ".osm")); //populate outputs DA.SetDataTree(0, osmList); }
public Cable(Point3d start, Point3d end) { this.Geometry = new Line(start, end); }
/// <summary> /// Provides Base point from Acad point /// </summary> /// <param name="point3D">Base point</param> /// <returns>Acad point</returns> public static BasePoint ConvertToBasePoint(Point3d point3D) { return(new BasePoint(point3D.X, point3D.Y, point3D.Z)); }
// 派生类的构造函数. public EllipseJig(Point3d center, Vector3d vec) : base(new Ellipse()) { mCenterPt = center; mNormal = vec; }
public LineJig(Point3d startPoint, string message) : base(new Line(startPoint, Point3d.Origin)) { _startPoint = startPoint; _message = message; }
public RotationJig(Entity entity, Point3d center, string message) : base(entity) { this._center = center; this._message = message; }
/// <summary> /// 用于在AutoCAD图形中插入块参照 /// </summary> /// <param name="spaceId">块参照要加入的模型空间或图纸空间的Id</param> /// <param name="layer">块参照要加入的图层名</param> /// <param name="blockName">块参照所属的块名</param> /// <param name="position">块参照的插入点</param> /// <param name="scale">块参照的缩放比例</param> /// <param name="rotateAngle">块参照的旋转角度</param> /// <returns></returns> public static ObjectId InsertBlockReference(this ObjectId spaceId, string layer, string blockName, Point3d position, Scale3d scale, double rotateAngle) { ObjectId blockRefId; Database db = spaceId.Database; //打开块表 BlockTable bt = (BlockTable)db.BlockTableId.GetObject(OpenMode.ForRead); if (!bt.Has(blockName)) { return(ObjectId.Null); } //以写的方式打开空间(模型空间或图纸空间) BlockTableRecord space = (BlockTableRecord)spaceId.GetObject(OpenMode.ForWrite); //创建一个块参照并设置插入点 BlockReference br = new BlockReference(position, bt[blockName]); //设置块参照的缩放比例 br.ScaleFactors = scale; //设置块参照的层名 br.Layer = layer; //设置块参照的旋转角度 br.Rotation = rotateAngle; //在空间中加入创建的块参照 blockRefId = space.AppendEntity(br); //通知事务处理加入创建的块参照 db.TransactionManager.AddNewlyCreatedDBObject(br, true); space.DowngradeOpen(); return(blockRefId); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { var X2D = new double[2][] { new double[2] { 0, 1 }, new double[2] { 0, 1 } }; X2D = new double[2][] { new double[3] { 0, 0.25, 1 }, new double[3] { 0, 0.5, 1 } }; //var Z2D = new double[9] { 1, 1, 1, 1, 1, 1, 1, 1, 1 }; var Z2D = new double[9] { 1, 2, 3, 4, 2, -3, 1, 2, 3 }; //var Z2D = new double[4] { 1, 2, 3, 4 }; //Z2D = new double[6] { 1, 2, 3, 1, 2, 3 }; Z = Z2D; grid = new Grid(X2D); gp = new IvyCore.Parametric.Point(grid); Zpts = this.ConstructFieldView(grid, Z); var p = new Point3d(); DA.GetData(0, ref p); int n = Math.Min(gp.Dim, 3); for (int i = 0; i < n; i++) { gp[i] = p[i]; } int cellIndex = gp.CellIndex(); var cell = gp.Grid.Cells[cellIndex]; Interpolant interp = cell.GetInterpolant(gp); double zlerp = interp.Lerp(Z); //for (int i = 0; i < LERP.Length; i++) //{ // int index = cell.VerticesIndex[i]; // zlerp += LERP[i] * Z[index]; //} var cellPts = new Point3d[5]; double[] node; node = grid.Nodes[cell.VerticesIndex[0]].Coord; cellPts[0] = new Point3d(node[0], node[1], 0); node = grid.Nodes[cell.VerticesIndex[1]].Coord; cellPts[1] = new Point3d(node[0], node[1], 0); node = grid.Nodes[cell.VerticesIndex[3]].Coord; cellPts[2] = new Point3d(node[0], node[1], 0); node = grid.Nodes[cell.VerticesIndex[2]].Coord; cellPts[3] = new Point3d(node[0], node[1], 0); cellPts[4] = cellPts[0]; var contour = new PolylineCurve(cellPts); p.Z = zlerp; DA.SetData(0, p); DA.SetDataList(1, Zpts); DA.SetData(2, contour); DA.SetData(3, grid.Info()); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { Point3d origin = Point3d.Unset; if (!DA.GetData(0, ref origin)) { origin = new Point3d(0, 0, 0); } int xyz = 1; if (!DA.GetData(1, ref xyz)) { xyz = 1; } int sectionheight = 1; if (!DA.GetData(2, ref sectionheight)) { sectionheight = 1; } double low = double.NaN; if (!DA.GetData(3, ref low)) { low = 0; } double top = double.NaN; if (!DA.GetData(4, ref top)) { top = 15; } double[, ,] vu, vv, vw; List <double[, , ]> vel = new List <double[, , ]> { }; DA.GetDataList(5, vel); vu = vel[0]; vv = vel[1]; vw = vel[2]; double[, ,] p = new double[, , ] { }; DA.GetData(6, ref p); double hx = double.NaN; double hy = double.NaN; double hz = double.NaN; if (!DA.GetData(7, ref hx)) { return; } if (!DA.GetData(8, ref hy)) { return; } if (!DA.GetData(9, ref hz)) { return; } bool dispP = false; DA.GetData(10, ref dispP); int colourSheme = 0; DA.GetData(11, ref colourSheme); string output_path = null; DA.GetData(12, ref output_path); //min max pressure values double minp = double.MaxValue; double maxp = double.MinValue; for (int i = 0; i < p.GetLength(0); i++) { for (int j = 0; j < p.GetLength(1); j++) { for (int k = 0; k < p.GetLength(2); k++) { if (minp > p[i, j, k]) { minp = p[i, j, k]; } if (maxp < p[i, j, k]) { maxp = p[i, j, k]; } } } } Point3f[][] MVert = new Point3f[vu.GetLength(0)][]; Color[][] Cols = new Color[vu.GetLength(0)][]; int[][] index = new int[vu.GetLength(0)][]; int counter = 0; double[,] output_vu = new double[1, 1]; double[,] output_vv = new double[1, 1]; double[,] output_vw = new double[1, 1]; double[,] output_p = new double[1, 1]; Mesh MshColSection = new Mesh(); switch (xyz) { case 0: //x //8---9---10--11 //| x | x | x | //4---5---6---7 //| x | x | x | //0---1---2---3 // //- loop through and get colours for all vertices //- make vertices as point3d MVert = new Point3f[vu.GetLength(1)][]; Cols = new Color[vu.GetLength(1)][]; index = new int[vu.GetLength(1)][]; counter = 0; if (dispP) { output_p = new double[vu.GetLength(1), vu.GetLength(2)]; } else { output_vu = new double[vu.GetLength(1), vu.GetLength(2)]; output_vv = new double[vu.GetLength(1), vu.GetLength(2)]; output_vw = new double[vu.GetLength(1), vu.GetLength(2)]; } for (int j = 0; j < vu.GetLength(1); j++) { MVert[j] = new Point3f[vu.GetLength(2)]; Cols[j] = new Color[vu.GetLength(2)]; index[j] = new int[vu.GetLength(2)]; for (int k = 0; k < vu.GetLength(2); k++) { MVert[j][k] = new Point3f((float)(sectionheight * hx + origin[0]), (float)(j * hy + origin[1]), (float)(k * hz + origin[2])); MshColSection.Vertices.Add(MVert[j][k]); Cols[j][k] = new Color(); index[j][k] = counter; counter++; double quantity = 0; if (dispP) { quantity = p[sectionheight, j, k]; //if (minp <= 0) quantity += Math.Abs(minp); //low = 0; //top = maxp + Math.Abs(minp); //third = (top - low) / 5; output_p[j, k] = quantity; } else { Line arrowlines = new Line(new Point3d(sectionheight * hx + origin[0], j * hy + origin[1], k * hz + origin[2]), new Vector3d(vu[sectionheight, j, k], vv[sectionheight, j, k], vw[sectionheight, j, k])); quantity = arrowlines.Length; output_vu[j, k] = vu[sectionheight, j, k]; output_vv[j, k] = vv[sectionheight, j, k]; output_vw[j, k] = vw[sectionheight, j, k]; } Cols[j][k] = Utilities.GetRGB(colourSheme, quantity, top, low); MshColSection.VertexColors.SetColor(index[j][k], Cols[j][k]); } } for (int j = 0; j < vu.GetLength(1) - 1; j++) { for (int k = 0; k < vu.GetLength(2) - 1; k++) { MshColSection.Faces.AddFace(index[j][k], index[j + 1][k], index[j + 1][k + 1], index[j][k + 1]); } } break; case 1: //y //8---9---10--11 //| x | x | x | //4---5---6---7 //| x | x | x | //0---1---2---3 // if (dispP) { output_p = new double[vu.GetLength(0), vu.GetLength(2)]; } else { output_vu = new double[vu.GetLength(0), vu.GetLength(2)]; output_vv = new double[vu.GetLength(0), vu.GetLength(2)]; output_vw = new double[vu.GetLength(0), vu.GetLength(2)]; } //- loop through and get colours for all vertices //- make vertices as point3d MVert = new Point3f[vu.GetLength(0)][]; Cols = new Color[vu.GetLength(0)][]; index = new int[vu.GetLength(0)][]; counter = 0; for (int i = 0; i < vu.GetLength(0); i++) { MVert[i] = new Point3f[vu.GetLength(2)]; Cols[i] = new Color[vu.GetLength(2)]; index[i] = new int[vu.GetLength(2)]; for (int k = 0; k < vu.GetLength(2); k++) { MVert[i][k] = new Point3f((float)(i * hx + origin[0]), (float)(sectionheight * hy + origin[1]), (float)(k * hz + origin[2])); MshColSection.Vertices.Add(MVert[i][k]); Cols[i][k] = new Color(); index[i][k] = counter; counter++; double quantity = 0; if (dispP) { quantity = p[i, sectionheight, k]; //if (minp <= 0) quantity += Math.Abs(minp); //low = 0; //top = maxp + Math.Abs(minp); //third = (top - low) / 5; output_p[i, k] = quantity; } else { Line arrowlines = new Line(new Point3d(i * hx + origin[0], sectionheight * hy + origin[1], k * hz + origin[2]), new Vector3d(vu[i, sectionheight, k], vv[i, sectionheight, k], vw[i, sectionheight, k])); quantity = arrowlines.Length; output_vu[i, k] = vu[i, sectionheight, k]; output_vv[i, k] = vv[i, sectionheight, k]; output_vw[i, k] = vw[i, sectionheight, k]; } Cols[i][k] = Utilities.GetRGB(colourSheme, quantity, top, low); MshColSection.VertexColors.SetColor(index[i][k], Cols[i][k]); } } for (int i = 0; i < vu.GetLength(0) - 1; i++) { for (int k = 0; k < vu.GetLength(2) - 1; k++) { MshColSection.Faces.AddFace(index[i][k], index[i + 1][k], index[i + 1][k + 1], index[i][k + 1]); } } break; case 2: //z //8---9---10--11 //| x | x | x | //4---5---6---7 //| x | x | x | //0---1---2---3 // if (dispP) { output_p = new double[vu.GetLength(0), vu.GetLength(1)]; } else { output_vu = new double[vu.GetLength(0), vu.GetLength(1)]; output_vv = new double[vu.GetLength(0), vu.GetLength(1)]; output_vw = new double[vu.GetLength(0), vu.GetLength(1)]; } //- loop through and get colours for all vertices //- make vertices as point3d MVert = new Point3f[vu.GetLength(0)][]; Cols = new Color[vu.GetLength(0)][]; index = new int[vu.GetLength(0)][]; counter = 0; for (int i = 0; i < vu.GetLength(0); i++) { MVert[i] = new Point3f[vv.GetLength(1)]; Cols[i] = new Color[vv.GetLength(1)]; index[i] = new int[vv.GetLength(1)]; for (int j = 0; j < vv.GetLength(1); j++) { MVert[i][j] = new Point3f((float)(i * hx + origin[0]), (float)(j * hy + origin[1]), (float)(sectionheight * hz + origin[2])); MshColSection.Vertices.Add(MVert[i][j]); Cols[i][j] = new Color(); index[i][j] = counter; counter++; double quantity = 0; if (dispP) { quantity = p[i, j, sectionheight]; //if (minp <= 0) quantity += Math.Abs(minp); //low = 0; //top = maxp + Math.Abs(minp); //third = (top - low) / 5; output_p[i, j] = quantity; } else { Line arrowlines = new Line(new Point3d(i * hx + origin[0], j * hy + origin[1], sectionheight * hz + origin[2]), new Vector3d(vu[i, j, sectionheight], vv[i, j, sectionheight], vw[i, j, sectionheight])); quantity = arrowlines.Length; output_vu[i, j] = vu[i, j, sectionheight]; output_vv[i, j] = vv[i, j, sectionheight]; output_vw[i, j] = vw[i, j, sectionheight]; } Cols[i][j] = Utilities.GetRGB(colourSheme, quantity, top, low); MshColSection.VertexColors.SetColor(index[i][j], Cols[i][j]); } } for (int i = 0; i < vu.GetLength(0) - 1; i++) { for (int j = 0; j < vv.GetLength(1) - 1; j++) { MshColSection.Faces.AddFace(index[i][j], index[i + 1][j], index[i + 1][j + 1], index[i][j + 1]); } } break; } DA.SetData(0, MshColSection); if (output_path != null) { if (dispP) { // add 'p' to filepath Utilities.WriteCSV(String.Concat(output_path, "_P.csv"), output_p); } else { //add 'vu', 'vv', 'vw' to filepath Utilities.WriteCSV(String.Concat(output_path, "_U.csv"), output_vu); Utilities.WriteCSV(String.Concat(output_path, "_V.csv"), output_vv); Utilities.WriteCSV(String.Concat(output_path, "_W.csv"), output_vw); } } }
/// <summary> /// 用于在AutoCAD图形中插入带属性的块参照 /// </summary> /// <param name="spaceId">块参照要加入的模型空间或图纸空间的Id</param> /// <param name="layer">块参照要加入的图层名</param> /// <param name="blockName">块参照所属的块名</param> /// <param name="position">块参照的插入点</param> /// <param name="scale">块参照的缩放比例</param> /// <param name="rotateAngle">块参照的旋转角度</param> /// <param name="attNameValues">属性的名称和取值</param> /// <returns></returns> public static ObjectId InsertBlockReference(this ObjectId spaceId, string layer, string blockName, Point3d position, Scale3d scale, double rotateAngle, Dictionary <string, string> attNameValues) { //获取数据库对象 Database db = spaceId.Database; //以读的方式打开块表 BlockTable bt = (BlockTable)db.BlockTableId.GetObject(OpenMode.ForRead); //如果没有blockName表示的块,则程序返回 if (!bt.Has(blockName)) { return(ObjectId.Null); } //以写的方式打开空间(模型空间或图纸空间) BlockTableRecord space = (BlockTableRecord)spaceId.GetObject(OpenMode.ForWrite); //获取块表记录的Id ObjectId btrId = bt[blockName]; //打开块表记录 BlockTableRecord btr = (BlockTableRecord)btrId.GetObject(OpenMode.ForRead); //创建一个块参照并设置插入点 BlockReference br = new BlockReference(position, bt[blockName]); //设置块参照的缩放比例 br.ScaleFactors = scale; //设置块参照的图层 br.Layer = layer; //设置块参照的旋转角度 br.Rotation = rotateAngle; //将块参照添加到模型空间 space.AppendEntity(br); //判断块表记录是否包含属性定义 if (btr.HasAttributeDefinitions) { //遍历属性定义 foreach (ObjectId id in btr) { //检查是否是属性定义 AttributeDefinition attDef = id.GetObject(OpenMode.ForRead) as AttributeDefinition; if (attDef != null) { //创建一个新的属性对象 AttributeReference attribute = new AttributeReference(); //从属性定义获得属性对象的对象特征 attribute.SetAttributeFromBlock(attDef, br.BlockTransform); //设置属性对象的其它特征 attribute.Position = attDef.Position.TransformBy(br.BlockTransform); attribute.Rotation = attDef.Rotation; attribute.AdjustAlignment(db); //判断是否包含指定的属性名称 if (attNameValues.ContainsKey(attDef.Tag.ToUpper())) { //设置属性值 attribute.TextString = attNameValues[attDef.Tag.ToUpper()].ToString(); } //向块参照添加属性对象 br.AttributeCollection.AppendAttribute(attribute); db.TransactionManager.AddNewlyCreatedDBObject(attribute, true); } } } db.TransactionManager.AddNewlyCreatedDBObject(br, true); //返回添加的块参照的Id return(br.ObjectId); }
checkPointXData2Nodes(ObjectId idCogoPnt, ResultBuffer RBpnt, string nameApp) { try { List <Handle> handlesP3d = RBpnt.rb_handles(); int i = 0; //Working with a list of unique non-zero handles foreach (Handle hP3d in handlesP3d) { //GET BREAKLINE PER STORED HANDLES Polyline3d poly3d = (Polyline3d)Db.handleToObject(hP3d.ToString()); if ((poly3d != null)) { if (poly3d.Length != 0) { ResultBuffer RBp3d = poly3d.ObjectId.getXData(nameApp); List <Handle> handlesPnts = RBp3d.rb_handles(); Handle hPnt = idCogoPnt.getHandle(); // if pnt handle is in poly3d handle list then check coordinates otherwise Point3dCollection pnts3d = poly3d.getCoordinates3d(); Point3d pnt3dCogoPnt = hPnt.getCogoPntCoordinates(); if (System.Math.Round(pnts3d[0].X, 3) == System.Math.Round(pnt3dCogoPnt.X, 3) && System.Math.Round(pnts3d[0].Y, 3) == System.Math.Round(pnt3dCogoPnt.Y, 3)) { if (pnts3d[0].Z != pnt3dCogoPnt.Z) { poly3d.setBegPnt(pnt3dCogoPnt); } if (!handlesPnts.Contains(hPnt)) { handlesPnts.Add(hPnt); poly3d.ObjectId.setXData(handlesPnts, nameApp); } } else if (System.Math.Round(pnts3d[1].X, 3) == System.Math.Round(pnt3dCogoPnt.X, 3) && System.Math.Round(pnts3d[1].Y, 3) == System.Math.Round(pnt3dCogoPnt.Y, 3)) { if (pnts3d[1].Z != pnt3dCogoPnt.Z) { poly3d.setEndPnt(pnt3dCogoPnt); } if (!handlesPnts.Contains(hPnt)) { handlesPnts.Add(hPnt); poly3d.ObjectId.setXData(handlesPnts, nameApp); } } else { poly3d.ObjectId.delete(); handlesP3d.RemoveAt(i); RBpnt = handlesP3d.handles_RB(nameApp); idCogoPnt.setXData(handlesP3d, nameApp); } } else { poly3d.ObjectId.delete(); handlesP3d.RemoveAt(i); RBpnt = handlesP3d.handles_RB(nameApp); idCogoPnt.setXData(handlesP3d, nameApp); } } else { //remove bad handle from list handlesP3d.RemoveAt(i); RBpnt = handlesP3d.handles_RB(nameApp); idCogoPnt.setXData(handlesP3d, nameApp); } i++; } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " xData.cs: line: 145"); } return(RBpnt); }
public void MyCommand() // This method can have any name { LayerStateManager LayerState = db.LayerStateManager; int viewnum = 0; ObjectId SaveTableID = InitialSave(); if (SaveTableID == ObjectId.Null) { ed.WriteMessage("\n遇到问题,无法创建存档..."); return; } int SaveNum = GetSave(SaveTableID); if (SaveNum != InitialNum) { PromptIntegerOptions InputOption = new PromptIntegerOptions("\n回车继续上次的编号,或者输入新的视图起始编号"); InputOption.AllowNone = true; InputOption.DefaultValue = SaveNum; PromptIntegerResult InputRes = ed.GetInteger(InputOption); if (InputRes.Status != PromptStatus.OK) { return; } viewnum = InputRes.Value; } else { PromptIntegerResult numres = ed.GetInteger("\n输入视图起始编号"); if (numres.Status != PromptStatus.OK) { return; } viewnum = numres.Value; } int counter = 0; while (true) { inputstart: PromptEntityOptions ops = new PromptEntityOptions("\n选择视图框"); ops.SetRejectMessage("\n只能选择封闭的矩形!"); ops.AddAllowedClass(typeof(Polyline), true); ops.AllowNone = false; ops.AllowObjectOnLockedLayer = true; PromptEntityResult res = ed.GetEntity(ops); if (res.Status != PromptStatus.OK) { if (counter != 0) { UpdateSave(SaveTableID, viewnum); } ed.WriteMessage("\n共创建{0}个视图。", counter); break; } using (Transaction trans = db.TransactionManager.StartTransaction()) { try { Polyline PL = trans.GetObject(res.ObjectId, OpenMode.ForRead) as Polyline; if (PL.NumberOfVertices != 4 && !PL.Closed) { ed.WriteMessage("\n选择的不是封闭的矩形!"); goto inputstart; } Point3d P1 = PL.GetPoint3dAt(0); Point3d P2 = PL.GetPoint3dAt(1); Point3d P3 = PL.GetPoint3dAt(2); Point3d P4 = PL.GetPoint3dAt(3); Vector3d V1 = P1.GetVectorTo(P2); Vector3d V2 = P2.GetVectorTo(P3); Vector3d V3 = P3.GetVectorTo(P4); Vector3d V4 = P4.GetVectorTo(P1); if (!(V1.IsPerpendicularTo(V2) && V2.IsPerpendicularTo(V3) && V3.IsPerpendicularTo(V4))) { ed.WriteMessage("\n选择的不是封闭的矩形!"); goto inputstart; } Point2d CT = new Point2d((P1.X + P3.X) / 2, (P1.Y + P3.Y) / 2); double H = 1; double W = 1; if (V1.Length > V4.Length) { H = V4.Length; W = V1.Length; } else { H = V1.Length; W = V4.Length; } Vector2d UserXaxix = new Vector2d(db.Ucsxdir.X, db.Ucsxdir.Y); Vector2d WXaxix = new Vector2d(1, 0); double TwistAngle = WXaxix.GetAngleTo(UserXaxix); if (db.Ucsxdir.Y > 0) { TwistAngle = Math.PI * 2 - WXaxix.GetAngleTo(UserXaxix); } //Matrix2d WCS2DCS = Matrix2d.Rotation(new Vector2d(1, 0).GetAngleTo(UserXaxix),new Point2d(0,0)); Matrix2d WCS2DCS = Matrix2d.Rotation(TwistAngle, new Point2d(0, 0)); Point3d UcsCenter = db.Ucsorg; //Point2d DcsCenter = new Point2d(UcsCenter.X, UcsCenter.Y).TransformBy(TransWCSToDCS); Point2d DcsCenter = CT.TransformBy(WCS2DCS); /* * ed.WriteMessage("\n计算旋转角:{0}", WXaxix.GetAngleTo(UserXaxix)); * ed.WriteMessage("\nTwistAngle:{0}", TwistAngle); * ed.WriteMessage("\nWCS的中点:{0}", CT.ToString()); * ed.WriteMessage("\nUCS的中点:{0}", new Point3d(CT.X,CT.Y,0).TransformBy(ed.CurrentUserCoordinateSystem).ToString()); * ed.WriteMessage("\nDCS的中点:{0}", DcsCenter.ToString()); */ SymbolTable VT = trans.GetObject(db.ViewTableId, OpenMode.ForWrite) as SymbolTable; if (VT.Has(viewnum.ToString())) { foreach (ObjectId viewid in VT) { ViewTableRecord VR = trans.GetObject(viewid, OpenMode.ForWrite) as ViewTableRecord; if (VR.Name == viewnum.ToString()) { VR.Erase(); break; } } } ViewTableRecord NewVr = new ViewTableRecord(); NewVr.Name = viewnum.ToString(); NewVr.CenterPoint = DcsCenter; NewVr.Height = H; NewVr.Width = W; NewVr.ViewTwist = TwistAngle; NewVr.SetUcs(db.Ucsorg, db.Ucsxdir, db.Ucsydir); VT.Add(NewVr); trans.AddNewlyCreatedDBObject(NewVr, true); //添加图层快照属性要在把view添加到数据库里后再操作,要不会报错eNoDataBase... string LayerStateName = string.Format("ACAD_VIEWS_{0}", NewVr.Name); //已有同名那就删掉 if (LayerState.HasLayerState(LayerStateName)) { LayerState.DeleteLayerState(LayerStateName); } LayerState.SaveLayerState(LayerStateName, LayerStateMasks.None, new ObjectId()); NewVr.LayerState = LayerStateName; trans.Commit(); ed.WriteMessage("\n成功创建编号为{0}的视图。", viewnum); viewnum++; counter++; } catch (Autodesk.AutoCAD.Runtime.Exception EX) { ed.WriteMessage("\n出错了!{0}", EX.ToString()); } finally { trans.Dispose(); } } } }
protected override SamplerStatus Sampler(JigPrompts prompts) { PromptPointResult promptPointResult = prompts.AcquirePoint(new JigPromptPointOptions("\r\n请指定下一点:") { Cursor = 2, BasePoint = CAD.GetPointAngle(this.point3d_0, this.double_1 / 2.0, (double)(checked (-90 * this.short_0))), UseBasePoint = true }); Point3d value = promptPointResult.Value; SamplerStatus result; if (value != this.point3d_1) { this.short_0 = 1; double num = -Math.Tan(0.39269908169872414); if (value.Y > this.point3d_0.Y) { this.short_0 = -1; num = -1.0 * num; } long num2 = checked ((long)Math.Round(Math.Min(this.double_0, this.double_1) / 5.0)); Point2d point2d; point2d..ctor(value.X, value.Y); Point2d point2d2; point2d2..ctor(this.point3d_0.X - this.double_0 / 10.0, this.point3d_0.Y - (double)this.short_0 * this.double_1 / 2.0); Point2d point2d3; point2d3..ctor(this.point3d_0.X - this.double_0 / 2.0, this.point3d_0.Y - (double)this.short_0 * this.double_1 / 2.0); Point2d point2d4; point2d4..ctor(point2d3.X + (double)num2, point2d3.Y); Point2d point2d5; point2d5..ctor(point2d3.X, point2d3.Y + (double)(checked (num2 *unchecked ((long)this.short_0)))); Point2d point2d6; point2d6..ctor(this.point3d_0.X - this.double_0 / 2.0, this.point3d_0.Y + (double)this.short_0 * this.double_1 / 2.0); Point2d point2d7; point2d7..ctor(point2d6.X + (double)num2, point2d6.Y); Point2d point2d8; point2d8..ctor(point2d6.X, point2d6.Y - (double)(checked (num2 *unchecked ((long)this.short_0)))); Point2d point2d9; point2d9..ctor(this.point3d_0.X + this.double_0 / 2.0, this.point3d_0.Y + (double)this.short_0 * this.double_1 / 2.0); Point2d point2d10; point2d10..ctor(point2d9.X - (double)num2, point2d9.Y); Point2d point2d11; point2d11..ctor(point2d9.X, point2d9.Y - (double)(checked (num2 *unchecked ((long)this.short_0)))); Point2d point2d12; point2d12..ctor(this.point3d_0.X + this.double_0 / 2.0, this.point3d_0.Y - (double)this.short_0 * this.double_1 / 2.0); Point2d point2d13; point2d13..ctor(point2d12.X - (double)num2, point2d12.Y); Point2d point2d14; point2d14..ctor(point2d12.X, point2d12.Y + (double)(checked (num2 *unchecked ((long)this.short_0)))); Point2d point2d15; point2d15..ctor(this.point3d_0.X + this.double_0 / 10.0, this.point3d_0.Y - (double)this.short_0 * this.double_1 / 2.0); this.polyline_0 = new Polyline(); this.polyline_0.AddVertexAt(0, point2d, 0.0, 0.0, 0.0); this.polyline_0.AddVertexAt(1, point2d2, 0.0, 0.0, 0.0); this.polyline_0.AddVertexAt(2, point2d4, num, 0.0, 0.0); this.polyline_0.AddVertexAt(3, point2d5, 0.0, 0.0, 0.0); this.polyline_0.AddVertexAt(4, point2d8, num, 0.0, 0.0); this.polyline_0.AddVertexAt(5, point2d7, 0.0, 0.0, 0.0); this.polyline_0.AddVertexAt(6, point2d10, num, 0.0, 0.0); this.polyline_0.AddVertexAt(7, point2d11, 0.0, 0.0, 0.0); this.polyline_0.AddVertexAt(8, point2d14, num, 0.0, 0.0); this.polyline_0.AddVertexAt(9, point2d13, 0.0, 0.0, 0.0); this.polyline_0.AddVertexAt(10, point2d15, 0.0, 0.0, 0.0); this.polyline_0.Closed = true; this.entity_0[0] = this.polyline_0; this.point3d_1 = value; result = 0; } else { result = 1; } return(result); }
public void CreateBlock() { Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor ed = doc.Editor; Transaction tr = db.TransactionManager.StartTransaction(); using (tr) { // Get the block table from the drawing BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead); // Check the block name, to see whether it's // already in use PromptStringOptions pso = new PromptStringOptions("\nEnter new block name: "); pso.AllowSpaces = true; // A variable for the block's name string blkName = ""; do { PromptResult pr = ed.GetString(pso); // Just return if the user cancelled // (will abort the transaction as we drop out of the using // statement's scope) if (pr.Status != PromptStatus.OK) { return; } try { // Validate the provided symbol table name SymbolUtilityServices.ValidateSymbolName(pr.StringResult, false); // Only set the block name if it isn't in use if (bt.Has(pr.StringResult)) { ed.WriteMessage("\nA block with this name already exists."); } else { blkName = pr.StringResult; } } catch { // An exception has been thrown, indicating the // name is invalid ed.WriteMessage("\nInvalid block name."); } } while (blkName == ""); // Create our new block table record... BlockTableRecord btr = new BlockTableRecord(); // ... and set its properties btr.Name = blkName; //input insert point PromptPointOptions ppo = new PromptPointOptions("\nSelect point to insert block"); PromptPointResult ppr = ed.GetPoint(ppo); Point3d pt = ppr.Value; // Add the new block to the block table bt.UpgradeOpen(); ObjectId btrId = bt.Add(btr); tr.AddNewlyCreatedDBObject(btr, true); // Add some lines to the block to form a square // (the entities belong directly to the block) Circle circle = new Circle(); circle.Center = pt; circle.Radius = 20; btr.AppendEntity(circle); tr.AddNewlyCreatedDBObject(circle, true); // Add a block reference to the model space BlockTableRecord ms = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite); BlockReference br = new BlockReference(Point3d.Origin, btrId); ms.AppendEntity(br); tr.AddNewlyCreatedDBObject(br, true); // Commit the transaction tr.Commit(); // Report what we've done ed.WriteMessage("\nCreated block named \"{0}\" .", blkName); } }
checkPointsToAlign() { SelectionSet ss = null; Debugg debugg = new Debugg(); DefaultTraceListener dtl = debugg.getListner(); dtl.LogFileName = @"M:\John\debug.txt"; bool exists; ObjectId idDictObject = Dict.getNamedDictionary("ObjectDict", out exists); ObjectId idDictSED = Dict.getNamedDictionary("SEDTagDict", out exists); ObjectIdCollection idsAlign = Align.getAlignmentIDs(); ss = (SelectionSet)Select.buildSSet(typeof(CogoPoint), true); ObjectId[] idsCgPnt = ss.GetObjectIds(); Dictionary <ObjectId, List <Handle> > dictM = new Dictionary <ObjectId, List <Handle> >(); double station = 0.0; double offset = 0.0; foreach (ObjectId id in idsAlign) { Alignment align = (Alignment)id.getEnt(); List <Handle> hList = new List <Handle>(); dictM.Add(id, hList); dtl.Write(string.Format("{0}\n", id.ToString())); foreach (ObjectId idCgPnt in idsCgPnt) { Point3d pnt3d = idCgPnt.getCogoPntCoordinates(); try { align.StationOffset(pnt3d.X, pnt3d.Y, ref station, ref offset); if (station >= align.StartingStation && station <= align.EndingStation) { if (System.Math.Abs(offset) < 0.01) { Handle h = idCgPnt.getHandle(); hList.Add(h); dtl.Write(string.Format("{0}\n", h.ToString())); } } } catch (System.Exception ex) { Application.ShowAlertDialog(ex.Message + " SDrain_App.cs: line: 66"); BaseObjs.writeDebug(ex.Message + " SDrain_App.cs: line: 66"); } } } //List<TypedValue[]> xrecs = Dict.getXRecs(idDictObject); //if (xrecs != null){ // foreach (TypedValue[] tvs in xrecs){ // dtl.Write(string.Format("{0}\n", tvs[2].Value.ToString())); // } //} //Xrecord xRec = null; //List<DBDictionaryEntry> entries = Dict.getEntries(idDictObject); //foreach (DBDictionaryEntry entry in entries){ // xRec = Dict.getXRec(idDictObject, entry); //} List <Handle> hListBad = new List <Handle>(); ObjectId idBR = ObjectId.Null; ss = Select.buildSSet(typeof(BlockReference), true); ObjectId[] idsSS = ss.GetObjectIds(); string idStr = idsSS[0].ToString(); idStr = idStr.Replace("(", ""); idStr = idStr.Replace(")", ""); Int64 id64 = Int64.Parse(idStr); Int32 id32 = System.Convert.ToInt32(id64); foreach (ObjectId id in idsSS) { Entity ent = (Entity)id.getEnt(); BlockReference br = (BlockReference)ent; if (br.Name.Contains("sedtag") || br.Name.Contains("sdetag")) { ResultBuffer rbBR = Dict.getXRec(idDictObject, id.ToString()); if (rbBR != null) { TypedValue[] tvsBR = rbBR.AsArray(); Handle hPnt = tvsBR.getObjectId(2).getHandle(); ResultBuffer rbPnt = Dict.getXRec(idDictSED, hPnt.ToString()); if (rbPnt != null) { TypedValue[] tvsPnt = rbPnt.AsArray(); ObjectId idAlign = tvsPnt.getObjectId(2); List <Handle> hList2 = null; dictM.TryGetValue(idAlign, out hList2); if (!hList2.Contains(hPnt)) { TypedValue[] tvsSED = new TypedValue[3]; tvsSED.SetValue(new TypedValue(1001, br.Handle.ToString()), 0); Handle hLdr = tvsBR.getObjectId(0).getHandle(); //check tvsSED.SetValue(new TypedValue(1002, hLdr), 1); tvsSED.SetValue(new TypedValue(1003, idAlign.getHandle()), 2); } else { if (tvsPnt.getObjectId(2).getHandle() != idAlign.getHandle()) { TypedValue[] tvsPntNew = new TypedValue[3]; tvsPntNew[0] = tvsPnt[0]; tvsPntNew[1] = tvsPnt[1]; tvsPntNew[2] = new TypedValue(1003, idAlign.getHandle()); } } } } else { hListBad.Add(id.getHandle()); } } } }
private double jRadius; // 半径 public CircleJig(Point3d center) : base(new Circle()) // 继承父类Circle的属性 { ((Circle)Entity).Center = center; // Enitty 转化为Cirecle 对象 复制center }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { // code for reading input parameters //declare input parameters bool iReset = false; bool iPlay = false; Point3d initPos = new Point3d(0, 0, 0); Vector3d initVel = new Vector3d(0.5, 0.5, 1); AgentEnvironment iAgentEnvironment = new AgentEnvironment(Plane.WorldXY, 50.0, 50.0, 0); BristlebotAgent iBristlebot = new BristlebotAgent(initPos, initVel); int iCount = 10; double iTimeStep = 0.01; double iNeighbourhoodRadius = 1; double iSeparationDistance = 1.0; List <Circle> iRepellers = new List <Circle>(); bool iUseParallel = false; bool iUseRTree = false; //read in input parameters DA.GetData("Reset", ref iReset); //0 DA.GetData("Play", ref iPlay); //1 DA.GetData("Environment", ref iAgentEnvironment); //2 DA.GetData("BristlebotAgent", ref iAgentEnvironment); //2 DA.GetData("Count", ref iCount); //4 DA.GetData("Timestep", ref iTimeStep); //5 DA.GetData("NeighbourhoodRadius", ref iNeighbourhoodRadius); //6 DA.GetData("SeparationDistance", ref iSeparationDistance); //10 DA.GetDataList("Repellers", iRepellers); //11 DA.GetData("UseCoresInParallel", ref iUseParallel); //12 DA.GetData("UseR-TreeSearch", ref iUseRTree); //13 if (iReset || bristlebotSystem == null) { bristlebotSystem = new BristlebotSystem(iCount, iAgentEnvironment); } else { bristlebotSystem.NeighbourhoodRadius = iNeighbourhoodRadius; bristlebotSystem.Repellers = iRepellers; bristlebotSystem.UseParallel = iUseParallel; if (iUseRTree) { bristlebotSystem.updateUsingRTree(); } else { bristlebotSystem.Update(); } if (iPlay) { ExpireSolution(true); } } List <GH_Point> positions = new List <GH_Point>(); List <GH_Vector> velocities = new List <GH_Vector>(); foreach (BristlebotAgent agent in bristlebotSystem.Agents) { positions.Add(new GH_Point(agent.Position)); velocities.Add(new GH_Vector(agent.Velocity)); } DA.SetDataList("Positions", positions); DA.SetDataList("Velocities", velocities); }
public DataTree <Brep> Generate3DBuildings(List <OSMWay> ways) { double unitScale = CommonGHProcessors.GetRhinoUnitScale(Rhino.RhinoDoc.ActiveDoc); DataTree <Brep> breps = new DataTree <Brep>(); for (int i = 0; i < ways.Count; i++) { OSMWay currentWay = ways[i]; double height = 0; // Check if there is a building heigh identified foreach (KeyValuePair <string, string> tag in currentWay.Tags) { if (tag.Key.ToLower() == "height") { try { string heightStr = tag.Value.ToLower(); if (heightStr.Contains("m")) { height = Convert.ToDouble(heightStr.Replace("m", string.Empty)) * unitScale; } else if (heightStr.Contains("\'") || heightStr.Contains("\"")) { string[] heightArr = heightStr.Split(new char[] { '\'' }); if (heightArr.Count() == 1) { height = Convert.ToDouble(heightArr[0]); } else { double ft = Convert.ToDouble(heightArr[0]); double inch = Convert.ToDouble(heightArr[1].Replace("\"", string.Empty)); ft += (inch / 12); double metric = ft * 0.30479999024640031211519001231392; height = metric * unitScale; } } else { height = Convert.ToDouble(heightStr) * unitScale; } } catch { } break; } } Vector3d heightVect = new Vector3d(0, 0, height); // Create Polylines if possible List <Polyline> boundaryCrvs = new List <Polyline>(); for (int j = 0; j < currentWay.Points.Count; j++) { List <LINE.Geometry.Point3d> pointList = currentWay.Points[j]; List <Point3d> polyLinePoints = new List <Point3d>(); foreach (LINE.Geometry.Point3d point in pointList) { try { Point3d pt = new Point3d(point.X, point.Y, point.Z); polyLinePoints.Add(pt); } catch { } } if (polyLinePoints.Count > 2) { Polyline pline = new Polyline(polyLinePoints); if (!pline.IsClosed) { pline.Add(pline.First); } //Curve crv = pline.ToNurbsCurve() as Curve; //crv.MakeClosed(0.001); boundaryCrvs.Add(pline); } } // Create the extrued masses as breps if (boundaryCrvs.Count == 1) { try { Line[] ca = boundaryCrvs[0].GetSegments(); List <Curve> crvSegments = new List <Curve>(); foreach (Line line in ca) { crvSegments.Add(line.ToNurbsCurve()); } List <Brep> unjoinedBreps = new List <Brep>(); Curve[] pc = PolyCurve.JoinCurves(crvSegments); Brep[] brepArr = Brep.CreatePlanarBreps(pc); unjoinedBreps.Add(brepArr[0]); // Add the extruded surfaces foreach (Curve crvSeg in crvSegments) { Surface srf = Surface.CreateExtrusion(crvSeg, heightVect); if (srf != null) { unjoinedBreps.Add(srf.ToBrep()); } } //Surface srf2 = Surface.CreateExtrusion(pc[0], heightVect); //Brep brep = srf2.ToBrep(); //unjoinedBreps.Add(brep); Brep top = brepArr[0].DuplicateBrep(); top.Translate(heightVect); unjoinedBreps.Add(top); Brep[] joinedBreps = Brep.JoinBreps(unjoinedBreps, 0.001); breps.Add(joinedBreps[0], new GH_Path(i, 0)); //breps.Add(brep.CapPlanarHoles(0.01), new GH_Path(i, 0)); } catch { breps.Add(null, new GH_Path(i, 0)); } } else if (boundaryCrvs.Count > 1) { try { List <Curve> crvSegments = new List <Curve>(); List <Curve> polyCurves = new List <Curve>(); foreach (Polyline pl in boundaryCrvs) { Line[] ca = pl.GetSegments(); List <Curve> tempCrvs = new List <Curve>(); foreach (Line line in ca) { tempCrvs.Add(line.ToNurbsCurve()); crvSegments.Add(line.ToNurbsCurve()); } polyCurves.Add(PolyCurve.JoinCurves(tempCrvs)[0]); } List <Brep> brepSegments = new List <Brep>(); // Create an initial brep from lofting Brep[] brepArr = Brep.CreatePlanarBreps(polyCurves); Brep baseBrep = brepArr[0]; brepSegments.Add(baseBrep); // Add the extruded surfaces foreach (Curve crvSeg in crvSegments) { Surface srf = Surface.CreateExtrusion(crvSeg, heightVect); if (srf != null) { brepSegments.Add(srf.ToBrep()); } } // move the base surface up Brep topBrep = baseBrep.DuplicateBrep(); topBrep.Translate(heightVect); brepSegments.Add(topBrep); //topBrep.Flip(); Brep[] joinedBreps = Brep.JoinBreps(brepSegments, 0.0001); //BrepSolidOrientation solidOrientation = joinedBreps[0].get_SolidOrientation(); breps.Add(joinedBreps[0], new GH_Path(i, 0)); } catch { breps.Add(null, new GH_Path(i, 0)); } } else { // single point data breps.Add(null, new GH_Path(i, 0)); } //System.Windows.Forms.MessageBox.Show("Current 3d i: " + i.ToString() + "\nBranches: " + breps.BranchCount.ToString()); } return(breps); }
public void SetPosition(Point3d position) { this.position = position; }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { Plane plane = Plane.WorldXY; double radius = 0; bool seal = false; if (!DA.GetData(0, ref plane)) { return; } if (!DA.GetData(1, ref radius)) { return; } if (!DA.GetData(2, ref seal)) { return; } double xx = plane.OriginX; double yy = plane.OriginY; double zz = plane.OriginZ; ////////////////////////////相对平面坐标 string[] mm = str.Split(new string[] { "{", "}" }, StringSplitOptions.RemoveEmptyEntries); List <string> nn = mm.ToList(); for (int i = 0; i < nn.Count; i++)//移除空项 { if (nn[i].Length < 8) { nn.RemoveAt(i); i--; } } List <int> count = new List <int>(); for (int i = 0; i < length.Length; i++)//点分组列表 { count.Add(Convert.ToInt32(length[i].ToString())); } /////////////////////////////////////////////////////////////////// double rate = radius / 146;//与默认半径的比例 List <Point3d> pts = new List <Point3d>(); for (int i = 0; i < nn.Count; i++) { string[] pt = nn[i].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); double ptx = Convert.ToDouble(pt[0]) * rate + xx; double pty = Convert.ToDouble(pt[1]) * rate + yy; double ptz = Convert.ToDouble(pt[2]) * rate + zz; Point3d point = new Point3d(ptx, pty, ptz); pts.Add(point); } ////////////////////////////////////////////////////////////////////获取点 List <Polyline> ply = new List <Polyline>(); List <Brep> bps = new List <Brep>(); for (int i = 0; i < count.Count; i++) { List <Point3d> pts2 = new List <Point3d>(); for (int j = 0; j < count[i]; j++) { pts2.Add(pts[0]); pts.RemoveAt(0); } pts2.Add(pts2[0]); Polyline pl = new Polyline(pts2); ply.Add(pl); if (seal) { bps.Add(Brep.CreatePlanarBreps(pl.ToNurbsCurve())[0]); } } if (seal) { DA.SetDataList(1, bps); } DA.SetDataList(0, ply); }