algorithmic modeling for Rhino
Nearly, When I Coding to create an Custom Object with Custom persist paramater. I find an very strange problerm, the strange is that you actually can not find where throw the Exception at the Code. And I set an breakpoint in the "SetFilePath" Component's SoleInstance method. But the code isn't run into the method before pupup this Component Exception. So I think It is not the plobrem with the "SetFilePath"
Component's plobrem.
And It troubled me for a long time, Could help me find what wrong with code as below, and the problerm sreenshot as below:
Notice:
The paramater is set through "set one path " menu item. and the "set one path" menu item ivoke the method of "Prompt_Plural" in Custom PersistentParam know as "PathParameter" in the below.
Plobrem screenShot:
Code ScreenShot:
Tags:
Replies are closed for this discussion.
You should override the CastTo and CastFrom methods on your goo, and handle the cases for converting to string and GH_String.
Thanks David, But I actually don't know why I must cast GH_String to GH_MyPath, I have never using GH_String In My Code, And I just as an base Class of GH_MyPath.
Er... I have no override the base Class's CastTo and CastFrom method, Wheather I override the two method and completely rewrite the two method and then The Object Will have no this PopUp Component Exception?
Can you post the code for the whole type? I don't fancy copying source code by hand from pixels on the screen.
OH, I'm So Sorry anout this, The Whole Code about the Project is post as attach file on the Attachments Section. ThankYou
HI,cughudson.you can just use GH_String for PathParamter;
Attachments:
Ah.... Thankyou.But I want override the GH_String's ToString Method, But If I use GH_String for PathParamter, The ToString is not my want, So I must Create an Custom Param derived from GH_String to override the GH_String's method with the same name
Sorry, David. But Could you tell me why come this exception, After I rewrite the CastTo and CastFrom Method?
Hi David, First,I'm so apologize to inntrupt you so frequency.
To be frankly, I need you help, and The Problerm have annony me for a long time, But could you tell me what wrong with the Code, Thankyou very much.
Sorry, missed your earlier request. Should I be looking at the PathParameter.cs and SetFilePath.cs files you attached 4 posts above this one?
Yeap, Actually,Thankyou, David.
The Code about the problerm has been post at above of this discussion by me.
the file name is "type.cs"," Param.cs "and "PathComponent.cs";
type.cs file is contain the data type definition;
Param.cs file is contain the Paramater definition we has used in PathComponent.cs
PathComponent.cs is to Create PathComponent
ThankYou.
I found the problem. Since you did not override the Duplicate() method on your GH_String derived type, that method would return a GH_String instead of your own type. This caused issues when a data tree containing your type was being duplicated.
See attached. I also cleaned up the rest of the code, and I removed all logic not vital to this problem.
I'm not entirely sure what additional functionality you're getting over just GH_String, but if your data is supposed to be something different from GH_String, I think it would be best if you didn't derive from GH_String either. I think deriving from GH_Goo<T> would be better.
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by