Initialize the spline control in a Python tag?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 30/06/2012 at 16:33, xxxxxxxx wrote:
I've only used the SplineGUI at a very basic level
and it looks like this. (It makes an ease in out curve,
I haven't looked yet to set a linear spline, love to know)
But basically, you make the spline gui in the res file and
then fill it with your curve in the init.In res file:
// myTAGPLUGIN res CONTAINER myTAGPLUGIN { NAME myTAGPLUGIN; INCLUDE Texpression; GROUP MY_GROUP { SPLINE FOOCURVE { MINSIZE_H 120; MINSIZE_V 90; } } }
And in myTAGPLUGIN.pyp file
import c4d import os from c4d import plugins, utils as u, bitmaps, Vector as v, documents from c4d.utils import SplineHelp class myTAGPLUGIN(plugins.TagData) : def Init(self, mytagplugin) : self.InitAttr(mytagplugin, c4d.SplineData, [c4d. FOOCURVE]) icurve = mytagplugin[c4d. FOOCURVE] icurve.SetRange(0.0, 1.0, 0.01, 0.0, 1.0, 0.01) icurve.InsertKnot(1,1,0) # End icurve.InsertKnot(0,1,0) # Start mytagplugin[c4d. FOOCURVE] = icurve return True def Execute(self,mytag,doc,op,bt,priority,flags) thespline = mytag[c4d. FOOCURVE] pos = thespline.GetPoint(0.6).y print pos return True #Then the register part.
Cheers
Lennart -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 01/07/2012 at 06:50, xxxxxxxx wrote:
I strongly suggest you download the C++ SDK docs as well. They have a useful index/search frame which makes it a lot easier to find what you want. For example, in the C++ docs if you type 'spline' into the search box the first thing you hit is 'SPLINE (description element)' which is probably what you're after. If you do that in the Python docs you get a long, long list of everything with 'spline' in its name. The one you want then is near the bottom of that list - c4d.gui.SplineCustomGui'.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 01/07/2012 at 08:07, xxxxxxxx wrote:
First thanks to spedler, yes I have the C++ SDK, but have not used it before now. It is a great tip to look there, indeed. However, my plugin does not work properly, for some reason.Here:
GROUP PULSEEMITTERSETTINGS
{
SPLINE FOOSPLINE {GRIDSIZE_V 2;}
}
Regardless of what I type in here, it is either ignored, or - believe it or not - makes C4D freeze so that I have to kill it using task manager in Windows. can you make this work? Does what you tyupe in here really have any influence on the Spline control?
And thank you too Lennart, it was a great help to me, now I somehow got it working. But there are still things I do not uderstand.
This:
[c4d. FOOCURVE]
In my plugin, the values I have defined in the *.h file are not recognized. I have to either redefine them in the pyp file like this:
FOOCURVE = 12345
self.InitAttr(mytagplugin, c4d.SplineData, FOOCURVE)
or type the value directly in like this:
self.InitAttr(mytagplugin, c4d.SplineData, 12345)
Why is it that you can access values defined in the *.h file, and I not?
Then, constants that I would guess are defined somewhere inside the C4D system are not recognized, like this:
icurve.InsertKnot(0,0, SPLINE_KNOT_FLAG_NO_HORIZ_MOVE)
icurve.InsertKnot(0,0, c4d.SPLINE_KNOT_FLAG_NO_HORIZ_MOVE)
they are mentioned in the Python docs, but are flagged as unknown when I execute the code. I had to experiment to find out that
SPLINE_KNOT_FLAG_NO_HORIZ_MOVE = 32
SPLINE_KNOT_FLAG_NO_VERT_MOVE = 64
Is this normal, that those constants are not accessible?
_
Lennart:
> I haven't looked yet to set a linear spline, love to know)
_This will do it, at least it looks like that here to me:
icurve.MakeLinearSplineLinear(-1)
Ok, your help is very much appreciated. I am slooooooooooowly making progress, like swimming in molasses
-Ingvar -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 01/07/2012 at 08:23, xxxxxxxx wrote:
I don't know if this will help you out or not.
But I have an R13 SplineGUI example posted on my plugins site:https://sites.google.com/site/scottayersmedia/plugins-ScottA
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 01/07/2012 at 08:34, xxxxxxxx wrote:
Originally posted by xxxxxxxx
However, my plugin does not work properly, for some reason.Here:GROUP PULSEEMITTERSETTINGS{ SPLINE FOOSPLINE {GRIDSIZE_V 2;}}Regardless of what I type in here, it is either ignored, or - believe it or not - makes C4D freeze so that I have to kill it using task manager in Windows. can you make this work? Does what you tyupe in here really have any influence on the Spline control?
The .res file affects the appearance of the control and sets some limits on it. So yes, it makes a real difference to the control but doesn't initialise the control or set any default values.
Whatever you type in the control parameters shouldn't hang Cinema. What normally happens when you make a mistake in the .res file (and it's easy to do - Cinema is *very* picky about the syntax) you get an error message as soon as you invoke the plugin in Cinema. Usually it tells you something like 'Error in reading resource file line 10' and you have to figure out what you did wrong. I don't think Python plugins would behave any differently.
So I don't know why the plug hangs but it probably isn't the .res file. I don't know if you can step through the code in debug mode, as you can if you use C++. If you can do that you can see exactly where the problem is, which makes it a lot easier. There is a Python interactive debugger - pdb, I think it is - but whether you can use it within Cinema, you'll need to look into.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 01/07/2012 at 08:48, xxxxxxxx wrote:
Hi ScottA, yes, it helps a lot!
Your code is different. And I also realize there is a lot to learn in Python, this:
self.sd.SetRange(xmin=0, xmax=100, xsteps=1..
is very unfamiliar to me, unless I am creating an object in C#
I will study your code with great interest later!
In the mean time.. there is more I do not uderstand, why does this work:
icurve = mytagplugin[SOME_ID]
icurve.DoSomething()
mytagplugin[SOME_ID] = icurveand not this:
mytagplugin[SOME_ID].DoSomething()
In the programming languages I have used so far, both would work
-Ingvar -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 01/07/2012 at 09:04, xxxxxxxx wrote:
@ingvarai:
This behaviour is API dependent and doesn't have anything to do with the programming language. For the latter example to work, it would require that the __getitem__ method ([] syntax) would return the real reference to the object. When it doesn't work this way, it means that the item-access via [] returns a copy of the object that is internally used.Try these two examples:
class SomeClass(object) : def __init__(self, x) : self.x = x class Container(object) : def __init__(self) : self.obj = SomeClass(9999) def __getitem__(self, name) : if name == "obj": return self.obj else: raise KeyError c = Container() c["obj"].x = 0 print c.obj.x
class SomeClass(object) : def __init__(self, x) : self.x = x class Container(object) : def __init__(self) : self.obj = SomeClass(9999) def __getitem__(self, name) : if name == "obj": # a copy of the instance return SomeClass(self.obj.x) else: raise KeyError c = Container() c["obj"].x = 0 print c.obj.x
In the first example, you will see the value of the x attribute has changed to zero. But in the latter example, it is still unchanged, being 9999.
-Nik
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 01/07/2012 at 09:49, xxxxxxxx wrote:
Spedler,
it may not neccesarily freeze, but in any case it does not respond properly because the error message (just like you say) keeps popping up so I have to kill it.
I have tried to change some of the parameters. But the spline control looks exactly the same, regardless. And I restart C4D between each change. Right now it does not mean anything, the default spline control is fine as it is. But I am trying to understand how the whole plugin business is assembled and screwed together, that is why I experiment with so many settings and values.
-Ingvar -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 01/07/2012 at 09:55, xxxxxxxx wrote:
Originally posted by xxxxxxxx
@ingvarai:
This behaviour is API dependent and doesn't have anything to do with the programming language.Nik,
I realized this shortly after having posted my message. Foolish of me. The roblem is, in other languages I hav had no problems understanding this, but in Python, I often have no clue about what object I really have at hand, to do something to. It is a trial / error approach, for me.
You help is invaluable, I will study the code.
-Ingvar -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 01/07/2012 at 11:56, xxxxxxxx wrote:
Originally posted by xxxxxxxx
Spedler,
it may not neccesarily freeze, but in any case it does not respond properly because the error message (just like you say) keeps popping up so I have to kill it.
-Ingvar
You don't have to do kill Cinema if all you're getting is that message. Believe me, I've done this many times! What you do is:
* when the error message box appears, hit Esc and it will go away
* if it comes back again, repeat step 1
* DON'T move the mouse as Cinema will redisplay the error
* wait until Cinema gets tired of showing you that box and then hit Alt-F4
* you can then click OK and Cinema will exit - no need to force kill -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 01/07/2012 at 12:09, xxxxxxxx wrote:
Originally posted by xxxxxxxx
* you can then click OK and Cinema will exit - no need to force kill
Ok, thanks
I am of the impatient kind, probably. And killing it does mot do any harm, it will rise again
-Ingvar