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; }
private void SetLineWeight() { _LineWeightO = _AcDb.LineWeight.ByLineWeightDefault; if (string.IsNullOrEmpty(_LineWeight)) { return; } double d; if (!double.TryParse(_LineWeight, NumberStyles.Any, CultureInfo.InvariantCulture, out d)) { _Errors = _Errors + string.Format(CultureInfo.CurrentCulture, "\nUngültiger Eintrag für Linienstärke für Layer '{0}': {1}", OldLayer, _LineWeight); return; } d = d * 100.0; int val = (int)Math.Floor(d); string cmpVal = "LineWeight" + val.ToString().PadLeft(3, '0'); foreach (var e in Enum.GetValues(typeof(_AcDb.LineWeight))) { if (cmpVal == e.ToString()) { _LineWeightO = (_AcDb.LineWeight)e; return; } } _Errors = _Errors + string.Format(CultureInfo.CurrentCulture, "\nUngültiger Eintrag für Linienstärke für Layer '{0}': {1}", OldLayer, _LineWeight); }
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(); } } }