Page 1 of 1

Ruby GraphicsPath save error?

Posted: Sat Oct 04, 2014 3:59 pm
by KG_is_back
Here is the thing. I want to pass a GraphicsPath form one ruby component to another but when I save the schematic I get an error "(in method 'saveState') no _dump_data is defined for Class GraphicsPath"
I believe the problem is, that the Path cannot be saved as part of inputs and outputs (which are saved and loaded by default in ruby). I do not need to save the path, but I need it to pass from one component to another. What should I do?

Re: Ruby GraphicsPath save error?

Posted: Sun Oct 05, 2014 12:30 am
by billv
KG_is_back wrote:pass a GraphicsPath form one ruby component to another

What if you write the method inside a class like..

Code: Select all

class GraphicsPath

def rect
return [0,0,10,10]
end

end

# then in other ruby prim...

mypath = GraphicsPath.new
mypath.rect


Would this work for you ?

Re: Ruby GraphicsPath save error?

Posted: Sun Oct 05, 2014 12:57 am
by KG_is_back
billv wrote:
KG_is_back wrote:pass a GraphicsPath form one ruby component to another

What if you write the method inside a class like..

Code: Select all

class GraphicsPath

def rect
return [0,0,10,10]
end

end

# then in other ruby prim...

mypath = GraphicsPath.new
mypath.rect


Would this work for you ?


Unfortunately that would not work. The example schematic contains the path contains only one rectangle just to show the problem. The path I'm using in my original schematic contains several shapes.
But it gave me an idea oh how to fix the problem. I do not really need to save the path - I just need to prevent the error massage to show. So what if I add a dummy "_dump_data" method to graphicsPath class that simply outputs nil. That should fool the FS not to show error. And similar thing would probably be needed for loading... I'll give it a try.

Re: Ruby GraphicsPath save error?

Posted: Sun Oct 05, 2014 1:28 am
by billv
So its not viable/possible to just re write your
original inside the class and add all your shapes
inside new def's there....Ok....Hope you find right solution.

Re: Ruby GraphicsPath save error?

Posted: Sun Oct 05, 2014 1:36 am
by KG_is_back
Yes!!! IT WORKS... it is something called marshal module...has functions _dump and _load to deal the saving and loading data... some classes do not have these functions defined, so they output error. I just added "dummy" versions of these methods GraphicsPath class and errors are gone

Code: Select all

class GraphicsPath

def _dump level
end
def _load args
end

end

Re: Ruby GraphicsPath save error?

Posted: Sun Oct 05, 2014 1:56 am
by billv
Great :) ..will take another look at Mr Marshall..interesting fix..

Re: Ruby GraphicsPath save error?

Posted: Sun Oct 05, 2014 6:14 am
by RJHollins
Ahh ... the 'Marshall' routine.

Mr NuBeat has done some extensive work on this very useful function.

I think NuBeat started to help me on this over at the SM forum. For what I needed to do, this 'Marshall' technique of saving and loading configuration data simplified the entire process and array management.

I continue to thank NuBeat for this, and all his other generous help and educating :D

Re: Ruby GraphicsPath save error?

Posted: Sun Oct 05, 2014 10:04 am
by KG_is_back
RJHollins wrote:Ahh ... the 'Marshall' routine.

Mr NuBeat has done some extensive work on this very useful function.

I think NuBeat started to help me on this over at the SM forum. For what I needed to do, this 'Marshall' technique of saving and loading configuration data simplified the entire process and array management.

I continue to thank NuBeat for this, and all his other generous help and educating :D

ah yes I remember that... it was something about array of arrays, that the top array contains only pointers to the sub-arrays. when you create a copy of the top array and change the element in the sub-array both copy and original will be affected. We needed the mashall routine to create a hard copy to make the copy and original change values separately.

Re: Ruby GraphicsPath save error?

Posted: Sun Oct 05, 2014 6:53 pm
by RJHollins
One of the very handy features using the 'Marshall' routine had to do with variable sized array management. It automatically handle all those details.

Re: Ruby GraphicsPath save error?

Posted: Tue Oct 07, 2014 8:53 am
by RJHollins
I went searching for the thread[s] both here and on SM for the 'Marshal Method' ... I couldn't find it :roll:

We were doing all kinds of testing to save/load files while dealing with some strange compatiability issue ... it was a real crazy time.

If I find the threads I'll try to post them.