Sorry if I offend you, this was not at all my intention (appologies for my poor English too).
The TryCast() method try to cast the DBObject returned by GetObject() in the specified type (Curve) and returns Nothing if the cast fails.
Then this is checked with the "IsNot Nothing" expression:
If ent IsNot Nothing AndAlso ent.ExtensionDictionary.IsValid Then
This works fine for me and correct the 'bug' I reported.
If you still have a problem, please tell how it occurs (which command is running and what you're doing in the autoCAD Editor) and which code line fires the exception.
About Dictionaries, they're usefull to store data within the Database (NOD children) or within a DBObject (extension dictionaries). These data will be available after closing and re-opening the drawing.
yes thanks _gile . no offence taken
i learn myself and have only the forum to help if i get stuck. i understand casting but the solution is more apparent for you because you have lots of experience
i made the change you suggest and it seems to validate correctly now..
Another way (cheaper because the entity type is checked befor opening it) is to use the ObjectId.ObjectClass property:
Public Sub MyInputMonitor(ByVal sender As Object, ByVal e As PointMonitorEventArgs) ' first lets check what is under the Cursor Dim fullEntPath() As FullSubentityPath = e.Context.GetPickedEntities() ' create a RXClass instance for the Curve class Dim curveClass As RXClass = RXClass.GetClass(GetType(Curve)) ' check if there's something under the cursor and if it's derived from Curve If fullEntPath.Length > 0 AndAlso _ fullEntPath(0).GetObjectIds(0).ObjectClass.IsDeriv
edFrom(curveClass) Then ' start a transaction Dim trans As Transaction = Application.DocumentManager.MdiActiveDocument.Data base.TransactionManager.StartTransaction Try ' open the Entity for read, we already know it's a Curve Dim ent As Curve = trans.GetObject(fullEntPath(0).GetObjectIds(0), OpenMode.ForRead) ' ok, so if we are over something - then check to see if it has an extension dictionary If (ent.ExtensionDictionary.IsValid) Then ' ...
Access a broad range of knowledge to help get the most out of your products and services.