VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Acadobject and Acadentity

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
2371 Views, 5 Replies

Acadobject and Acadentity

hi,

here is the example from acad vba help,

Dim returnObj As AcadObject Dim basePnt As Variant On Error
Resume Next ' The following example waits for a selection from the
userRETRY: ThisDrawing.Utility.GetEntity returnObj, basePnt, "Select an
object" -------------------------------------------------------------------w
hy not Dim returnObj As Acadentity,thanks
5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: Anonymous

No reason as far as I'm concerned
I always use AcadEntity then check for
If TypeOf oEnt is DesiredType Then
DoSomethingWith oEnt
End if

also instead of On Error Resume Next you might consider something like the
following

PickSomething: 'line label so we can return if we missed the object
On Error GoTo MissedPick '(or whatever label you prefer)
ThisDrawing.Utility.GetEntity oEnt, basePnt, "Select an
object"
On Error GoTo 0 'reset error handling for rest of routine

'rest of routine here ....

'then exit section
ExitHere:
'do whatever cleanup...etc
Exit Sub/Funciton

'error section after normal exit
'error lable later in program
MissedPick:
If UserEscaped Then 'assuming you have a user escaped function to test
escape key press
'do whatever..probably
GoTo ExitHere

Else

'do something else
'maybe user just missed the pick and wants to retry
GoTo PickSomething
End if

End Sub/Function

just my 2c
more than you asked but what the heck...
:-)


"youngman" wrote in message
news:5235363@discussion.autodesk.com...
hi,

here is the example from acad vba help,

Dim returnObj As AcadObject Dim basePnt As Variant On Error
Resume Next ' The following example waits for a selection from the
userRETRY: ThisDrawing.Utility.GetEntity returnObj, basePnt, "Select an
object" -------------------------------------------------------------------w
hy not Dim returnObj As Acadentity,thanks
Message 3 of 6
Anonymous
in reply to: Anonymous

Thanks for your answer.
but no error occurs here while running the sample sub i posted

when dose error occur, for confusing AcadEntity with Acadobject

thanks a lot
-------------------------------------




"MP" wrote in message
news:5235386@discussion.autodesk.com...
No reason as far as I'm concerned
I always use AcadEntity then check for
If TypeOf oEnt is DesiredType Then
DoSomethingWith oEnt
End if

also instead of On Error Resume Next you might consider something like the
following

PickSomething: 'line label so we can return if we missed the object
On Error GoTo MissedPick '(or whatever label you prefer)
ThisDrawing.Utility.GetEntity oEnt, basePnt, "Select an
object"
On Error GoTo 0 'reset error handling for rest of routine

'rest of routine here ....

'then exit section
ExitHere:
'do whatever cleanup...etc
Exit Sub/Funciton

'error section after normal exit
'error lable later in program
MissedPick:
If UserEscaped Then 'assuming you have a user escaped function to test
escape key press
'do whatever..probably
GoTo ExitHere

Else

'do something else
'maybe user just missed the pick and wants to retry
GoTo PickSomething
End if

End Sub/Function

just my 2c
more than you asked but what the heck...
:-)


"youngman" wrote in message
news:5235363@discussion.autodesk.com...
hi,

here is the example from acad vba help,

Dim returnObj As AcadObject Dim basePnt As Variant On Error
Resume Next ' The following example waits for a selection from the
userRETRY: ThisDrawing.Utility.GetEntity returnObj, basePnt, "Select an
object" -------------------------------------------------------------------w
hy not Dim returnObj As Acadentity,thanks
Message 4 of 6
Anonymous
in reply to: Anonymous

AcadEntities are objects you can draw on the screen. AcadObjects
are objects such as layers. Don't use an AcadObject for what you
know will be an AcadEntity.

"youngman" wrote in message
news:5235548@discussion.autodesk.com...
Thanks for your answer.
but no error occurs here while running the sample sub i posted

when dose error occur, for confusing AcadEntity with Acadobject

thanks a lot
-------------------------------------




"MP" wrote in message
news:5235386@discussion.autodesk.com...
No reason as far as I'm concerned
I always use AcadEntity then check for
If TypeOf oEnt is DesiredType Then
DoSomethingWith oEnt
End if

also instead of On Error Resume Next you might consider something like the
following

PickSomething: 'line label so we can return if we missed the object
On Error GoTo MissedPick '(or whatever label you prefer)
ThisDrawing.Utility.GetEntity oEnt, basePnt, "Select an
object"
On Error GoTo 0 'reset error handling for rest of routine

'rest of routine here ....

'then exit section
ExitHere:
'do whatever cleanup...etc
Exit Sub/Funciton

'error section after normal exit
'error lable later in program
MissedPick:
If UserEscaped Then 'assuming you have a user escaped function to test
escape key press
'do whatever..probably
GoTo ExitHere

Else

'do something else
'maybe user just missed the pick and wants to retry
GoTo PickSomething
End if

End Sub/Function

just my 2c
more than you asked but what the heck...
:-)


"youngman" wrote in message
news:5235363@discussion.autodesk.com...
hi,

here is the example from acad vba help,

Dim returnObj As AcadObject Dim basePnt As Variant On Error
Resume Next ' The following example waits for a selection from the
userRETRY: ThisDrawing.Utility.GetEntity returnObj, basePnt, "Select an
object" -------------------------------------------------------------------w
hy not Dim returnObj As Acadentity,thanks
Message 5 of 6
Anonymous
in reply to: Anonymous

Hi youngman,

There is no error.
The topic is Early binding versus Late binding
Early binding is said to be more efficient...and you get Intellisense(list
of properties displayed in ide as you are writing the code)
do a google search on early binding or late binding and you'll get all the
poop on that.
:-)
There's no problem using either Object or Entity...except for the
intellisense you might get

Decaring an object as closely as you know it to be is early binding....
Declaring it as Object is late binding...you figure out later at run time
what it is...
by using and If TypeOf oObject is AcadSomethingSpecific Then...etc

Speaking in general terms...
AcadObject is the base class from which all other (acad) classes derive.
AcadEntity is a class derived from AcadObject ... so all entities are
objects but all objects are not necessarily entities...
AcadLine is a class derived from AcadEntity...etc etc

eg. Dim oLine as AcadLine... now you get all the properties for a line
displayed when you enter oLine(.)
(oLine with a period following it ... and before you type anything
else)...(Intellisense)

If you Dim oLine as AcadObject
you get all the properties common to an Object when you do oLine(.)

If you Dim oLine as AcadEntity you get all the properties available to an
Entity when you go oLine(.)

In any case oLine is whatever it is... if it's a circle and you access
properties available to a Line you get an error...if it's a Line you're good
to go...

get it?

:-)



"youngman" wrote in message
news:5235548@discussion.autodesk.com...
Thanks for your answer.
but no error occurs here while running the sample sub i posted

when dose error occur, for confusing AcadEntity with Acadobject

thanks a lot
-------------------------------------
Message 6 of 6
Anonymous
in reply to: Anonymous

Oh,Thanks,MP
you make the topic so clear for me,

thanks a lot,

also thanks to Paul Richardson,

best regards




"MP" wrote in message
news:5235712@discussion.autodesk.com...
Hi youngman,

There is no error.
The topic is Early binding versus Late binding
Early binding is said to be more efficient...and you get Intellisense(list
of properties displayed in ide as you are writing the code)
do a google search on early binding or late binding and you'll get all the
poop on that.
:-)
There's no problem using either Object or Entity...except for the
intellisense you might get

Decaring an object as closely as you know it to be is early binding....
Declaring it as Object is late binding...you figure out later at run time
what it is...
by using and If TypeOf oObject is AcadSomethingSpecific Then...etc

Speaking in general terms...
AcadObject is the base class from which all other (acad) classes derive.
AcadEntity is a class derived from AcadObject ... so all entities are
objects but all objects are not necessarily entities...
AcadLine is a class derived from AcadEntity...etc etc

eg. Dim oLine as AcadLine... now you get all the properties for a line
displayed when you enter oLine(.)
(oLine with a period following it ... and before you type anything
else)...(Intellisense)

If you Dim oLine as AcadObject
you get all the properties common to an Object when you do oLine(.)

If you Dim oLine as AcadEntity you get all the properties available to an
Entity when you go oLine(.)

In any case oLine is whatever it is... if it's a circle and you access
properties available to a Line you get an error...if it's a Line you're good
to go...

get it?

:-)



"youngman" wrote in message
news:5235548@discussion.autodesk.com...
Thanks for your answer.
but no error occurs here while running the sample sub i posted

when dose error occur, for confusing AcadEntity with Acadobject

thanks a lot
-------------------------------------

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

Post to forums  

Autodesk Design & Make Report

”Boost