I’m having a small problem with copying/pasting/saving/loading my customcurveobject. What should I do to make it happen ? Currently when I copy this object with command line, it works fine. Problems start whenever I try to use clipboard or when I save the file… after loading (or actually on saving), my geometry turns into LineCurve. Does this class even supports serialization ? If not, what would be a solution ?
Public Class CustomObj
Public Overrides Function ToString() As String
Return "Custom Line"
MyBase.New(New LineCurve(New Point3d(0, 0, 0), New Point3d(1, 1, 1)))
Protected Overrides Sub OnDraw(e As Display.DrawEventArgs)
Public Overrides Function ShortDescription(plural As Boolean) As String
Return "Custom Line"
These classes don’t serialize automatically. What we did was to store data on the object’s UserDictionary and when the document is loaded, to check the existence of said data and convert it to the custom objects.
That’s what I supposed. Thanks.
Have you noticed any problems with that approach ?
No, it seems to be working fine here.
So I ended (sort of) up with developing a custom UserData attached to CustomCurveObject. The problem is that when somehow I got it to work, I started to mess around with referencing proper user data to custom curves.
Let me explain what I did and ask some questions at the same time ;
- My UserData hold only one value so far, but I want it future-proof so I will stick with that rather than with UserDictionary
- I keep reference to my UserData in CustomCurveObject… but I don’t really know if it’s even a proper way of keeping track of that information which is stored in the underlying Curve.
- Let’s say I have a curve with some UserData - is it also duplicated when I call Duplicate on the curve ? (or is it mysteriously referenced only to a new curve, or maybe it is ADDED - vide next point)
- In the UserDataList documentation it is stated :
Add : If the userdata is already in a different UserDataList, it will be removed from that list and added to this list.
Why oh why McNeel ppl you make my life so hard
- Does it mean that each GeometryBase holds it’s own UserDataList, or is it somehow stored in the Document, or Shared among GeometryBase classes ?
- If I want to replace a value in the Curve.UserData from the level of MyCustomCurve (has MyData value set previosly to MyCustomCurve.UserData.Find(CustomUserData) :
MyData = New MyCustomCurve(Value)
Does it even make sense ?
I think you make your life difficult by using user data, instead of using the user dictionary. We’ve made some extensive plugins with data on objects and have never needed the added complexity of user data, everything we want to do can be accomplished with the dictionary.
If you also switch to the dictionary, I think you find that all subsequent problems will go away…