.NET

Reply
Contributor
theEntity
Posts: 21
Registered: ‎08-05-2012
Message 1 of 13 (425 Views)

.NET training labs

425 Views, 12 Replies
08-05-2012 04:19 PM

hey all.  i'll be frequenting regularly this forum from now on. asking all kinds of dumb questions.

 

like:

who made the these training labs?  http://images.autodesk.com/adsk/files/autocad_net_training0.zip

 

im having trouble with lab6

an editor.PointMonitor event triggers this sub routine called myPointMonitor

 -the lab then declare a FullSubentityPath variable = e.Context.GetPickedEntities()

 and checks IF (fullEntPath.Length) Then  

 

should their not be an argument here?

 

i get " out of bound of array " here.   and the IF statement is never executed.

 

if anyone can assist id appreciate it.

bare in mind i'm new to the autocad api  and have only indermediate exprience with vb.net

 

 

edit: sry   the IF is executed  but encounters the exception @

Dim ent As Curve = trans.GetObject(fullEntPath(0).GetObjectIds(0), OpenMode.ForRead)

 

 

*Expert Elite*
_gile
Posts: 2,086
Registered: ‎04-29-2006
Message 2 of 13 (398 Views)

Re : .NET training labs

08-05-2012 11:02 PM in reply to: theEntity

Hi,

 

Try to replace Curve with Entity:

 

Dim ent As Entity = trans.GetObject(fullEntPath(0).GetObjectIds(0), OpenMode.ForRead)

Gilles Chanteau
Contributor
theEntity
Posts: 21
Registered: ‎08-05-2012
Message 3 of 13 (390 Views)

Re : .NET training labs

08-06-2012 12:15 AM in reply to: _gile

it seems that was not the intention because further

 

 Dim pnt As Point3d = ent.GetPointAtDist(myTypedVal.Value)

GetPointAtDist is not a member of entity

 

open lab6 and run debug.. check it out , its a small download

*Expert Elite*
_gile
Posts: 2,086
Registered: ‎04-29-2006
Message 4 of 13 (388 Views)

Re : .NET training labs

08-06-2012 12:34 AM in reply to: theEntity
If (fullEntPath.Length) Then

This won't work with C# or (I think) VB with Option Strict On.

 

Try:

If (fullEntPath.Length > 0) Then
Gilles Chanteau
Contributor
theEntity
Posts: 21
Registered: ‎08-05-2012
Message 5 of 13 (380 Views)

Re : .NET training labs

08-06-2012 01:03 AM in reply to: _gile
If (fullEntPath.Length > 0) Then

was the 1st thing i tried before i came to this forum.

 

the if statement does run tho.

*Expert Elite*
_gile
Posts: 2,086
Registered: ‎04-29-2006
Message 6 of 13 (362 Views)

Re : .NET training labs

08-06-2012 09:52 AM in reply to: theEntity

Ok, I downloaded the lab and looked up into the code.

I do not know if it's your problem but an exception will occur with the "newInput" command if the cursor comes near an entity which is not a curve.

The "MyInputMonitor" code would check if the entity is a curve. Here's a way (not certain about the VB syntax):

 

replace:

' open the Entity for read, it must be derived from 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
'...

with

' open the Entity for read, try to cast it as Curve
Dim ent As Curve = TryCast(trans.GetObject(fullEntPath(0).GetObjectIds()(0), OpenMode.ForRead), Curve)
' ok, so if we are over something - then check to see if it is a curve and if it has an extension dictionary
If ent IsNot Nothing AndAlso ent.ExtensionDictionary.IsValid Then
'...

 

Gilles Chanteau
Board Manager
StephenPreston
Posts: 380
Registered: ‎05-22-2006
Message 7 of 13 (353 Views)

Re : .NET training labs

08-06-2012 10:50 AM in reply to: _gile

Oops. That would be a bug. I'll have someone update the labs with the corrected code. Sorry for the inconvenience and thanks for reporting it.

Cheers,

Stephen Preston
Autodesk Developer Network
*Expert Elite*
_gile
Posts: 2,086
Registered: ‎04-29-2006
Message 8 of 13 (347 Views)

Re : .NET training labs

08-06-2012 11:13 AM in reply to: StephenPreston

Hi Stephen,

 

There's the same 'bug' in the C# code.

 

PS: IMO, arriving to this step in the training (using event handlers) it can be assumed that the learner should know enough about debugging and type casting to correct this by himself...

Gilles Chanteau
Contributor
theEntity
Posts: 21
Registered: ‎08-05-2012
Message 9 of 13 (346 Views)

Re : .NET training labs

08-06-2012 11:16 AM in reply to: StephenPreston

ooooh..  here is the culprit himself.  :cattongue:

kudoos on making the labs , i find it very useful to fasttrack my learning. the power point is also very helpful.

 

now that i have your attention i'd like to pick your brains about dictionaries:

Can you give me a simple senario where saving data to dictionaries is useful / like what kind of data?

i reckon i can store any nessary data i need within variable memory in run time.

\\ saving data to entities seems very much like an GIS application. i rekon i can expose the dictionary in an interface to allow users to append data to entities and make autcad behave like gis software

 

hey thx _gile for taking a look.

 

 

Contributor
theEntity
Posts: 21
Registered: ‎08-05-2012
Message 10 of 13 (344 Views)

Re : .NET training labs

08-06-2012 11:18 AM in reply to: theEntity

-gile

 

the learner is learing at great pace.  forgive his ignorance

 

btw - the trycast did not correct my problem

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.