Jump to content

jed

Limited Member
  • Posts

    2,189
  • Joined

  • Last visited

  • Days Won

    66

Everything posted by jed

  1. Can you be more specific - why not just use collision nodes ? re lambda in above script, It's a new one for me - still not sure how it works, but I also found a similar method itemgetter that can reference the 2nd element of a tuple as a search criteria. Need to import the module - import c4d from operator import itemgetter def main(): mylist.sort(key = itemgetter(1)) # ascending sort mylist.sort(key = itemgetter(1), reverse = True) # decending sort
  2. I think this works - not sure how, just pasted some code I found online. It takes the Y position of 5 cubes, sorts lo-hi and outputs the cube names as string. import c4d # sort cubes by Y position lo-hi # cube name output as string def main(): global Output1, Output2, Output3, Output4, Output5 mylist = [('cube1', Input1), ('cube2', Input2), ('cube3', Input3), ('cube4', Input4), ('cube5', Input5)] mylist.sort(key=lambda tup: tup[1]) # sort list of tuples by 2nd element lo-hi Output1 = mylist[0][0] Output2 = mylist[1][0] Output3 = mylist[2][0] Output4 = mylist[3][0] Output5 = mylist[4][0] https://www.dropbox.com/s/pip4h9g0ef40us8/mylist.c4d?dl=1 not very elegant, but some ideas for you.
  3. Rather than hierarchy, it might be simpler with an object list and a link list. In this snip the Object Index gets the index of each matrix (0, 1, 2 ...) then references a spline and connects it. The situation is a bit confusing because the specimen Matrix has 2 ports called object - one selects the object and one is the data field - so I renamed the 2nd.
  4. If it's only a couple of splines with a few points, you could iterate through a condition node with the mesh IDs as data. https://www.dropbox.com/s/e9y40dlolb3hews/iteratepoints.c4d?dl=1
  5. Not sure what you mean by connect, but if you wanted to move a spline point to the xyz of a mesh point using point nodes it would be where the point index ports reference the point ID numbers as per structure manager - 0 is 1st spline point etc. Problem is, the corresponding mesh points are not going to be 0, 1, 2 . . .
  6. I can't run your file due to not having the plugins, but things I'd try : lower bounce (maybe to 0), one collision per pair, use a compare > 0 on the count.
  7. You don't really expect me to understand what looks like 5,000 interconnected nodes ? If you really need to reference all those images with what seems to be sequential conditions ( == 2, ==3 etc) I suggest you use iteration. You could probably get the filenames with string concatenation.
  8. It's not very clear how you want to connect up the sliders in your scene. Maybe you could explain it a bit better and post a c4d file. You do realise that percent sliders are 0-1 decimal in XPresso ?
  9. 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.
  10. 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.
  11. 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
  12. 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
  13. maybe start a new thread on that
  14. 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.
  15. This makes a cube visible when link is present https://www.dropbox.com/s/arqibkx1hi8p7hb/linktransfer2.c4d?dl=1
  16. 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.
  17. 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
  18. 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.
  19. 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.
  20. 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 . . .
  21. 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
  22. jed

    Spline driven gradient

    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 . . .
  23. 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.
  24. 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.
  25. Sting makes his first post at C4D Cafe explanation well it does say off-topic, light-hearted + fun
×
×
  • Create New...

Copyright Core 4D © 2024 Powered by Invision Community