TheSwamp
Code Red => .NET => Topic started by: Andrey Bushman on August 04, 2010, 02:57:55 AM
-
Hi to all.
How can I work with instances of ImpObject, ImpEntity and ImpDBObject?
MS Visual Studio 2010 can't find info about it classes via Object Browser (browse all components): search not found result.
-
I think those are the raw pointers and are marked private.
-
I create RText object (via "_rtext" command) and run it code:
[CommandMethod(ns, "type", CommandFlags.Modal)]
public void ShowType()
{
Document dwg = acad.DocumentManager.MdiActiveDocument;
PromptEntityResult result = ed.GetEntity("\nSelect entity: ");
if (result.Status == PromptStatus.OK)
{
using (Transaction t = dwg.TransactionManager.StartTransaction())
{
DBObject x = t.GetObject(result.ObjectId, OpenMode.ForRead);
Type type = x.GetType();
ed.WriteMessage(string.Format("\nType: '{0}'", type.ToString()));
ed.WriteMessage(string.Format("\nIsPublic: '{0}'", type.IsPublic));
ed.WriteMessage(string.Format("\nAssembly: '{0}'\n", type.Assembly.FullName));
ed.WriteMessage(new string('*', 30));
ed.WriteMessage("\n");
PropertyInfo[] props = type.GetProperties().OrderBy(n => n.Name).ToArray();
Dictionary<string, object> dict = new Dictionary<string, object>();
foreach (PropertyInfo item in props)
{
object value;
try
{
value = item.GetValue(x, null);
}
catch (System.Exception e)
{
value = string.Format("Exception: '{0}'", e.Message);
}
dict.Add(string.Format("{0} [{1}]", item.Name, item.PropertyType), value);
ed.WriteMessage(string.Format("\n\tProperty: '{0}';\tType: '{1}';\tValue.ToString: '{2}'",
item.Name, item.PropertyType, value));
}
}
}
}
Result:
Command: netload
Command: bush.type
Select entity:
Type: 'Autodesk.AutoCAD.DatabaseServices.ImpEntity'
IsPublic: 'False'
Assembly: 'acdbmgd, Version=17.2.0.0, Culture=neutral, PublicKeyToken=null'
******************************
Property: 'AcadObject'; Type: 'System.Object'; Value.ToString:
'System.__ComObject'
Property: 'Annotative'; Type:
'Autodesk.AutoCAD.DatabaseServices.AnnotativeStates'; Value.ToString:
'NotApplicable'
Property: 'AutoDelete'; Type: 'System.Boolean'; Value.ToString: 'False'
Property: 'BlockId'; Type: 'Autodesk.AutoCAD.DatabaseServices.ObjectId';
Value.ToString: '(2128920264)'
Property: 'BlockName'; Type: 'System.String'; Value.ToString:
'*Paper_Space'
Property: 'CastShadows'; Type: 'System.Boolean'; Value.ToString: 'True'
Property: 'ClassID'; Type: 'System.Guid'; Value.ToString:
'b0e62a6f-1a3e-4417-8d1d-7c52caff839a'
Property: 'CloneMeForDragging'; Type: 'System.Boolean';
Value.ToString: 'True'
Property: 'CollisionType'; Type:
'Autodesk.AutoCAD.DatabaseServices.CollisionType'; Value.ToString: 'Solid'
Property: 'Color'; Type: 'Autodesk.AutoCAD.Colors.Color'; Value.ToString:
'BYLAYER'
Property: 'ColorIndex'; Type: 'System.Int32'; Value.ToString: '256'
Property: 'CompoundObjectTransform'; Type:
'Autodesk.AutoCAD.Geometry.Matrix3d'; Value.ToString: 'Exception:
'Exception has been thrown by the target of an invocation.''
Property: 'Database'; Type: 'Autodesk.AutoCAD.DatabaseServices.Database';
Value.ToString: 'Autodesk.AutoCAD.DatabaseServices.Database'
Property: 'Drawable'; Type: 'Autodesk.AutoCAD.GraphicsInterface.Drawable';
Value.ToString: 'Autodesk.AutoCAD.DatabaseServices.ImpEntity'
Property: 'DrawableType'; Type:
'Autodesk.AutoCAD.GraphicsInterface.DrawableType'; Value.ToString:
'Geometry'
Property: 'Ecs'; Type: 'Autodesk.AutoCAD.Geometry.Matrix3d';
Value.ToString: '((1,0,0,0),(0,1,0,0),(0,0,1,0),(0,0,0,1))'
Property: 'EntityColor'; Type: 'Autodesk.AutoCAD.Colors.EntityColor';
Value.ToString: 'Autodesk.AutoCAD.Colors.EntityColor'
Property: 'ExtensionDictionary'; Type:
'Autodesk.AutoCAD.DatabaseServices.ObjectId'; Value.ToString: '(0)'
Property: 'ForceAnnoAllVisible'; Type: 'System.Boolean';
Value.ToString: 'True'
Property: 'GeometricExtents'; Type:
'Autodesk.AutoCAD.DatabaseServices.Extents3d'; Value.ToString:
'((210.037799342435,66.0012581218959,0),(477.4941836172,82.8746177019484,0))'
Property: 'Handle'; Type: 'Autodesk.AutoCAD.DatabaseServices.Handle';
Value.ToString: '2E5'
Property: 'HasFields'; Type: 'System.Boolean'; Value.ToString: 'False'
Property: 'HasSaveVersionOverride'; Type: 'System.Boolean';
Value.ToString: 'False'
Property: 'Hyperlinks'; Type:
'Autodesk.AutoCAD.DatabaseServices.HyperLinkCollection'; Value.ToString:
'Autodesk.AutoCAD.DatabaseServices.HyperLinkCollection'
Property: 'Id'; Type: 'Autodesk.AutoCAD.DatabaseServices.ObjectId';
Value.ToString: '(2128926440)'
Property: 'IsAProxy'; Type: 'System.Boolean'; Value.ToString: 'False'
Property: 'IsCancelling'; Type: 'System.Boolean'; Value.ToString:
'False'
Property: 'IsDisposed'; Type: 'System.Boolean'; Value.ToString: 'False'
Property: 'IsErased'; Type: 'System.Boolean'; Value.ToString: 'False'
Property: 'IsEraseStatusToggled'; Type: 'System.Boolean';
Value.ToString: 'False'
Property: 'IsModified'; Type: 'System.Boolean'; Value.ToString: 'False'
Property: 'IsModifiedGraphics'; Type: 'System.Boolean';
Value.ToString: 'False'
Property: 'IsModifiedXData'; Type: 'System.Boolean'; Value.ToString:
'False'
Property: 'IsNewObject'; Type: 'System.Boolean'; Value.ToString:
'False'
Property: 'IsNotifyEnabled'; Type: 'System.Boolean'; Value.ToString:
'False'
Property: 'IsNotifying'; Type: 'System.Boolean'; Value.ToString:
'False'
Property: 'IsObjectIdsInFlux'; Type: 'System.Boolean'; Value.ToString:
'False'
Property: 'IsPersistent'; Type: 'System.Boolean'; Value.ToString:
'True'
Property: 'IsPlanar'; Type: 'System.Boolean'; Value.ToString: 'False'
Property: 'IsReadEnabled'; Type: 'System.Boolean'; Value.ToString:
'True'
Property: 'IsReallyClosing'; Type: 'System.Boolean'; Value.ToString:
'False'
Property: 'IsTransactionResident'; Type: 'System.Boolean'; Value.ToString:
'True'
Property: 'IsUndoing'; Type: 'System.Boolean'; Value.ToString: 'False'
Property: 'IsWriteEnabled'; Type: 'System.Boolean'; Value.ToString: 'False'
Property: 'Layer'; Type: 'System.String'; Value.ToString: 'Видовые
экраны'
Property: 'LayerId'; Type: 'Autodesk.AutoCAD.DatabaseServices.ObjectId';
Value.ToString: '(2128920464)'
Property: 'Linetype'; Type: 'System.String'; Value.ToString: 'ByLayer'
Property: 'LinetypeId'; Type: 'Autodesk.AutoCAD.DatabaseServices.ObjectId';
Value.ToString: '(2128920160)'
Property: 'LinetypeScale'; Type: 'System.Double'; Value.ToString: '1'
Property: 'LineWeight'; Type:
'Autodesk.AutoCAD.DatabaseServices.LineWeight'; Value.ToString: 'ByLayer'
Property: 'Material'; Type: 'System.String'; Value.ToString: 'ByLayer'
Property: 'MaterialId'; Type: 'Autodesk.AutoCAD.DatabaseServices.ObjectId';
Value.ToString: '(2128919688)'
Property: 'MaterialMapper'; Type: 'Autodesk.AutoCAD.GraphicsInterface.Mapper';
Value.ToString: ''
Property: 'MergeStyle'; Type:
'Autodesk.AutoCAD.DatabaseServices.DuplicateRecordCloning'; Value.ToString:
'Ignore'
Property: 'ObjectBirthVersion'; Type:
'Autodesk.AutoCAD.DatabaseServices.FullDwgVersion'; Value.ToString:
'AC1014,Release0'
Property: 'ObjectId'; Type: 'Autodesk.AutoCAD.DatabaseServices.ObjectId';
Value.ToString: '(2128926440)'
Property: 'OwnerId'; Type: 'Autodesk.AutoCAD.DatabaseServices.ObjectId';
Value.ToString: '(2128920264)'
Property: 'PaperOrientation'; Type:
'Autodesk.AutoCAD.DatabaseServices.PaperOrientationStates'; Value.ToString:
'NotApplicable'
Property: 'PlotStyleName'; Type: 'System.String'; Value.ToString:
'ByLayer'
Property: 'PlotStyleNameId'; Type:
'Autodesk.AutoCAD.DatabaseServices.PlotStyleDescriptor'; Value.ToString:
'((0),PlotStyleNameByLayer)'
Property: 'ReceiveShadows'; Type: 'System.Boolean'; Value.ToString: 'True'
Property: 'Transparency'; Type: 'Autodesk.AutoCAD.Colors.Transparency';
Value.ToString: '(0)'
Property: 'UndoFiler'; Type: 'Autodesk.AutoCAD.DatabaseServices.DwgFiler';
Value.ToString: ''
Property: 'UnmanagedObject'; Type: 'System.IntPtr'; Value.ToString:
'2129843056'
Property: 'Visible'; Type: 'System.Boolean'; Value.ToString: 'True'
Property: 'XData'; Type:
'Autodesk.AutoCAD.DatabaseServices.ResultBuffer'; Value.ToString: ''
I want find property, which specify Text Style for it instance, but I not find it.
Via AutoCAD Property Window I can change Text Style for it object, but I need do it via .net.
I think that this object has connection with instance of MText or DBText, but I can not find it.
-
Select entity:
Type: 'Autodesk.AutoCAD.DatabaseServices.ImpEntity'
IsPublic: 'False'
Assembly: 'acdbmgd, Version=17.2.0.0, Culture=neutral, PublicKeyToken=null'
******************************
Via MS VS 2010 Object Browser:
Assembly:
(http://habreffect.ru/files/ef9/7aa58b2f9/04.08.png)
I find "Imp.."-types:
(http://habreffect.ru/files/ba4/cab7c6fcd/04.08-1.png)
but I not see them...
-
Actually, they are marked internal, That may be the reason why your browser does not pick them up. Have a look at them in reflector.
-
Actually, they are marked internal, That may be the reason why your browser does not pick them up. Have a look at them in reflector.
Thank you.
I thought what "Show hidden types and members" will show me all internal types in MS VS 2010 Object Browser...
-
Those are what vertical objects look like to the base Autocad managed code. In order to cast the object to its full type, you also need to reference the managed libraries of the appropriate vertical product. And note that not all objects are available in the managed libraries of vertical products - for example, the managed API to Civil 3D is still very incomplete. There are a lot of things that can only be accessed via the COM interops. That involves getting the AcadObject from your ImpDBObject and casting it as required, and requires you to reference the interops for the appropriate vertical product.
-
..... and requires you to reference the interops for the appropriate vertical product.
Which, in this case, I don't believe is possible. RTEXT is an Express Tools custom object and I haven't found any COM interops for ET.