FindObject() doesnt work properly
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/06/2008 at 11:32, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 10.111
Platform: Windows ;
Language(s) : C.O.F.F.E.E ;---------
Hi.I encounter strange problems using FindObject() in my script and in a COFFEE-Menu-Plugin. The code reads the string from a file containing names and referring numbers, such as Deutschland;15Italien;10Schweiz;35.......
It should find the corresponding Extrude-Nurbs named "Deustchland", "Italien" etc. and set the extrusion amount to the number assigned in the file. This works only for the first set of name and number from the file.
After this there is no object found although all names and numbers are extracted correctly when i print them in the console. These are the two functions responsible for data extraction and setting of the values. Note the recursion.>
\> MyDialog::SetValue(doc, name, value) \> { \> // var obj= SearchObject(doc, doc->GetFirstObject(), name); \> println(name); \> var obj= doc->FindObject(name); \> if(!obj) { println("no object??"); return FALSE; } \> var pos= obj->GetPosition(); \> var axis= GetItem(IDC_AXIS); \> var mode= GetItem(IDC_MODE); \> switch(axis) \> { \> case IDC_AXIS_X: \> if(mode == IDC_POSITION_ABS) obj->SetPosition(vector(value, pos.y, pos.z)); \> else if(mode == IDC_POSITION_REL) obj->SetPosition(vector(pos.x+value, pos.y, pos.z)); \> else if(mode == IDC_EXTRUDE) obj#EXTRUDEOBJECT_MOVE= vector(value, 0.0, 0.0); \> break; \> case IDC_AXIS_Y: \> if(mode == IDC_POSITION_ABS) obj->SetPosition(vector(pos.x, value, pos.z)); \> else if(mode == IDC_POSITION_REL) obj->SetPosition(vector(pos.x, pos.y+value, pos.z)); \> else if(mode == IDC_EXTRUDE) obj#EXTRUDEOBJECT_MOVE= vector(0.0, value, 0.0); \> break; \> case IDC_AXIS_Z: \> if(mode == IDC_POSITION_ABS) obj->SetPosition(vector(pos.x, pos.y, value)); \> else if(mode == IDC_POSITION_REL) obj->SetPosition(vector(pos.x, pos.y, pos.z+value)); \> else if(mode == IDC_EXTRUDE) obj#EXTRUDEOBJECT_MOVE= vector(0.0, 0.0, value); \> break; \> } \> doc->Message(MSG_UPDATE); \> EventAdd(); \> } \> \> MyDialog::GetValues(doc, content) \> { \> if(sizeof(content) <= 1) { println("Done!"); return TRUE; } \> var length= sizeof(content); \> var pos; \> pos= 0; \> var separator= ';'; \> var sep_pos= strchr(content, separator, pos); \> var name= strmid(content, pos, sep_pos); \> println("name \'", name, "\'"); \> content= strmid(content, sep_pos+1, length-sep_pos); \> length= sizeof(content); \> var value_str=""; \> var i= 0; \> for(; i<length; i++) { if(!isdigit(content[i])) break; } \> value_str= strmid(content, 0, i); \> println("value ", value_str); \> SetValue(doc, name, evaluate(value_str)); //////// set the values \> length= sizeof(content); \> content= strmid(content, i, length-sizeof(value_str)); \> GetValues(doc, content); \> } \>
Any ideas why this doesnt work?
Thanks again folks
Yakuza
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 24/06/2008 at 01:07, xxxxxxxx wrote:
in the second code function:
for(; i<length; i++) { if(!isdigit(content _)) break; }
This line will stop as the first char is not a digit, so it will always be initialised with 1 if my just woken up eyez see it right. could be the problem.
Cannot see anything else.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 01/07/2008 at 08:52, xxxxxxxx wrote:
Hi Samir.
Thanks for your reply. I solved the problem. It were the linebreaks in the textfile, they were not visible in c4d. Although the whole string was shown in one line in console there still were linbreaks. So the extracted string "Deutschland" was actually "\nDeutschland".
cheers
Yakuza