.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

acadentity in vb and Vb.net

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
sivaulagu
1026 Views, 2 Replies

acadentity in vb and Vb.net

previously i was using vb6 to automate drawings in autocad,

but now i've switched to vb.net and i'm facing lot many problem wen i use option strict and explicit to ON.

i've used

dim cadEnt as acdentity

i can get

cadEnt.startpoint

cadEnt.objectname

cadEnt.coordinates

in vb6 startpoint was variant datatype

 

 

but in vb.net i couldnt get

cadEnt.startpoint

cadEnt.coordinates

wat is it in Vb.net

2 REPLIES 2
Message 2 of 3
Alfred.NESWADBA
in reply to: sivaulagu

Hi,

 

as long as you use Option Strict (without any exceptions) late-binding would be disallowed. Look at this screenshot, if you set STRICT to ON ==> latebinding will raise an error.

 

And one more word to that: set the option as global for you project within the project-properties and not within the code-file(s).

 

Having set that you would not get compiled your code

dim cadEnt as acdentity

i can get

cadEnt.startpoint

Because the object of type "AcadEntity" does not have a property called "StartPoint" (as AcadEntity can reference any geometry-objects, something like AcadCircle or AcadHatch or ....)

 

If you have a line and want to get it's startpoint you have to use a variable of type AcadLine

If you have a polyline and want to have it's vertices you have to check what type of polyline it is (LWPoly, 2D-Poly, 3D-Poly) and have to use this type to declare the variable.

 

Of course ... you can remove now option strict and all will be as you mentioned "I have a object from any type, give me the start point" ==> but as long as this object does not have a start point the code will crash.

Even if you have a perfect error handling the crash uses a lot of time, so a lot of performance.

 

The big disadvantage of having option strict on is that you have to write more code.

The big advantage of having option strict on is your code won't crash because it would even not get compiled. So you see possible problems within your code just while writing it, not if a user selects the wrong object type and then AutoCAD is away with some greetings like "unhandled exception" at the customer.

 

HTH, - alfred -

 

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 3 of 3
sivaulagu
in reply to: Alfred.NESWADBA

s i want to keep option strict on....

tats my boss order...

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost