Ruby GraphicsPath save error?

For general discussion related FlowStone
Post Reply
KG_is_back
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Ruby GraphicsPath save error?

Post 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?
Attachments
pathproblem.fsm
(321 Bytes) Downloaded 994 times
billv
Posts: 1165
Joined: Tue Aug 31, 2010 3:34 pm
Location: Australia
Contact:

Re: Ruby GraphicsPath save error?

Post 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 ?
KG_is_back
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Ruby GraphicsPath save error?

Post 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.
billv
Posts: 1165
Joined: Tue Aug 31, 2010 3:34 pm
Location: Australia
Contact:

Re: Ruby GraphicsPath save error?

Post 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.
KG_is_back
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Ruby GraphicsPath save error?

Post 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
billv
Posts: 1165
Joined: Tue Aug 31, 2010 3:34 pm
Location: Australia
Contact:

Re: Ruby GraphicsPath save error?

Post by billv »

Great :) ..will take another look at Mr Marshall..interesting fix..
RJHollins
Posts: 1573
Joined: Thu Mar 08, 2012 7:58 pm

Re: Ruby GraphicsPath save error?

Post 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
KG_is_back
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Ruby GraphicsPath save error?

Post 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.
RJHollins
Posts: 1573
Joined: Thu Mar 08, 2012 7:58 pm

Re: Ruby GraphicsPath save error?

Post 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.
RJHollins
Posts: 1573
Joined: Thu Mar 08, 2012 7:58 pm

Re: Ruby GraphicsPath save error?

Post 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.
Post Reply