本文整理汇总了C#中ObjectId.GetObject方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectId.GetObject方法的具体用法?C# ObjectId.GetObject怎么用?C# ObjectId.GetObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectId
的用法示例。
在下文中一共展示了ObjectId.GetObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddAttrToBlockRef
protected AttributeReference AddAttrToBlockRef(BlockReference blRef, ObjectId idAttrDef, string textString)
{
using (var attrDef = idAttrDef.GetObject(OpenMode.ForRead, false, true) as AttributeDefinition)
{
var attrRef = new AttributeReference();
attrRef.SetAttributeFromBlock(attrDef, blRef.BlockTransform);
attrRef.TextString = textString;
blRef.AttributeCollection.AppendAttribute(attrRef);
t.AddNewlyCreatedDBObject(attrRef, true);
return attrRef;
}
}
示例2: convertText
private Extents3d convertText(ObjectId idDbText, int angle, Point3d pos, bool isMarkOrPaint)
{
Extents3d resVal = new Extents3d();
if (idDbText.IsNull)
{
return resVal;
}
using (var text = idDbText.GetObject(OpenMode.ForWrite, false, true) as DBText)
{
text.TextStyleId = idDbText.Database.GetTextStylePIK();
double lenMax = panelBtr.HeightByTile;
// Аннотативность???
if (panelBtr.HeightByTile >= 2000)
{
text.Position = pos;
double angleRadian = Math.PI * angle / 180.0;
text.Rotation = angleRadian;
}
else
{
lenMax = panelBtr.ExtentsNoEnd.MaxPoint.X - panelBtr.ExtentsNoEnd.MinPoint.X;
// Небольшая корректировка положения текста
if (isMarkOrPaint)
{
text.Position = new Point3d(10, 315,0);
}
else
{
text.Position = new Point3d(10, 65, 0);
}
}
// Проверка длины текста - если не вписывается в размер панели то сжатие
ControlTextLength(text, lenMax);
resVal = text.GeometricExtents;
}
return resVal;
}
示例3: AddData
/// <summary>
/// Agrega información a un Xrecord
/// </summary>
/// <param name="recId">El id del Xrecord.</param>
/// <param name="data">La información a guardar</param>
public void AddData(ObjectId recId, params String[] data)
{
Database db = AcadApp.DocumentManager.MdiActiveDocument.Database;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
try
{
Xrecord oldX = (Xrecord)recId.GetObject(OpenMode.ForWrite);
List<TypedValue> typedValueData = new List<TypedValue>();
for (int i = 0; i < data.Length; i++)
typedValueData.Add(new TypedValue((int)DxfCode.Text, data[i]));
oldX.Data = new ResultBuffer(typedValueData.ToArray());
tr.Commit();
}
catch (System.Exception exc)
{
ed.WriteMessage(exc.Message);
tr.Abort();
}
}
}
示例4: exploreDictionary
private static void exploreDictionary(ObjectId idDict, ref StringBuilder sbInfo, string tab = " ")
{
var entry = idDict.GetObject(OpenMode.ForRead);
if (entry is DBDictionary)
{
var dict = entry as DBDictionary;
foreach (var item in dict)
{
sbInfo.AppendLine($"{tab}{item.Key}");
exploreDictionary(item.Value, ref sbInfo, tab+" ");
}
}
else if (entry is Xrecord)
{
var xrec = entry as Xrecord;
foreach (var item in xrec)
{
sbInfo.AppendLine($"{tab} {getTypeCodeName(item.TypeCode)} = {item.Value}");
}
}
}
示例5: Extract
/// <summary>
/// Obtiene información de un Xrecord
/// </summary>
/// <param name="xId">El id de un Xrecord</param>
/// <returns>La información del registro</returns>
public string[] Extract(ObjectId xId)
{
Database db = AcadApp.DocumentManager.MdiActiveDocument.Database;
List<string> values = new List<string>();
using (Transaction tr = db.TransactionManager.StartTransaction())
{
try
{
Xrecord xRec = (Xrecord)xId.GetObject(OpenMode.ForWrite);
TypedValue[] tps = xRec.Data.AsArray();
foreach (TypedValue tp in tps)
values.Add((string)tp.Value);
}
catch (System.Exception exc)
{
ed.WriteMessage(exc.Message);
tr.Abort();
}
}
return values.ToArray();
}
示例6: AddXRecord
/// <summary>
/// Agrega un xrecord en un diccionario
/// </summary>
/// <param name="xName">El nombre del registro</param>
/// <param name="dicId">El id del diccionario.</param>
/// <returns>El object id del nuevo registro</returns>
public ObjectId AddXRecord(ObjectId dicId, String xName)
{
Database db = AcadApp.DocumentManager.MdiActiveDocument.Database;
ObjectId id = new ObjectId();
using (Transaction tr = db.TransactionManager.StartTransaction())
{
try
{
DBDictionary dic = (DBDictionary)dicId.GetObject(OpenMode.ForWrite);
Xrecord x = new Xrecord();
dic.SetAt(xName, x);
tr.AddNewlyCreatedDBObject(x, true);
id = x.ObjectId;
tr.Commit();
}
catch (System.Exception exc)
{
ed.WriteMessage(exc.Message);
tr.Abort();
}
}
return id;
}
示例7: ChangeBasePointInRedefineBase
public void ChangeBasePointInRedefineBase(Database dbExt, ObjectId idBtr)
{
var btr = idBtr.GetObject( OpenMode.ForRead) as BlockTableRecord;
var idsBlRefs =btr.GetBlockReferenceIds(true, false);
foreach (ObjectId idBlRef in idsBlRefs)
{
var blRef = idBlRef.GetObject( OpenMode.ForWrite) as BlockReference;
if (blRef == null) continue;
blRef.TransformBy(MatChangeBasePoint);
}
if (btr.IsDynamicBlock && !btr.IsAnonymous)
{
var idsBtrAnonym =btr.GetAnonymousBlockIds();
foreach (ObjectId idBtrAnonym in idsBtrAnonym)
{
ChangeBasePointInRedefineBase(dbExt, idBtrAnonym);
}
}
}
示例8: replaceText
private ObjectId replaceText(ObjectId idBdText, BlockTableRecord btr)
{
using (var text = idBdText.GetObject(OpenMode.ForWrite, false, true) as DBText)
{
using (var copyText = text.Clone() as DBText)
{
text.Erase();
return btr.AppendEntity(copyText);
}
}
}
示例9: GetInsertionPoint
public Point3d GetInsertionPoint(ObjectId BRid, string attributeName)
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Database db = doc.Database;
Point3d insertionPoint = new Point3d();
using (Transaction tr = doc.TransactionManager.StartTransaction())
{
BlockReference br = BRid.GetObject(OpenMode.ForRead) as BlockReference;
if (br != null)
{
AttributeCollection arColl = br.AttributeCollection;
foreach (ObjectId arID in arColl)
{
AttributeReference ar = tr.GetObject(arID, OpenMode.ForRead) as AttributeReference;
if (ar != null)
{
if (ar.Tag == attributeName)
{
insertionPoint = ar.Position;
}
}
}
}
}
return insertionPoint;
}
示例10: Transform
public static void Transform(Matrix3d matrix, ObjectId entId)
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
Database dwg = Application.DocumentManager.MdiActiveDocument.Database;
using (Transaction tr = dwg.TransactionManager.StartTransaction())
{
try
{
Entity ent = entId.GetObject(OpenMode.ForWrite) as Entity;
ent.TransformBy(matrix);
tr.Commit();
}
catch (Exception exc)
{
ed.WriteMessage(exc.Message);
tr.Abort();
}
}
}
示例11: OpenEnity
public static Entity OpenEnity(ObjectId id)
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
Database dwg = Application.DocumentManager.MdiActiveDocument.Database;
//La variable de tipo entidad
Entity ent = null;
using (Transaction tr = dwg.TransactionManager.StartTransaction())
{
try
{
//Abrir entidad
ent = id.GetObject(OpenMode.ForRead) as Entity;
tr.Commit();
}
catch (Exception exc)
{
ed.WriteMessage(exc.Message);
tr.Abort();
}
}
//el valor de retorno
return ent;
}
示例12: eraseEntInBlock
private void eraseEntInBlock(ObjectId idBtr)
{
using (var btr = idBtr.GetObject(OpenMode.ForWrite) as BlockTableRecord)
{
foreach (ObjectId idEnt in btr)
{
using (var ent = idEnt.GetObject(OpenMode.ForWrite, false, true) as Entity)
{
ent.Erase();
}
}
}
}
示例13: GetLine
public static Line GetLine(ObjectId lineID)
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Database db = doc.Database;
Line ln;
// check the current value of the br and see if it is null - it should not be
using (Transaction tr = doc.TransactionManager.StartTransaction())
{
ln = lineID.GetObject(OpenMode.ForRead) as Line;
if (ln != null)
{
return ln;
}
// throws an exception if the point does not have any value
else
{
throw new Autodesk.AutoCAD.Runtime.Exception(ErrorStatus.NullObjectId, "The block reference returned is null - probably because the objectID you passed into the GetBlockReference method was not a blockReference.");
}
}
return ln;
}
示例14: GetInsertionPointOfBlockReference
///////////the below has proven obsolete
//////public static BlockReference GetBlockReference(ObjectId BRid)
//////{
////// Document doc = Application.DocumentManager.MdiActiveDocument;
////// Editor ed = doc.Editor;
////// Database db = doc.Database;
////// BlockReference br;
////// // check the current value of the br and see if it is null - it should not be
////// using (Transaction tr = doc.TransactionManager.StartTransaction())
////// {
////// br = BRid.GetObject(OpenMode.ForRead) as BlockReference;
////// if (br != null)
////// {
////// return br;
////// }
////// // throws an exception if the point does not have any value
////// else
////// {
////// throw new Autodesk.AutoCAD.Runtime.Exception(ErrorStatus.NullObjectId, "The block reference returned is null - probably because the objectID you passed into the GetBlockReference method was not a blockReference.");
////// }
////// }
////// return br;
//////}
public static Point3d GetInsertionPointOfBlockReference(ObjectId BRid)
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Database db = doc.Database;
Point3d insertionPoint = new Point3d();
using (Transaction tr = doc.TransactionManager.StartTransaction())
{
BlockReference br = BRid.GetObject(OpenMode.ForRead) as BlockReference;
if (br != null)
{
insertionPoint = br.Position;
}
}
// throws an exception if the point does not have any value
if (insertionPoint.IsEqualTo(new Point3d()))
{
throw new Autodesk.AutoCAD.Runtime.Exception(ErrorStatus.InvalidDxf3dPoint, "The block reference does not have an insertion point. Probably the objectID you passed into the GetInsertionPointOfBlockReference method is not in fact a blockReference id.");
}
return insertionPoint;
}
示例15: Get
/// <summary>
/// Obtiene un diccionario o un registro, contenido en otro diccionario.
/// Si el id es de una entidad, el diccionario abrir será el de extensión
/// </summary>
/// <param name="dName">El nombre del diccionario</param>
/// <param name="objId">El id del objeto</param>
/// <returns>El object id del diccionario seleccionado</returns>
public ObjectId Get(ObjectId objId, String dName)
{
Database db = AcadApp.DocumentManager.MdiActiveDocument.Database;
ObjectId id = new ObjectId();
using (Transaction tr = db.TransactionManager.StartTransaction())
{
try
{
DBObject obj = objId.GetObject(OpenMode.ForRead);
DBDictionary dic = null;
if (obj is Entity && (obj as Entity).ExtensionDictionary.IsValid)
dic = (DBDictionary)(obj as Entity).ExtensionDictionary.GetObject(OpenMode.ForWrite);
else if (obj is DBDictionary)
dic = (DBDictionary)objId.GetObject(OpenMode.ForRead);
if (dic != null)
id = dic.GetAt(dName);
tr.Commit();
}
catch (System.Exception exc)
{
ed.WriteMessage(exc.Message);
tr.Abort();
}
}
return id;
}