예제 #1
0
 /// <summary>
 /// Gets all layer IDs.
 /// </summary>
 /// <param name="db">The database.</param>
 /// <returns>The layer IDs.</returns>
 public static ObjectId[] GetAllLayerIds(Database db = null)
 {
     return(DbHelper.GetSymbolTableRecords((db ?? HostApplicationServices.WorkingDatabase).LayerTableId));
 }
예제 #2
0
 /// <summary>
 /// Gets all block names.
 /// </summary>
 /// <param name="db">The database.</param>
 /// <returns>The block name array.</returns>
 public static string[] GetAllBlockNames(Database db = null)
 {
     return(DbHelper.GetSymbolTableRecordNames((db ?? HostApplicationServices.WorkingDatabase).BlockTableId));
 }
예제 #3
0
 public static void AffirmRegApp(params string[] appNames) // newly 20130122
 {
     DbHelper.AffirmRegApp(HostApplicationServices.WorkingDatabase, appNames);
 }
예제 #4
0
        public static void PolyTrimExtend() // mod 20130228
        {
            double epsilon = Interaction.GetValue("\nEpsilon", _polyTrimExtendEpsilon);

            if (double.IsNaN(epsilon))
            {
                return;
            }
            _polyTrimExtendEpsilon = epsilon;

            var visibleLayers = DbHelper
                                .GetAllLayerIds()
                                .QOpenForRead <LayerTableRecord>()
                                .Where(layer => !layer.IsHidden && !layer.IsFrozen && !layer.IsOff)
                                .Select(layer => layer.Name)
                                .ToList();

            var ids = Interaction
                      .GetSelection("\nSelect polyline", "LWPOLYLINE")
                      .QWhere(pline => visibleLayers.Contains(pline.Layer) && pline.Visible)
                      .ToArray(); // newly 20130729

            var pm = new ProgressMeter();

            pm.Start("Processing...");
            pm.SetLimit(ids.Length);
            ids.QOpenForWrite <Polyline>(list =>
            {
                foreach (var poly in list)
                {
                    int[] indices = { 0, poly.NumberOfVertices - 1 };
                    foreach (int index in indices)
                    {
                        var end = poly.GetPoint3dAt(index);
                        foreach (var poly1 in list)
                        {
                            if (poly1 != poly)
                            {
                                var closest  = poly1.GetClosestPointTo(end, false);
                                double dist  = closest.DistanceTo(end);
                                double dist1 = poly1.StartPoint.DistanceTo(end);
                                double dist2 = poly1.EndPoint.DistanceTo(end);

                                double distance = poly1.GetDistToPoint(end);
                                if (poly1.GetDistToPoint(end) > 0)
                                {
                                    if (dist1 <= dist2 && dist1 <= dist && dist1 < epsilon)
                                    {
                                        poly.SetPointAt(index, new Point2d(poly1.StartPoint.X, poly1.StartPoint.Y));
                                    }
                                    else if (dist2 <= dist1 && dist2 <= dist && dist2 < epsilon)
                                    {
                                        poly.SetPointAt(index, new Point2d(poly1.EndPoint.X, poly1.EndPoint.Y));
                                    }
                                    else if (dist <= dist1 && dist <= dist2 && dist < epsilon)
                                    {
                                        poly.SetPointAt(index, new Point2d(closest.X, closest.Y));
                                    }
                                }
                            }
                        }
                    }
                    pm.MeterProgress();
                }
            });
            pm.Stop();
        }