Ejemplo n.º 1
0
            public LayerInfo(_AcDb.LayerTableRecord ltr, _AcDb.Transaction trans)
            {
                OldLayer       = ltr.Name;
                NewLayer       = "";
                _ColorO        = ltr.Color;
                Color          = ColorToString();
                _LineTypeO     = ltr.LinetypeObjectId;
                _LineType      = Engine.GetNameFromLinetypeOid(ltr.LinetypeObjectId, trans);
                _LineWeightO   = ltr.LineWeight;
                LineWeight     = LineWeightToString();
                _TransparencyO = ltr.Transparency;
                if (_TransparencyO != default(_AcCm.Transparency))
                {
                    Transparency = Engine.AlphaToTransparenz(_TransparencyO.Alpha).ToString(CultureInfo.InvariantCulture);
                }
                else
                {
                    Transparency = string.Empty;
                }
                if (ltr.IsPlottable)
                {
                    Plot = "Ja";
                }
                else
                {
                    Plot = "Nein";
                }

                Description = ltr.Description;
            }
Ejemplo n.º 2
0
        private _AcDb.ObjectId CreateNewLayer(_AcAp.Document doc, _AcDb.Database db)
        {
            using (_AcDb.Transaction trans = doc.TransactionManager.StartTransaction())
            {
                try
                {
                    string           layerName = "MyTest";
                    _AcDb.LayerTable layTb     = trans.GetObject(db.LayerTableId, _AcDb.OpenMode.ForRead) as _AcDb.LayerTable;
                    using (_AcDb.LayerTableRecord acLyrTblRec = new _AcDb.LayerTableRecord())
                    {
                        // Assign the layer a name
                        acLyrTblRec.Name = layerName;

                        // Upgrade the Layer table for write
                        layTb.UpgradeOpen();


                        // Append the new layer to the Layer table and the transaction
                        layTb.Add(acLyrTblRec);
                        trans.AddNewlyCreatedDBObject(acLyrTblRec, true);


                        int transparenz = 10;

                        Byte alpha            = TransparenzToAlpha(transparenz);
                        _AcCm.Transparency tr = new _AcCm.Transparency(alpha);
                        acLyrTblRec.Transparency = tr;

                        _AcCm.Color col = _AcCm.Color.FromColorIndex(_AcCm.ColorMethod.ByColor, 2);
                        //_AcCm.Color col = _AcCm.Color.FromRgb(10, 20, 30);
                        acLyrTblRec.Color = col;

                        _AcDb.ObjectId ltOid = GetLinetypeFromName("Continuous", trans, db);
                        if (!ltOid.IsNull)
                        {
                            acLyrTblRec.LinetypeObjectId = ltOid;
                        }

                        _AcDb.LineWeight lw = _AcDb.LineWeight.LineWeight030;
                        acLyrTblRec.LineWeight = lw;

                        // ???
                        //acLyrTblRec.PlotStyleName = "hugo";

                        acLyrTblRec.Description = "My new Layer";

                        return(acLyrTblRec.ObjectId);
                    }
                }
                finally
                {
                    trans.Commit();
                }
            }
        }
Ejemplo n.º 3
0
 private static void FehlerLineOrHatchPoly(_AcDb.ObjectId oid, string layer, int red, int green, int blue, _AcDb.TransactionManager tm, _AcGe.Point3d?label)
 {
     if (label.HasValue)
     {
         _AcCm.Color col = _AcCm.Color.FromRgb((byte)red, (byte)green, (byte)blue);
         Plan2Ext.Globs.InsertFehlerLines(new List <_AcGe.Point3d> {
             label.Value
         }, layer, 50, Math.PI * 1.25, col);
     }
     else
     {
         HatchPoly(oid, layer, red, green, blue, tm);
     }
 }
Ejemplo n.º 4
0
            private void StringToColor()
            {
                if (string.IsNullOrEmpty(_Color))
                {
                    _Errors = _Errors + string.Format(CultureInfo.CurrentCulture, "\nFehler in Eintrag für Layer '{0}': Es ist keine Farbe festgelegt!", OldLayer);
                    return;
                }

                var vals = _Color.Split(new char[] { '/' });

                if (vals.Length != 1 && vals.Length != 3)
                {
                    _Errors = _Errors + string.Format(CultureInfo.CurrentCulture, "\nUngültiger Eintrag für Farbe für Layer '{0}': {1}", OldLayer, _Color);
                    return;
                }

                if (vals.Length == 1)
                {
                    byte index;
                    if (!GetColorInt(vals[0], out index))
                    {
                        return;
                    }

                    _ColorO = _AcCm.Color.FromColorIndex(_AcCm.ColorMethod.ByColor, index);
                }
                else
                {
                    // rgb
                    byte rIndex, gIndex, bIndex;
                    if (!GetColorInt(vals[0], out rIndex))
                    {
                        return;
                    }
                    if (!GetColorInt(vals[1], out gIndex))
                    {
                        return;
                    }
                    if (!GetColorInt(vals[2], out bIndex))
                    {
                        return;
                    }

                    _ColorO = _AcCm.Color.FromRgb(rIndex, gIndex, bIndex);
                }
            }