| Author |
Message |
Dan
Guest
|
Posted:
Mon Dec 20, 2004 11:14 pm Post subject:
How can I verify an ObjectId is valid in a drawing? |
|
|
/snip
'Find an object from a given objectID
Set tempObj = ThisDrawing.ObjectIdToObject(newObjsString)
/snip
This is a line I have in my code, it works great if the ObjectId is valid,
but if it is not, AutoCAD creates a Fatal Error, and crashes.
If I have a ObjectId number, how can verify it is valid without AutoCAD
crashing?
Thanks again all,
Dan
|
|
| Back to top |
|
 |
VBA
Guest
|
Posted:
Tue Dec 21, 2004 12:34 am Post subject:
Re: How can I verify an ObjectId is valid in a drawing? |
|
|
Are you using an "On Error Goto" construct?
"Dan" <danderson@nospamculpandtanner.com> wrote in message
news:41c716b4$1_2@newsprd01...
| Quote: | /snip
'Find an object from a given objectID
Set tempObj = ThisDrawing.ObjectIdToObject(newObjsString)
/snip
This is a line I have in my code, it works great if the ObjectId is valid,
but if it is not, AutoCAD creates a Fatal Error, and crashes.
If I have a ObjectId number, how can verify it is valid without AutoCAD
crashing?
Thanks again all,
Dan
|
|
|
| Back to top |
|
 |
Dan
Guest
|
Posted:
Tue Dec 21, 2004 12:50 am Post subject:
Re: How can I verify an ObjectId is valid in a drawing? |
|
|
Yes I am: On Error GoTo Err_Control
Dan
"VBA" <nospam@nowhere.com> wrote in message news:41c7294e$1_3@newsprd01...
| Quote: | Are you using an "On Error Goto" construct?
"Dan" <danderson@nospamculpandtanner.com> wrote in message
news:41c716b4$1_2@newsprd01...
/snip
'Find an object from a given objectID
Set tempObj = ThisDrawing.ObjectIdToObject(newObjsString)
/snip
This is a line I have in my code, it works great if the ObjectId is
valid,
but if it is not, AutoCAD creates a Fatal Error, and crashes.
If I have a ObjectId number, how can verify it is valid without AutoCAD
crashing?
Thanks again all,
Dan
|
|
|
| Back to top |
|
 |
Jorge Lopez
Guest
|
Posted:
Tue Dec 21, 2004 3:58 am Post subject:
Re: How can I verify an ObjectId is valid in a drawing? |
|
|
Why are you trying to determine if an ObjectID is valid? Are you storing the
ObjectID in a database for later retrieval? ObjectIDs are transient and not
persistent between drawing loads. I can look into how to do this but first I
want to make sure you aren't trying to do something you should not be doing.
Handles are persistent between drawing loads btw.
Cheers,
Jorge
"Dan" <danderson@nospamculpandtanner.com> wrote in message
news:41c716b4$1_2@newsprd01...
| Quote: | /snip
'Find an object from a given objectID
Set tempObj = ThisDrawing.ObjectIdToObject(newObjsString)
/snip
This is a line I have in my code, it works great if the ObjectId is valid,
but if it is not, AutoCAD creates a Fatal Error, and crashes.
If I have a ObjectId number, how can verify it is valid without AutoCAD
crashing?
Thanks again all,
Dan
|
|
|
| Back to top |
|
 |
Tony Tanzillo
Guest
|
Posted:
Tue Dec 21, 2004 4:04 am Post subject:
Re: How can I verify an ObjectId is valid in a drawing? |
|
|
AutoCAD shouldn't crash if you give ObjectIDToObject() an invalid
object id. But, your code below suggests you're passing a string
into the method. Are you?
Why would you need to verify if an object id is valid? If an object
is erased (or unappeneded), its object id is still valid, but this
method will generate an error nontheless.
Step back and tell us what the purpose of validating the object id is.
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005
http://www.acadxtabs.com
"Dan" <danderson@nospamculpandtanner.com> wrote in message news:41c716b4$1_2@newsprd01...
| Quote: | /snip
'Find an object from a given objectID
Set tempObj = ThisDrawing.ObjectIdToObject(newObjsString)
/snip
This is a line I have in my code, it works great if the ObjectId is valid,
but if it is not, AutoCAD creates a Fatal Error, and crashes.
If I have a ObjectId number, how can verify it is valid without AutoCAD
crashing?
Thanks again all,
Dan
|
|
|
| Back to top |
|
 |
Dan
Guest
|
Posted:
Tue Dec 21, 2004 6:05 am Post subject:
Re: How can I verify an ObjectId is valid in a drawing? |
|
|
Thanks for the assistance....
The purpose is to create a Field mapping tool.
Purpose is simply this:
There is a defined field that needs to be modified.
How does the user know where the parent of that field resides?
Solution/Tool
I have written some code to prompt the user to select desired field, then
the code reads the field expression,
then zooms to the Objectid in the expression and highlights it for the user,
for the user to make necessary modifications.
Odd thing as stated in a previous post, it works great, but there is some
anomily that can give the wrong objectid.
(See "What's wrong in code? Get Field Expression Tool thread")
If Objectid provided is not a valid ID, AutoCAD will crash when I get to
this line:
Set tempObj = ThisDrawing.ObjectIdToObject(newObjsString)
Thanks,
Dan
:
"Tony Tanzillo" <tony.tanzillo@U_KNOW_WHERE.com> wrote in message
news:41c75a84$1_3@newsprd01...
| Quote: | AutoCAD shouldn't crash if you give ObjectIDToObject() an invalid
object id. But, your code below suggests you're passing a string
into the method. Are you?
Why would you need to verify if an object id is valid? If an object
is erased (or unappeneded), its object id is still valid, but this
method will generate an error nontheless.
Step back and tell us what the purpose of validating the object id is.
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005
http://www.acadxtabs.com
"Dan" <danderson@nospamculpandtanner.com> wrote in message
news:41c716b4$1_2@newsprd01...
/snip
'Find an object from a given objectID
Set tempObj = ThisDrawing.ObjectIdToObject(newObjsString)
/snip
This is a line I have in my code, it works great if the ObjectId is
valid,
but if it is not, AutoCAD creates a Fatal Error, and crashes.
If I have a ObjectId number, how can verify it is valid without AutoCAD
crashing?
Thanks again all,
Dan
|
|
|
| Back to top |
|
 |
Tony Tanzillo
Guest
|
Posted:
Tue Dec 21, 2004 8:24 am Post subject:
Re: How can I verify an ObjectId is valid in a drawing? |
|
|
Per chance, are you using object ids that have small values?
This is a known problem. In some cases, the object referenced
by the object id is valid, but has no COM/ActiveX representation
or wrapper object, and I'm pretty sure that this may cause
the crash.
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005
http://www.acadxtabs.com
"Dan" <danderson@nospamculpandtanner.com> wrote in message news:41c776f5$1_3@newsprd01...
| Quote: | Thanks for the assistance....
The purpose is to create a Field mapping tool.
Purpose is simply this:
There is a defined field that needs to be modified.
How does the user know where the parent of that field resides?
Solution/Tool
I have written some code to prompt the user to select desired field, then
the code reads the field expression,
then zooms to the Objectid in the expression and highlights it for the user,
for the user to make necessary modifications.
Odd thing as stated in a previous post, it works great, but there is some
anomily that can give the wrong objectid.
(See "What's wrong in code? Get Field Expression Tool thread")
If Objectid provided is not a valid ID, AutoCAD will crash when I get to
this line:
Set tempObj = ThisDrawing.ObjectIdToObject(newObjsString)
Thanks,
Dan
:
"Tony Tanzillo" <tony.tanzillo@U_KNOW_WHERE.com> wrote in message
news:41c75a84$1_3@newsprd01...
AutoCAD shouldn't crash if you give ObjectIDToObject() an invalid
object id. But, your code below suggests you're passing a string
into the method. Are you?
Why would you need to verify if an object id is valid? If an object
is erased (or unappeneded), its object id is still valid, but this
method will generate an error nontheless.
Step back and tell us what the purpose of validating the object id is.
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005
http://www.acadxtabs.com
"Dan" <danderson@nospamculpandtanner.com> wrote in message
news:41c716b4$1_2@newsprd01...
/snip
'Find an object from a given objectID
Set tempObj = ThisDrawing.ObjectIdToObject(newObjsString)
/snip
This is a line I have in my code, it works great if the ObjectId is
valid,
but if it is not, AutoCAD creates a Fatal Error, and crashes.
If I have a ObjectId number, how can verify it is valid without AutoCAD
crashing?
Thanks again all,
Dan
|
|
|
| Back to top |
|
 |
Dan
Guest
|
Posted:
Thu Dec 30, 2004 1:28 am Post subject:
Re: How can I verify an ObjectId is valid in a drawing? |
|
|
still no ideas....?
"Dan" <danderson@nospamculpandtanner.com> wrote in message
news:41c85c70_2@newsprd01...
| Quote: | It looks like an ordinary id to me.
Here was my test:
I copied problematic text and field: "Test3"
Text ObjID = 2130161576
USING THE CODE (GetFieldExpression) PROVIDED,
Sub GetFieldExpression()
Dim ssetObj As AcadSelectionSet
Dim point1(0 To 2) As Double
Dim point2(0 To 2) As Double
Dim entText As AcadObject
Dim vPt As Variant
Dim text As String
Tag
On Error GoTo Err_Control
' Sub ???Not sure why TextObj needs to be present to work, delete after
Dim textObj As IAcadText2
Dim insertionPoint(0 To 2) As Double
Dim Height As Double
text = "%<\AcVar Date \f ""M/d/yyyy""%>%"
insertionPoint(0) = 2000000: insertionPoint(1) = 2000000:
insertionPoint(2)
= 0
Height = 0.5
Set textObj = ThisDrawing.ModelSpace.AddText(text, insertionPoint, Height)
'acSelectionSetLast
ThisDrawing.Application.ZoomAll
Set ssetObj = ThisDrawing.SelectionSets.Add("deletelast")
ssetObj.Select acSelectionSetLast
'MsgBox ("Selection set " & ssetObj.Name & " contains " & ssetObj.Count &
"
items")
text = textObj.FieldCode
UserForm3.Hide
ThisDrawing.Application.ZoomPrevious
ThisDrawing.Utility.GetEntity entText, vPt, vbCr & "Pick a FIELD in
drawing:"
text = entText.FieldCode
UserForm3.TextBox1 = text
ThisDrawing.Application.ZoomAll
' Erase the objects in the selection set
ssetObj.Erase
ThisDrawing.Application.ZoomPrevious
UserForm3.Show
ThisDrawing.SelectionSets.Item("deletelast").Delete
Exit_Here:
Exit Sub
Err_Control:
MsgBox "This OBJECT FIELD Entity's Expression could not be found. " &
vbCrLf
& "Verify it is not inside a dimension or table.", vbOKOnly + vbQuestion,
"CT-Error"
ssetObj.Erase
ThisDrawing.SelectionSets.Item("deletelast").Delete
Exit Sub
End Sub
WITH THIS FIELD I GET:
%<\AcObjProp Object(2117824080).TextString \f "%bl2">%
Notice, "2117824080" is not the correct Objectid and I cant figure out
why?
I created a new field linked to the text, and it works properly:
USING THE CODE (GetFieldExpression) PROVIDED,
WITH THIS FIELD I GET:
%<\AcObjProp Object(2130161576).TextString \f %bl2>%
IF YOU USE THE CODE (MapField) ON THIS FIELD, YOU WILL GET
A FATAL ERROR, AND AUTOCAD WILL CRASH.
????
This works well, but when ACAD comes across a bad objectid, a complete
crash
does nobady any good.
So I was hoping to build in some kind of verification first, or at least
figure out why.
Thankd,
Dan
"Tony Tanzillo" <tony.tanzillo@U_KNOW_WHERE.com> wrote in message
news:41c797fd$1_3@newsprd01...
Per chance, are you using object ids that have small values?
This is a known problem. In some cases, the object referenced
by the object id is valid, but has no COM/ActiveX representation
or wrapper object, and I'm pretty sure that this may cause
the crash.
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005
http://www.acadxtabs.com
"Dan" <danderson@nospamculpandtanner.com> wrote in message
news:41c776f5$1_3@newsprd01...
Thanks for the assistance....
The purpose is to create a Field mapping tool.
Purpose is simply this:
There is a defined field that needs to be modified.
How does the user know where the parent of that field resides?
Solution/Tool
I have written some code to prompt the user to select desired field,
then
the code reads the field expression,
then zooms to the Objectid in the expression and highlights it for the
user,
for the user to make necessary modifications.
Odd thing as stated in a previous post, it works great, but there is
some
anomily that can give the wrong objectid.
(See "What's wrong in code? Get Field Expression Tool thread")
If Objectid provided is not a valid ID, AutoCAD will crash when I get
to
this line:
Set tempObj = ThisDrawing.ObjectIdToObject(newObjsString)
Thanks,
Dan
:
"Tony Tanzillo" <tony.tanzillo@U_KNOW_WHERE.com> wrote in message
news:41c75a84$1_3@newsprd01...
AutoCAD shouldn't crash if you give ObjectIDToObject() an invalid
object id. But, your code below suggests you're passing a string
into the method. Are you?
Why would you need to verify if an object id is valid? If an object
is erased (or unappeneded), its object id is still valid, but this
method will generate an error nontheless.
Step back and tell us what the purpose of validating the object id
is.
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005
http://www.acadxtabs.com
"Dan" <danderson@nospamculpandtanner.com> wrote in message
news:41c716b4$1_2@newsprd01...
/snip
'Find an object from a given objectID
Set tempObj = ThisDrawing.ObjectIdToObject(newObjsString)
/snip
This is a line I have in my code, it works great if the ObjectId is
valid,
but if it is not, AutoCAD creates a Fatal Error, and crashes.
If I have a ObjectId number, how can verify it is valid without
AutoCAD
crashing?
Thanks again all,
Dan
|
|
|
| Back to top |
|
 |
|
|
|
|