Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk 3ds® Max® / SDK / GetUserPropString mangles my MSTR.
  RSS 2.0 ATOM  

GetUserPropString mangles my MSTR.
Rate this thread
 
62589
 
Permlink of this thread  
avatar
  • Jason:.
  • Posted: 06 December 2011 02:49 PM
  • Total Posts: 17
  • Joined: 06 September 2011 07:41 PM

What is the best way to deal with Object Properties that have a blank data portions.
I am getting bad results if a Key exists and there is no data present. See below.

void myClass::GetSomeInfo(INodepointerToNode)
{
  MSTR my_BadString
;
  
MSTR my_GoodString;

  
pointerToNode->GetUserPropString("keyWithData"my_GoodString);
  
pointerToNode->GetUserPropString("keyNoData"my_BadString);


  
myClass::FillStringWithData(my_GoodString);
  
myClass::FillStringWithData(my_BadString);
  
}

If a Key exists in the object properties such as below then my_BadString becomes corrupt, and I cannot fill it with data or even test if the my_BadString.data() is NULL or pretty much anything and the my_BadString becomes a bad pointer.

Object Properties =
{

keyWithData = greatThisWorksBecauseThereIsData
keyNoData =

}



3DSMax 2012 with subscription advantage pack / Windows 7 Enterprise

Replies: 0
avatar

From 2011 SDK help:
BOOL INode::GetUserPropString(...)
Returns:
TRUE if the key was found; otherwise FALSE.

Just test return value of GetUserPropString first.



Replies: 0
avatar
  • Jason:.
  • Posted: 11 December 2011 09:48 AM

Wow at first glance I thought that I had had a bit of a dumb moment and that the answer would be that simple.

The problem is a bit harder then that though as GetUserPropString(..) will return TRUE if the Key is there, (as is the case above) but the associated value is not. ie the function returns TRUE regardless of the presence of the VALUE portion of the KEY VALUE pair as long as the KEY is there.

Perhaps I will just assume that the Key Value pair is always complete / well formed. There is just potential for the data to be altered by a user and for that alteration to be an empty string.



3DSMax 2012 with subscription advantage pack / Windows 7 Enterprise

Replies: 0
avatar

Well, I can’t say I have experience in this area, so I’m kind of guessing. Yet, have you tested my_BadString method isNull() ?
Anyway, what is your intention with FillStringWithData? Name would suggest you’d need reference to string rather than a copy.



Replies: 0
avatar
  • Jason:.
  • Posted: 11 December 2011 11:38 AM

Ok, the solution is to Resize() the buffer after checking for IsNull(). When I just tried to fill the buffer without the resize nothing would be saved I guess because there was no room for my string.

I did try a comparison with null previously but that was checking if the pointer was null not the string.

Cheers, Jake.



3DSMax 2012 with subscription advantage pack / Windows 7 Enterprise

Replies: 1
/img/forum/dark/default_avatar.png

Yeap, string handling might be a bit tricky. I’m glad, if I could be helpful.

Author: Jake Jeziorski

Replied: 12 December 2011 07:53 AM