-
Posts
2,189 -
Joined
-
Last visited
-
Days Won
66
Content Type
Profiles
Blogs
Forums
Gallery
Pipeline Tools
3D Wiki
Plugin List
Store
Downloads
Everything posted by jed
-
XPresso is quite flexible with data eg an int or float '1' can be interpreted as a bool true or even the string character '1'. This can get you into sloppy habits that throws up errors when writing code eg Python is often quite strict with data types - I'd imagine COFFEE is also strict.
-
I'm not a COFFEE user (I use Python), but AFAIK in some programming languages you have to declare variables before they can be used - int, float, bool etc. Maybe this is what the error message means. In Python, you just use vars without declaration. Switching between sliders (or whatever) in XPresso sounds like a job for the condition node, where the switch input selects which of the inputs is routed to the output. The default data type is real, but can be changed to almost anything eg color, material, object etc.
-
Python has a ton of string formatting, here's a simple way to pad with '0' def main(): global X X = format(num, '.2f') X = X.zfill(6) 1st line rounds num to 2 decimal places and converts to string, with any trailing zero(s) 2nd line pads string from left with zero to max length 6 chars incl decimal point so 2.5 outputs 002.50 etc https://www.dropbox.com/s/gluudv9bca3ndew/zeropy.c4d?dl=1
-
There's a few ways, but here's my take, treating the number as a string. I used an XPresso preset to get 2 decimal places (with zeros), then used the string length to add the correct number of leading zeros. https://www.dropbox.com/s/ms77ebv9fmkpil1/zeros.c4d?dl=1
-
maybe start a new thread on that
-
I've just noticed you're on R14 - I'm on R18, but I don't know if this could make your Python act differently. I don't get this - are you checking for actual errors in the console ? empty lines don't seem to cause me any errors - look in console doc.SearchObject is designed to look for objects by name, if you really must have multiple objects with the same name you can use obj = doc.GetFirstObject() obj = doc.GetFirstObject().GetDown().GetNext() etc where down and next have same meanings as per iteration nodes (but this could break if you move stuff around). You can also link to an object in the hierarchy, and use down, next from there. Although I don't use it, I think op refers to the object a Python tag is on in the hierarchy ie if instead of using a XP Python node, you had all your code in a Python tag on a cube, op would be that cube. if the node input ports had different variable names, should be OK. I think I'd find it confusing having a lot of objects with the same name. I use C4D's renaming function and AutoRename from here to bulk name stuff eg thing.01, thing.02, thing.03 etc. The code thing is one of the buttons alongside Bold etc. Will read other questions and get back to you later.
-
This makes a cube visible when link is present https://www.dropbox.com/s/arqibkx1hi8p7hb/linktransfer2.c4d?dl=1
-
I think this does it, link is python node input from Null A link (ie Null B) import c4d #Welcome to the world of Python def main(): null_A = doc.SearchObject('Null A') if link: link[c4d.ID_USERDATA,1] = null_A[c4d.ID_USERDATA,2] link[c4d.ID_USERDATA,2] = null_A[c4d.ID_USERDATA,3] link[c4d.ID_USERDATA,3] = null_A[c4d.ID_USERDATA,4] I used if link because get yellow node error if no link present https://www.dropbox.com/s/uqrkqtyt64bjlna/linktransfer.c4d?dl=1 no guarantees - I'm also a bit of a Python novice edit - to get the correct userdata syntax, I just typed in null_A and dragged the relevant name in from the GUI.
-
Here's a rangemapper with this ease-ease spline - the spline represents input as X 0 - 1, and output as Y 0 - 1. You make points by ctrl-click - make sure start, end are on 0, 1 etc. Upper and lower must be clamped, or RM will calculate an output when outside the range. I used frame, but I think secs would also be OK https://www.dropbox.com/s/489z0asxthr9nl6/easemapper.c4d?dl=1 edit: just ease in, starts at 0 https://www.dropbox.com/s/sqcvar61wgg92yh/easein.c4d?dl=1
-
Yes it would be useful - that's what the rangemapper is. Can you explain the difference between what you are describing and this - utils boxstep does this in Python, or you could write your own with if, elif, else etc but that is just re-inventing the wheel.
-
I'm still not sure why XPresso rangemap doesn't do what you want - it has spline control. There's a Python equivalent Boxstep and an eased version Smoothstep - both map to 0 - 1 details (utils clamp just clamps). I noticed your Python maxoutput is 100 - you do realise that 0-100% for spherify (or anything) is actually 0-1 decimal ? Also GetActiveDocument is not required since doc is a built-in variable.
-
It's not very clear what you mean by clamp step by step - your file is already proportional between F25 and F50. Do you mean 100% in that range and 0% outside ? In XPresso that's just xpresso version https://www.dropbox.com/s/kju18ew7gbko25t/testxp.c4d?dl=1 python version https://www.dropbox.com/s/lf4mr4usmz1j5u6/testpy.c4d?dl=1 more info required . . .
-
If you just need to tweak the settings whilst setting up your scene, you could always 'tear off' the panel by clicking the + icon - you can have as many of these as you like
-
You are mapping 2D to 1D, so you need some trig. If you divide the spline point data Yt / Xt this gives you the tangent of the angle of the spline. Taking the atan of this gives you the actual angle. Dividing by 90 gives a %, take that from 1 and you have a number for the bias. https://www.dropbox.com/s/kbt0smfdeeso6ti/mapping.c4d?dl=1 maybe . . .
-
Can I just add that, unlike a lot of the free 3D models that are online (eg cars, trucks), the Turbosquid drones I bought were the correct C4D format, had sensible hierarchy with English names (ditto the mats) with all the axes centered and aligned - including the propellers, camera etc. Just need a bit of XPresso math to make them go.
-
I'm sure a lot of you guys have used Turbosquid in the past, but last night I decided to try them out for the 1st time - I bought a couple of quite decent quadcopter drone things for about 25 Euro. The thing that made me laugh though, was when I clicked 'buy' and a warning popped up reminding me I was buying a c4d model not an actual item. I had visions of someone googling 'remote control helicopter' eg for a childs Xmas present, finding a nice one for $400 at TS, clicking buy and when it said 'downloading . . .' going WHAT ? It must have happened at least once for them to have that disclaimer.
-
Sting makes his first post at C4D Cafe explanation well it does say off-topic, light-hearted + fun
-
Controlling stuff by disabling XPresso is not the best method IMHO, but you could either keyframe the enable checkbox in attrib manager, or make a second XPresso control window, drag your main XP tag in and use the enable port. In this snip the compare <= gives a 1 for upto F25 for enable, then a 0 to disable.It's a bit more flexible. I'd suggest stopping the follow inside your code - post your scene and I'll have a look. If it's a big scene (or has copyright models etc) strip it down to the relevant part.
-
I thought that's what the poster meant, although in my little (theoretical) test the string length changed by about 5% when stretched, so if my assumptions were correct the string diameter would only change by 2% - would you even notice a 2% change ? A rubber band gets thinner when you stretch it . . . I 'bow' to your superior knowledge on the subject.
-
I'm guessing that a string gets thinner when it is stretched on a bow, and the volume is constant. I think the vol of a string is the cross section X length ie volume = pi * R^2 * L so if the volume is constant, R is proportional to the square root of 1/L - so doesn't change much. Try pulling the center point on this 'string' spline - there's an exaggerated circle for comparison. It hardly varies. https://www.dropbox.com/s/disr7u4vjk82on6/bow.c4d?dl=1
-
Probably easiest to make a separate control XPresso window where your switch drives the enable port for your main XPresso. https://www.dropbox.com/s/m95k4ithd5tv9f8/enablexp.c4d?dl=1
-
I hate to say this graphos, but I've wasted your time here - that code is too advanced for me to understand, although in a way it illustrates the problems I have with Python. There's a ton of tutorials on YouTube and elsewhere that will teach Python from print('hello world') and up. That's how I am learning regular number-crunching Python. There doesn't seem to be anything explaining C4D-specific Python that starts at 'hello world' - it's either the MAXON manual or nothing, and the MAXON book might as well be in Russian. If I were to type any of the terms in your code into the MAXON website search box, the results would be meaningless to me. TBH I can't tell which are your vars and which are reserved words. It's the same at StackOverflow - you need to be an advanced coder to understand the answers to questions posted by noobs, which sort of defeats the purpose of a forum. As usual, there's an XKCD comic that sums it all up.
-
@graphos could you give an example of your basecontainer method - sounds interesting.
-
Same problem with frame dependent on or off. I've noticed a similar thing when I want to print to console for debugging - there has to be an output port connected to a result etc to get a print (although removing the Python output port lets me print). It's no big deal having an extra unwanted port - just puzzling. Maybe it's not a bug - it's a feature, as the saying goes.
-
Does an XPresso Python node need a connected output port to function correctly? I have a flying helicopter WIP that started life as an XPresso Python node with user data slider inputs and position etc output ports. It worked OK, but I decided to have a go at putting everything in the code ie reading my slider data and writing position + rotation vectors to the helicopter - no ports at all. Trouble is, it kept locking up - and intermittently at that. I thought it was my code, but after a lot of tinkering (trial and error) I found that having a 'dummy' variable connected to a result node - see snip - more or less guaranteed a flying helicopter. I tried a fix I read somewhere about c4d.EventAdd(), to no avail. I also tried copy/paste into a Python tag, but got even weirder reults - when I stopped the timeline, my helicopter kept flying ! Any insights into this output node mystery appreciated. Here's the WIP file - it has a bit of smoothing on the variables to make the aircraft react less jerky to the controls. File's 11MB due to some textures. https://www.dropbox.com/s/muln5vt8o3j4t0j/helicopter7.zip?dl=1