#wrong object name?
3 messages in this thread
I have been attempting to incorportate the select.k3d script into my
move script and it almost works, except I seem to have an object name
wrong or something. I am not exactly sure how to fix it, but I am
99.9% certain it is a simple fix.
The error I get when I run it comes after it has asked me to select
the XYZ point file and which objects I want to move (with the tag
object dialog box), the it runs for a few seconds, then spews the
following message:
Object ' ' does not exist
In Line 47, statement 1
see the line with three * for which line it is referring to.
Below is the scripts as I have modified them. Everything below it in the script
is just the select.k3d script with no changes.
*******************************************************************************
**
DefPosition ObjectPosition
DIM Selected_Objects$(3000,32)
Ext$(0)= "XYZ"
Selectfile "Select XYZ node file", "", ""
If RC < 1 Then End
' a file of x,y,z data
;open "\3ds4\scripts\treetest.asc", input, #50
Open FileName$, INPUT, #50
;
' all of the selected objects get stuffed into the array called
Selected_Objects$…
;PickObjects "Please Pick Objects", Selected_Objects$, NT_OBJECT
;
;
;
; This first part is a demo driver for routines ChooseNodeExp, PickObjectsExp
PWindow 25, 40, 40, 5
gosub InitObjTag : gosub SortObjTag
;Filter=NT_SELECTED-1 : for i=1 to 10 : NodeNumber=i : gosub ObjTagNum : next i
;gosub ChooseNodeExp : if RC > 0 then GFX_Continue "Chosen Node: "+NodeName$
Filter=NT_TAGSET+NT_OBJECT : gosub ObjTagAll
gosub PickObjectsExp : if RC <1 then end
for i=1 to RC
NodeNumber=i : gosub GetSelectedObject
; GFX_Continue "Chosen Node #"+Str$(i)+": "+NodeName$
next i
if RC = 0 then end
total_objects_selected = RC
ObjectPosition.time = 0
ObjectPosition.tens = 25
ObjectPosition.cont = 25
ObjectPosition.bias = 25
ObjectPosition.easeTo = 0
ObjectPosition.easeFrom = 0
for i = 0 to total_objects_selected-1 step 1
input #50, x,y,z
' when you hit an end of file, numeric variable default to 0, while string
variable default to NULL, ie ""
if x = 0 and y = 0 and z = 0 then i = 10000: goto next_i
ObjectPosition.x = x
ObjectPosition.y = y
ObjectPosition.z = z
*** CreateKey Selected_Objects$(i), ObjectPosition ***< this line gives
the error
@next_i
next i
end
****************************************************************************
Tim,
The problem is that you are never actually storing the selected object names in
array Selected_Objects$. Also, in your second for/next loop you were
offsetting your counter by -1. Not sure why.
I did some minor cleaning up of your script, mainly just to make things more
visible. Look at the first for/next loop..
Unless another portion of your routine needs the names of the selected objects,
I wouldn't even store them in your routine. See the commented lines in the
second for/next loop.
I left the call in for SortObjTag, but with the number of objects you are
dealing with, I would highly, strongly, adamently recommend not making this
call. It's very slow, and it doesn't seem like you really need the names in
sorted order.
LAM
*****************************************************************************
DefPosition ObjectPosition DIM Selected_Objects$(3000,32)
Ext$(0)= "XYZ" Selectfile "Select XYZ node file", "", "" If RC < 1 Then End
;open a file of x,y,z data Open FileName$, INPUT, #50
PWindow 25, 40, 40, 5
;initialize variables for call to PickObjectsExp gosub InitObjTag : gosub
SortObjTag
;old line was: Filter=NT_TAGSET+NT_OBJECT : gosub ObjTagAll ;If you want all
objects, don't worry about the tagging ;new line is: Filter=NT_OBJECT gosub
PickObjectsExp : if RC <1 then end total_objects_selected = RC
;the following for/next loop can be deleted if the next for/next loop is
;modified as documented in the comments. Also delete the dimensioning of
;Selected_Objects$.
;all of the selected objects get stuffed into the array called
;Selected_Objects$… for i=1 to total_objects_selected
NodeNumber=i : gosub GetSelectedObject
Selected_Objects$(i)=NodeName$ next i
ObjectPosition.time = 0 ObjectPosition.tens = 25 ObjectPosition.cont
= 25 ObjectPosition.bias = 25 ObjectPosition.easeTo = 0
ObjectPosition.easeFrom = 0
for i = 1 to total_objects_selected step 1
input #50, x,y,z
' when you hit an end of file, numeric variable default to 0, while
' string variable default to NULL, ie ""
if x = 0 and y = 0 and z = 0 then i = 10000: goto next_i
ObjectPosition.x = x
ObjectPosition.y = y
ObjectPosition.z = z
CreateKey Selected_Objects$(i), ObjectPosition ;if you want to get rid of
first for/next loop, replace the above line with: ; NodeNumber=i : gosub
GetSelectedObject ; CreateKey NodeName$, ObjectPosition
@next_i next i
end
****************************************************************************
Thanks for the clean-up. I will give the updated script a try.