• 0 Votes
    3 Posts
    1k Views
    H
    Hello @ferdinand, alright I see. I already thought that you would teach me once again that the naive thought I put up here would'nt hold up to the real world. Thanks for the explanation and the example you provided. I guess that will do just fine. As always much appreciated! Cheers, Sebastian
  • 0 Votes
    4 Posts
    698 Views
    ferdinandF
    Hello @HerrMay, Funny enough DrawPoints seems to internally use the "same points" to draw, one gets to see when one edits the points of a polygon object. In S26 the points are round (thats probably why I was thinking of circles) while in R20 they are squares. No question here, just an observation. As you can see, in the script I retrieve the cache of the object we are going to draw. # Get the cache of the object representing the plugin in the object manager, i.e., more or # less what we returned in GetContour, Cinema 4D has however exhausted the cache for us, and # the cache is not a SplineObject but a LineObject (i.e, the cache of a SplineObject). cache: c4d.LineObject = op.GetDeformCache() or op.GetCache() if not isinstance(cache, c4d.LineObject): return c4d.DRAWRESULT_O This not only enables us to deal with splines affected by a deformer correctly, but also and more importantly with spline generators as for example the Circle spline generator. Such generators do not have any control points one could retrieve, their cache will always contain LineObject instances and not SplineObject instances (when they have been implemented correctly). This is also what I was referring to in my comment, because OffsetYSpline returns a SplineObject as its cache in GetContour, but Cinema 4D will 'exhaust' that cache for us by returning the cache of the cache, the LineObject. A LineObject represents a SplineObject over its current interpolation settings. What is actually weird though is that the color gradient you used here to color the points doesn't work in R20. The points are simply drawn black there. Possibly a Python 2/3 issue caused by integer/float division differences? Yes, this is Python 3 code. In Python 2 integers divide by default as integers. Simply wrap one of the numbers into a float, e.g., f: float = float(i)/float(count). Allow one follow up question. How can I draw only the control points of the spline? In your example you use a circle primitive which has - when made editable - exactly four points making up the shape via tangents. Where as the drawn points using the intermediate points of the circle as well. You can use BaseObject.GetRealSpline to get the underlying editable spline object for a spline. So, when you would replace the section quoted above with this: cache: c4d.SplineObject = op.GetRealSpline() if not isinstance(cache, c4d.SplineObject): return c4d.DRAWRESULT_OK You would now draw the control points of the SplineObject representing the spline generator rather than the vertices of its underlying LineObject. The problem in this case is that the plugin you have chosen is calling 'Current State to Object' (CSTO) on the input object which it is cloning and returning offset-ed (see line 130 in your code listing). CSTO is of course just replacing an object with its cache state. So, when you put a circle spline below the offset spline, it will still be drawn as in the LineObject cache version because the cache and the BaseObject.GetRealSpline representation are in this case identical. Cheers, Ferdinand
  • GeDialog Timer Always Printing to Console?

    Cinema 4D SDK s26 2023 python
    2
    2
    0 Votes
    2 Posts
    316 Views
    K
    Well, that was a fast solution... couldn't it have emerged BEFORE I hit submit?!? Haha, the solution was easy... I was returning True on the Timer function. Took a look at the python memory viewer example and noticed they don't return a value on it. Removed the return from my Timer() function and all is working as expected. def Timer(self, msg): print("Timer") That's it:)
  • 0 Votes
    9 Posts
    1k Views
    gheyretG
    Hi @ferdinand , I get it ! Thanks again to your reply!
  • Cinema crashes renaming items in a TreeView

    Moved Bugs r20 s26 python windows macos
    11
    0 Votes
    11 Posts
    2k Views
    ferdinandF
    Hello @HerrMay, Thank you for your reply, and please excuse that I have overlooked it. Maybe a little bit off topic but since we're already talking Treeviews. There seems to be a bug too when it comes to multi-selecting objects in the Treeview. At least when using c4ds native BaseList2D objects. Without wanting to be rude, that statement is too vague to make a bug report out of it. The thread is quite old and therefore not the most reliable source of information, geared towards C++, and from what I see, not even conclusive in the assessment if there is a bug or not. I see there a user claiming that there is a bug, and another user, probably a Maxon employee, being skeptical about it. We are happy to file bugs, but we need a reproducible case. And just as a heads up, us filing a bug does not necessarily mean that we will fix soon or at all. I understand that this can be disheartening, but we must prioritize where our bug fixing efforts are most needed, which can lead to minor bugs being pushed for a long time. I have closed this thread due to its age, please feel free to open a new thread when you want to discuss that other bug. The thread is still be tracked due to its to_fix tag. Cheers, Ferdinand
  • Struggling on SetParameter for OLight

    Cinema 4D SDK python s26
    4
    0 Votes
    4 Posts
    1k Views
    mocolocoM
    Hi @m_adam, Thanks a lot for the flags, it does work as expected now. Are c4d.DESCFLAGS_GET_NONE and c4d.DESCFLAGS_GET_0 similars? Cheers, Christophe.
  • Back on "message after tag delete" post

    Cinema 4D SDK python s26 sdk
    5
    0 Votes
    5 Posts
    1k Views
    mocolocoM
    Hi @ferdinand, Thanks a lot one more time for all the detailed examples and informations. I finally opt to a data container of the node, mostly due to the fact that the hooks are volatile and need to be set all the time. I also ran some tests with globals without having encounter issues, but indeed you need to be careful when handling this approach. Cheers, Christophe
  • Can REAL MIN / MAX value be changed on Init?

    Moved Bugs 2023 python s26 sdk
    20
    0 Votes
    20 Posts
    4k Views
    mocolocoM
    Hi there, Was the issue fixed on R2023 or R2024? Thanks, Christophe
  • [SOLVED] ARROWBUTTON resource not accessible for Python?

    Cinema 4D SDK
    5
    0 Votes
    5 Posts
    709 Views
    ferdinandF
    Great to hear! One thing I forgot to mention: For ICONID1 XXX and ICONID2 YYY you can use any of the built-in icon IDs as listed here. When you want to use your own icons, you must make sure the icon IDs are registered before the node which is using them in its description. Simply put the c4d.gui.RegisterIcon call before the RegisterXXXPlugin call of the plugin using them. Cheers, Ferdinand
  • SplineMask Render Visibility Not Working

    General Talk s26
    2
    0 Votes
    2 Posts
    487 Views
    M
    Hi @InterfaceGuy, this forum is only about Cinema 4D Scripting and plugins, please reach the user support via the maxon website. Cheers, Maxime.
  • Timeline playing - MSG or method to get it?

    Cinema 4D SDK 2023 python s26
    3
    0 Votes
    3 Posts
    525 Views
    mocolocoM
    Hello @m_adam, Thanks a lot, it works like a charm! Have a good day, Christophe
  • 0 Votes
    7 Posts
    1k Views
    ferdinandF
    Hey @mocoloco, Should, that's why I asked. Yeah, that is not the style of the classic API, there are only little error messages and things like that. What you can also do, is use the return value of SetParameter, a boolean. It will be False when setting the parameter failed. I used 'Ge' to design all [...] Eh, I understand, you mean from GeDialog, or what? I think it just stands for GenericDialog, it also pops up in thing like GeListNode or GeClipMap. There are some really old entities in the classic API and naming conventions were different then Ge is at least not a name for interface gadgets in our APIs. Cheers, Ferdinand
  • Remove render sequence automatic numbering

    Cinema 4D SDK
    8
    0 Votes
    8 Posts
    2k Views
    L
    Hello @ferdinand Thanks a lot for the code above, I really appreciate your help. I changed a few things for match what I was looking for and now it's working perfectly. Thanks again!
  • Building menus with C4DPL_BUILDMENU in S26+

    Cinema 4D SDK s26 python
    4
    0 Votes
    4 Posts
    2k Views
    ferdinandF
    Hello @alexandre-dj, I know all menus in C4D have their own id, so this should be an easy check. That is only true on a relatively abstract level. There are string symbols, e.g., IDS_EDITOR_PLUGINS for menu resources, but there is no strict namespace management or anything else on might associate with statements such as 'all menus in C4D have their own id'. Also note that all menu entries in a menu container are stored under the integer IDs MENURESOURCE_COMMAND and MENURESOURCE_SUBMENU as shown in my example above. So, when you have a menu with ten commands and four sub-menus, all fourteen items are stored under these two IDs. This works because BaseContainer is actually not a hash map as one might think, and can store more than one value under a key. Long story short - traversing and modifying menus is not ultra complicated but I would also not label it as 'easy' ; which is why I did provide the example in my previous posting. When firing c4d.gui.GetMenuResource("M_EDITOR") to Get the whole menu of Cinema 4D (as you mention in your code here) I get a different address every time: >>> c4d.gui.GetMenuResource("M_EDITOR") <c4d.BaseContainer object at 0x000001B406C86580> >>> c4d.gui.GetMenuResource("M_EDITOR") <c4d.BaseContainer object at 0x000001B406CA6A40> >>> c4d.gui.GetMenuResource("M_EDITOR") <c4d.BaseContainer object at 0x000001B406C88C80> You are calling here the Python layer for returning a Python object representation of the C++ object that represents the menu. Cinema 4D is still a C++ application and the menu exists in your memory with the layout defined by the C++ type BaseContainer. That type has memory-wise nothing to do with its Python counter part c4d.BaseContainer. So, the Python layer must create that Python data on the fly, as otherwise the memory-footprint of Cinema 4D would double (actually more, because Python data is not exactly sparse data) and synchronizing both data layers would bring Cinema 4D to a crawl. TLDR; you retrieve the same data expressed as a different memory object because 'that is how Python works'. So when I use c4d.gui.SearchMenuResource(main_menu_ressource, my_custom_menu) to check if my custom menu is part of the main menu, this always return False, as the address of the main_menu object changes. Why your call fails here, depends a bit on what you are passing. The first argument should be the string symbol inside a sub menu, and the second item is the sub menu. When you store a reference to a sub-menu from a previous call to GetMenuResource, this might not work when SearchPluginMenuResource searches by identity instead of equality, i.e., it expects that container to be at a certain memory location (have not tried though). There is also c4d.gui.SearchPluginMenuResource(identifier='IDS_EDITOR_PLUGINS'), which should be sufficient to find anything that does not produce a name collision. I personally would just write my own stuff as demonstrated above, since I can then search however I want to. Cheers, Ferdinand
  • Geometry Axis asset node and LoadAssets

    Cinema 4D SDK python s26
    7
    1
    1 Votes
    7 Posts
    1k Views
    M
    @Dunhou said in Geometry Axis asset node and LoadAssets: Hi there, In C4D 2024, the Geometry Axis can not accessible in python anymore, how can I fix that? from typing import Optional import c4d doc: c4d.documents.BaseDocument # The active document op: Optional[c4d.BaseObject] # The active object, None if unselected def main() -> None: for i, (bc, descid, _) in enumerate(op.GetDescription(c4d.DESCFLAGS_DESC_0)): name = bc[c4d.DESC_NAME] if name == "Axis X": print(i,descid) print(op[descid]) if __name__ == '__main__': main() 2024 [image: 1699255573905-832ba1ea-2683-4deb-95de-67444dbcf033-image.png] 2023 [image: 1699255607788-d37942ef-53b5-4e13-9cab-2946766c3fd6-image.png] Cheers~ DunHou Hi, this issue have been fixed in 2024.2 and your code is working as it was previously. Cheers, Maxime.
  • 0 Votes
    3 Posts
    469 Views
    DunhouD
    @ferdinand Thanks for that solution. It's happy to hear that , I do try to make win-win clear post as I can to don't waste our time , hope it's a worthy work I tested the new GetUpdatedInexcludeData function , it worked well , The "click twice" thing never happen again . It's the None condition I didn't realize before . It does happend when no or single object in the list . And for the "odd place" and the "exception ", it is a test to make sure all the things above work well( after that are all the settings ) . I forgot move to the right place . sorry to that Thanks for the caring code for c4d.utils.DegToRad(360) , I haven't notice this before and just stupid import radians
  • How to render a animation preview ?

    Cinema 4D SDK sdk s26 python
    7
    0 Votes
    7 Posts
    1k Views
    M
    Hi @Dunhou you can't control the Make Preview plugin, you have to rewrite the function yourself with all the tips previously shared in this topic. Cheers, Maxime.
  • How to select directories in a CUSTOMGUI_FILENAME?

    Cinema 4D SDK s26 python
    3
    0 Votes
    3 Posts
    703 Views
    P
    Hi @ferdinand , Thanks a lot, that's exactly what I was looking for ! flags: c4d.BaseContainer = c4d.BaseContainer() flags[c4d.FILENAME_DIRECTORY] = True # Add a CUSTOMGUI_FILENAME with our flags settings. self.AddCustomGui(id=MyDialog.ID_FILENAME, pluginid=c4d.CUSTOMGUI_FILENAME, name="Path", flags=c4d.BFH_SCALEFIT, minw=0, minh=0, customdata=flags)
  • Can i get global input event ?

    Cinema 4D SDK python s26
    3
    0 Votes
    3 Posts
    399 Views
    gheyretG
    @ferdinand Wow~ Thank you so much bro
  • Python. Cinema4d. All iterations in the Text value

    Cinema 4D SDK
    9
    2
    0 Votes
    9 Posts
    1k Views
    S
    @ferdinand thx very much! ill save this