Jump to content

DALII

Registered Member
  • Posts

    26
  • Joined

  • Last visited

Recent Profile Visitors

1,057 profile views

DALII's Achievements

Explorer

Explorer (4/14)

  • Collaborator Rare
  • Conversation Starter Rare
  • Dedicated Rare
  • First Post Rare
  • One Year In

Recent Badges

1

Reputation

  1. import c4d doc: c4d.documents.BaseDocument # The document the object `op` is contained in. op: c4d.BaseObject # The Python generator object holding this code. hh: "PyCapsule" # A HierarchyHelp object, only defined when main is executed. def parse_string_to_list(input_string): elements = [] for part in input_string.split(','): if '-' in part: start, end = map(int, part.split('-')) elements.extend(range(start, end + 1)) else: elements.append(int(part)) return elements def filter_multiples_of_2(input_list): return [num for num in input_list if num % 2 == 0] def main() -> c4d.BaseObject: """Called by Cinema 4D to retrieve the cache of the Python Generator object. """ source = None source = op[c4d.ID_USERDATA,2] gapstring = op[c4d.ID_USERDATA,3] gap_unfiltered = [] gap_unfiltered = parse_string_to_list(gapstring) print (gap_unfiltered) gap = [] gap = filter_multiples_of_2(gap_unfiltered) print (gap) pointcount = source.GetPointCount() newpointcount = ((pointcount - 1) * 2) print ("Length of GAP: "+str(len(gap))) #newpointcount = newpointcount - (len(gap)*2) newspline = c4d.SplineObject(newpointcount,c4d.SPLINETYPE_LINEAR) newspline.ResizeObject(newpointcount, int((newpointcount/2))) activesegment = 0 for i in range(0, newpointcount-1, 2): print (i) if i in gap: activesegment = activesegment + 1 continue if activesegment == 0: print ("doing stuff") newspline.SetPoint(i, c4d.Vector(source.GetPoint(activesegment)[0], source.GetPoint(activesegment)[1], source.GetPoint(activesegment)[2])) newspline.SetPoint(i+1, c4d.Vector(source.GetPoint(activesegment+1)[0], source.GetPoint(activesegment)[1], source.GetPoint(activesegment+1)[2])) activesegment= activesegment + 1 continue if activesegment == int((newpointcount/2)-1): print ("doing stuff") newspline.SetPoint(i, c4d.Vector(source.GetPoint(activesegment)[0], source.GetPoint(activesegment)[1], source.GetPoint(activesegment)[2])) newspline.SetPoint(i+1, c4d.Vector(source.GetPoint(activesegment+1)[0], source.GetPoint(activesegment)[1], source.GetPoint(activesegment+1)[2])) activesegment = activesegment + 1 continue else: print ("doing stuff") newspline.SetPoint(i, c4d.Vector(source.GetPoint(activesegment)[0], source.GetPoint(activesegment)[1], source.GetPoint(activesegment)[2])) newspline.SetPoint(i+1, c4d.Vector(source.GetPoint(activesegment+1)[0], source.GetPoint(activesegment)[1], source.GetPoint(activesegment+1)[2])) activesegment = activesegment + 1 continue for i in range(activesegment): print ("Create Segment #" + str(i)) newspline.SetSegment(i,2,0) print (newspline.GetSegment(i)) listofpositions = [] #trying to delete the unused points at 0,0,0 for i in range(newspline.GetPointCount()): if newspline.GetPoint(i) == c4d.Vector(0,0,0): continue else: listofpositions.append(newspline.GetPoint(i)) print (listofpositions) print ("Old Point Count: " +str(newspline.GetPointCount())) newlynewpointcount = newspline.GetPointCount()-(len(gap)*2) newspline.ResizeObject(newlynewpointcount,int(newlynewpointcount/2)) print ("New Point Count: " + str(newlynewpointcount)) for i in range(newspline.GetPointCount()): print ("Set new position for " + str(i)) newspline.SetPoint(i,listofpositions[i]) c4d.EventAdd() return newspline Hi all! My current script - updated to work with creating only one new string and splitting the segments correctly, using a Link to the source spline so I don't have the problem with the original spline interfering with other generators afterwards and a 'ok'ish system do define gaps. While I'd say it is enough for my needs and even enough'er for my skills in scripting, I have a last question regarding the Link / Source object and its state. Everything works fine when the Spline is a Spline without deformer, but with deformer applied (for example the Projection deformer), the deformation will be ignored. I've read some stuff about geometry caches and that may be the problem, but if this is so: Here ends my kowledge, my skills and my chacne to add that 😄 Any idea? I somehow hope that I'm missing some simple parameter to get the object with the final state / cache in python? Thanks and wish you all a nice start of the week!
  2. Quite a big setup for a fence 😛 No! Looks impressive and a little bit overwhelming too. I'll have a look at the node setup for learning / research purpose, because on the first glance I saw the Link List node. Didn't know you can do that! But I guess the setup is a little bit too specific for that use-case only. The plain split-my-spline-into-straight-segments part would be enough, because the fence / wall / thing I'm building aftewards changes with every project. But thanks for your input! I'm always experimenting / extending / advancing my little script and if I'll every finish it I'll keep this thread updated! For now I was able to make the splitting into segments without creating X new spline objects for each segment. But now the rendering crashes ... I guess it needs some more work 😛
  3. Hi Smolak, thanks for your approach / setup to that problem. I tried your scene and while I'm still a little bit overwhelmed with all that stuff, some things I didn't even know they exist, I'm happy about the outcome. Even tried to use the Projection object and it still works fine. One thing that probably could be done inside expresso is the extension of the source spline. If I want to separate a segment and / or extend it a little bit I have to add the nodes manually inside the XPresso tag. But if it works it's worth the time! Being able to use the Projection object really is a bonus. Thank you! Now I'm off to check out what these purple splines are and why they make some gaps between the cubes 😄
  4. Would it be possible to mimic the Cubic (World) projection with this setup? That would result in an uniform UV scaling over multiple assets? Would be nice to use it with Corona Patterns that are configured to work with the Cubic mapping?
  5. Yes, looking for an option to split a spline into those straight segments / lines. Here is a screenshot of the current version of the Python Generator with an Extrude. In this example the spline is projected on the floor beneath and the step effect is irregular. (not like how it would be possible with a Cloner). Sadly in my Python Generator it is not possible to use the new Projection Object to keep the spline on the floor in a non-destructive easy way. For this I had to change the spline points manually. (But! With your Node setup it would be possible) Also attached is a scene with the screenshot setup + the stacked nodes to get a nice fence. FenceFence.c4d
  6. Thanks for the node! One thing I really want the node to do is the flattening of the single line elements. Both points should have the Y value of the first point. That would give me the stepped spline. But regarding the understanding: The first group is only to define if the spline should be closed or not. Then it looks like, inside the Control Point Logic, the position value for points of a spline is stored inside the color? What I really don't understand is why I need a Position value for the Split Spline node. 😄 But the whole setup looks quite manageable if everything is clear. Guess I'd need another Spline Control Points loop, but one that can iterate through pairs of points, or even through segments only. But then the thing with the position and the color comes back and why the position is only in the red channel, which should only define one axis? :S It is still quite confusing for me. There is no real F1 / Documentation right? And also the Data Inspector in the Debug menu shows the same information over and over again. But yeah. That was a quick dump of my experience with the nodes. Anyway a big thanks for your node object thingy. 🙂
  7. Nope. But sadly my skills with nodes are way worse than with Python code. I already tried to wrap my head around some of your great examples in the capsule file pit thread, but at least a few months ago I had to give up. (Even though I already build one or two generator-like things with the 'stacking the child nodes below a primitive' method. Using them inside the node editor still confuses me. If you would try your luck with that example I'd really appreciate it! I believe that generator node could be useful to a lot of people. At least in ArchViz we sometimes have to create such kind of walls / fences. One addition: I've adapted my code to give me the in-code possibility to create gaps. Kind of a nice workaround for not having the option to add more than one child below the Python generator. Really looking forward to your solution (only if you want, of course!) All the best! import c4d doc: c4d.documents.BaseDocument # The document the object `op` is contained in. op: c4d.BaseObject # The Python generator object holding this code. hh: "PyCapsule" # A HierarchyHelp object, only defined when main is executed. def main() -> c4d.BaseObject: """Called by Cinema 4D to retrieve the cache of the Python Generator object. """ source = op.GetDown().GetClone() pointcount = source.GetPointCount() return_null = c4d.BaseObject(c4d.Onull) temp_splines = [] empty = [1,8] for i in range(pointcount-1): if i in empty: print ("Gap Gap Gap") else: spline_temp = c4d.SplineObject(2,0) pos0 = source.GetPoint(i) pos1 = source.GetPoint(i+1) pos0_new = c4d.Vector(pos0[0], pos0[1], pos0[2]) pos1_new = c4d.Vector(pos1[0], pos0[1], pos1[2]) spline_temp.SetPoint(0, pos0_new) spline_temp.SetPoint(1, pos1_new) temp_splines.append(spline_temp.GetClone()) print (len(temp_splines)) for i in range(len(temp_splines)): temp_splines[i].InsertUnder(return_null) c4d.EventAdd() return return_null
  8. Hi all! Wish you a happy new year! I'm challenging myself with a Python Generator in C4D that uses a Spline as a child object and splits it up into multiple segments, that each point to point connection turns into a separate line. That line then has the identical Y value for both points, which makes it a straight line regarding the height. If the source spline has some elevation, the output spline should have a 'step effect'. The end result should be a spline / generator that I can put under a Extrude and Thicken, which gives me a stepped brick wall for example. Here is my Python Generator code. I'm no real programmer - what should explain the lines below. But hey, it works under some circumstances. If I have only one spline as a child object and if I disable the spline after my Generator did its magic I get a spline which can be extruded. My question for this setup would be: Is it possible to tell my Generator that it should ignore the child object with the output? Because if I enable the child object spline, the output has the step-spline and also the original spline included. And a follow up question if someone is interested: Is it possible to get a better version of this? My first idea was a single c4d.SplineObject where I rebuild all segments into one single spline object. This way I may could think of an option to add more than one child. But this is everything I could achieve for now. Hope you're doing fine! import c4d doc: c4d.documents.BaseDocument # The document the object `op` is contained in. op: c4d.BaseObject # The Python generator object holding this code. hh: "PyCapsule" # A HierarchyHelp object, only defined when main is executed. def main() -> c4d.BaseObject: """Called by Cinema 4D to retrieve the cache of the Python Generator object. """ source = op.GetDown().GetClone() pointcount = source.GetPointCount() return_null = c4d.BaseObject(c4d.Onull) temp_splines = [] for i in range(pointcount-1): spline_temp = c4d.SplineObject(2,0) pos0 = source.GetPoint(i) pos1 = source.GetPoint(i+1) pos0_new = c4d.Vector(pos0[0], pos0[1], pos0[2]) pos1_new = c4d.Vector(pos1[0], pos0[1], pos1[2]) spline_temp.SetPoint(0, pos0_new) spline_temp.SetPoint(1, pos1_new) temp_splines.append(spline_temp.GetClone()) print (len(temp_splines)) for i in range(len(temp_splines)): temp_splines[i].InsertUnder(return_null) c4d.EventAdd() return return_null
  9. Big fan of both plugins mentioned above. Thought of mentioning this here after I've found this topic and realizing there are no feedback answers yet. 🙂 Using the RMB plugin for many operations, depending on what I'm working right now. Welding, Splitting and so on ... Dials plugin is opened with TAB. PS. Don't want to bother you but it looks like that the RMB and DIals plugin are not working with the new 2024 version. SearchMaterial on the other hand works fine. Just mentioning it here ... No pressure 🤓
  10. Unfortunately not, no. "Importing" the external data is still done by hand. 🙂 Combining both actions as shown above would be the next big help to make that process a little bit faster. But those SendModelingCommands are still a mystery to me ... 🤓
  11. Hi @kalugin, what exactly do you mean with source files? The script above is all I have regarding code and the scene contains only a simple plane with one face. In poly edit mode I use the 'Create Point' tool to create a new vertex at the desired position, then I run my script once which brings the dialog to enter my height, after that it starts again with using the 'Create Point' tool and so on. Quick screenshot of the test scene. I've attached the two tools I'm using into the interface for quicker editing. (marked yellow) Nice outcome would be that the script executes automatically after I've created the new vertex. What way of even more automated are you thinking of? Always open for a even more automated process. 🙂
  12. Hi all! My goal would be a script that merges together some steps I'm doing right now to create a plane with height spots / points on it to build a terrain based on information I get from PDFs / other external sources. Right now I create a simple plan with no subdivisions, then use the 'Create Point' tool to click on the spot where I want my new point, and after it creates a point I give that point the right height information and so on and so on. I've already created a script that gets the last point index and with a dialog window I can enter the relative height of that point. from typing import Optional import c4d from c4d import gui from c4d import utils doc: c4d.documents.BaseDocument # The active document op: Optional[c4d.BaseObject] # The active object, None if unselected def main() -> None: GetLastPointID(op) def GetLastPointID(PointObj): if PointObj is None: c4d.gui.MessageDialog("Please select one point based object!") return elif not PointObj.CheckType(c4d.Opoint): c4d.gui.MessageDialog("Please select one point based object!") return else: maxPoints = PointObj.GetPointCount() pointHeight = gui.InputDialog("Height?") pointHeight = pointHeight.replace(",",".") PointObj.SetPoint(maxPoints-1, ((PointObj.GetPoint(maxPoints-1)[0]), float(pointHeight), (PointObj.GetPoint(maxPoints-1)[2]))) c4d.EventAdd() if __name__ == '__main__': main() Now: Everything would be a little bit more user-friendly, if that script could open the 'Create Point' modelling tool, let me do my work and after I've created a new point the 'height part' should follow. A really nice-to-have would be that the modelling tool would stay active and I don't have to activate it again. I've found the section about the c4d.utils.SendModelingCommand in the documentation (c4d.utils — Cinema 4D SDK 2023.1.0 documentation (maxon.net)) and also the ID for the 'Create Point' action (ID_MODELING_POINT_ADD_TOOL), but it looks like the SendModelingCommand doesn't work well with actions that require user action afterwards? It only creates new points automatically everywhere (because of MODELINGCOMMANDMODE_ALL, I guess) My question is: Is there any chance that my desired script-combination is possible? 🙂 I'm not really that into programming / scripting, just some python fun from time to time, which kind of limits me to these small little scripts / executables. Guess with writing a whole plugin such a script would be easy possible. Anyway, thanks for any answer in advance!
  13. Really appreciate your help here! Thank you! I tried your asset setup and it works really well. I even tried to add my little connect node, which now allows me to use an Extrude node for the whole spline - finally editable thickness for my walls. But it looks like - obviously - that an offset applied with scale isn't the best way for correct measurement. (If the Scale node does that work(?)) Guess the 'Create Outline' does work a little bit different. But it is again a really nice example for asset / capsule creation to learn from. I realy don't want to fill that capsule file pit with my comments now 🙂 Again: Thank you, really awesome stuff! Quick screenshot of the working thing. 🤓
  14. Hi! Me again. Since I downloaded your scene I've tried many times to somehow get a working, usable Asset / Capsule out of the nodes, but no luck. Would this be even possible with that setup? The most promising thing I could attach together is my little Geometry Modifier Group where I rearranged the input node to the new Geometry input. The double output is only for testing. Tried to output only the bottom Geometry Op, to get only the modified spline, but doesn't work either. (Guess to use it as a correct working modifier I have to assemble both point arrays into one spline somehow) But for now, would you say that it is possible to create a usable Capsule (hope I'm using the right term for these objects) out of it? Really like fiddling around, but the few resources that exist on that topic make it a little too hard. 😕
  15. This is exactly what I was after, yes! There is no need for overlap detection for my use cases. It looks like the built-in Outline tool works the same way as your capsule anyway? 🙂 I'm proud to say that I even understand the nodes beneath (I guess, at least) Thank you! I'll have a look into the other provided capsules here and maybe understand that stuff in the future 🙂
×
×
  • Create New...

Copyright Core 4D © 2023 Powered by Invision Community