• 0 Votes
    7 Posts
    1k Views
    fwilleke80F
    Okay, thanks!
  • Expresso show hidden objects

    Cinema 4D SDK macos project tool
    4
    1
    0 Votes
    4 Posts
    933 Views
    ferdinandF
    Hello @mauovernet, without any further questions or postings, we will consider this thread as solved by Friday the 4th, February 2022. Thank you for your understanding, Ferdinand
  • Unique Material per Object Plugin instance?

    Cinema 4D SDK r20 python macos
    4
    0 Votes
    4 Posts
    931 Views
    H
    Hi Guys, as I'm pretty sure I found a way to achieve what I'm after I thought I update this thread. Maybe this will help others as well. After taking some time to make NodeData.CopyTo() work, I ended up not getting it to work at all. So I thought about how I could achieve what I'm after a different way. Long story short, I ended up implementing a MessageData plugin as some kind of watchdog for a document. Since its CoreMessage runs on the main thread I can happily insert and delete materials as much as I wish to. (At least I'm hoping so ) Tl; dr The idea behind this goes as follows. I have a timer running and in addition to that I listen for c4d.EVMSG_CHANGE and do some checking to see if the scene needs to update. In my case it's comparing the amount of a specific object against the amount of "specific" materials. If there's a difference I use that difference to delete or insert materials until there's no difference. Once there's no difference I can assign the materials to the objects and let each object control its own material. To distinguish between materials responsible for my plugin and the ones that aren't I make sure to put a unique plugin id inside the base container of the material I can then check for. Here's a code snippet of that MessageData: class Watchdog(c4d.plugins.MessageData): PLUGIN_ID = "Use your own unique one" PLUGIN_NAME = "A MessageData plugin." PLUGIN_INFO = 0 def __init__(self): self._time = 1000 def GetTimer(self): return self._time def SetTimer(self, time): self._time = time @property def should_execute(self): is_mainthread = c4d.threading.GeIsMainThread() check_running = ( bool(c4d.CheckIsRunning(c4d.CHECKISRUNNING_EDITORRENDERING)), bool(c4d.CheckIsRunning(c4d.CHECKISRUNNING_EXTERNALRENDERING)), bool(c4d.CheckIsRunning(c4d.CHECKISRUNNING_INTERACTIVERENDERING)), bool(c4d.CheckIsRunning(c4d.CHECKISRUNNING_ANIMATIONRUNNING)), bool(c4d.CheckIsRunning(c4d.CHECKISRUNNING_VIEWDRAWING)) ) is_running = any(item is True for item in check_running) return is_mainthread and not is_running def CoreMessage(self, mid, mdata): if not self.should_execute: return False doc = c4d.documents.GetActiveDocument() # SceneHandler is a custom class I delegate the whole creation and comparing stuff to. objs, mats = ..., ... scene = SceneHandler(objs, mats) # Check for a change and start the timer again. But only if the scene should update. Otherwise the timer would run all the time. if mid == c4d.EVMSG_CHANGE: if scene.should_update: self.SetTimer(1000) # If we get a timer event we update the scene as long as it shouldn't update anymore. We can then stop the timer. if mid == c4d.MSG_TIMER: if not scene.should_update: self.SetTimer(0) scene.update(doc) return True Maybe this will help others. Since I found a solution for my problem this thread can be marked solved. Cheers, Sebastian
  • How to traverse a GeListNode tree

    Cinema 4D SDK python r25 r23 s24 windows macos
    5
    0 Votes
    5 Posts
    2k Views
    ferdinandF
    Hello @WDP, without any further questions we will consider this topic as solved by Friday, December the 17th. Thank you for your understanding, Ferdinand
  • How to Rotate an Object

    Cinema 4D SDK r25 s24 r23 python macos windows
    7
    0 Votes
    7 Posts
    2k Views
    ferdinandF
    Hello @WDP, this question would technically also be a new topic, please follow these rules. There is no formal notion of an object axis in the sense of a moveable entity in the API. Objects have their matrices (the global and the local one), which are effectively their own coordinate system opposed to the world coordinate system (or transform or frame when you prefer these terms over coordinate system). So, when you want to reproduce what is possible in the app, and move, rotate, or scale the axes of an object, without moving the geomtery of the object itself, then you will have to transform the vertices of that object. So, when the object has the world offset (0, 0, 0) and you want to move the axes to (100, 0, 0), you must first set the global object matrix to an offset of (100, 0, 0) and then apply the inverse of a transform that translates by (100, 0, 0) to all its vertices. I would recommend reading the matrix manual I did post in my first answer here. This will however only be possible for editable point objects, e.g., a c4d.PolygonObject. You are showing a generator object, i.e., a c4d.BaseObject with some cached geometry in your screenshot. You cannot move the axes for these objects, neither in the SDK nor in the app itself. We had recently this topic which dealt with moving the axes of a polygon object. Cheers, Ferdinand
  • Python Objekte X Y Z

    Moved Cinema 4D SDK python r21 windows macos
    8
    0 Votes
    8 Posts
    2k Views
    W
    Thank you very much!
  • 0 Votes
    12 Posts
    3k Views
    Y
    Oh! Forget guys my message above! The calling of Python code from C++ plugin in @kbar 's advice does the trick! If someone from the future who will read this thread will need the code example, I just use the code snippet from here: https://developers.maxon.net/docs/cpp/2023_2/page_maxonapi_python.html and feed to it this code: // call it from somewhere String code = "import c4d\nimport maxon\nimport os "; code+= "\n\nprint(f'This is simple message')"; code += "\nos.rename('C:/Code/sdk/plugins/myPlugin/myPlugin.xdl64', 'C:/Code/sdk/plugins/myPlugin/old_myPlugin.old')"; ExecutePythonScript(code, GetActiveDocument());
  • 0 Votes
    5 Posts
    2k Views
    ferdinandF
    Hello @HolgerBiebrach, we will set this topic to 'Solved' when there are no further questions or replies until Monday, November the 22th. Thank you for your understanding, Ferdinand
  • 0 Votes
    2 Posts
    511 Views
    ferdinandF
    Hello @thomasb, thank you for reaching out to us. Please remember to open a new thread for new questions of yours. It is fine to ask follow-up questions in a topic, but when the threshold to a new topic is being crossed, a new thread should be opened. I have done this for you here. In principle this is at least partially possible. You can determine the visibility for a user data description element with the description field DESC_HIDE, see example at the end of the posting for details. It is not possible to gray-out, i.e., disable, user data description elements. It is also a bit a case of an unusual workflow for user data, since you would have to rebuild the user data container every time you want to hide or show and element in it. You could overwrite for example message() in a Python scripting tag and then react to when a user clicks a button, drags a slider, etc. in the user data and rebuild the user data based on that. Which would give you the dynamic GUI feeling you are probably after. I have done this in the past, but more as a hack for fun to see how far I can push user data. I would not recommend doing it as it will complicate things like animation and can lead to "janky" interfaces. Being bound to the execution order of expressions can also lead to problems. If you want dynamic GUIs, you should implement a plugin. There you can overwrite NodeData.GetDDescription() to modify the description, e.g., add, remove, or hide stuff. To disable stuff, i.e., gray it out, you must overwrite NodeData.GetDEnabling(). Cheers, Ferdinand """Example for adding a hidden user data element. """ import c4d def main(): """Adds a hidden check box and a visible integer element to the user data of the selected object. """ if op is None: raise ArgumentError("Please select an object for running this script.") datenDesc = c4d.GetCustomDataTypeDefault(c4d.DTYPE_BOOL) datenDesc[c4d.DESC_NAME] = "Daten" datenDesc[c4d.DESC_HIDE] = True # Element will be hidden stepsDesc = c4d.GetCustomDataTypeDefault(c4d.DTYPE_LONG) stepsDesc[c4d.DESC_NAME] = "steps" stepsDesc[c4d.DESC_HIDE] = False # Element will be visible op.AddUserData(datenDesc) op.AddUserData(stepsDesc) c4d.EventAdd() if __name__ == '__main__': main()
  • 0 Votes
    8 Posts
    1k Views
    M
    Correct, thanks for poitning it I will add a task to improve documentation of Custom GUI
  • 0 Votes
    3 Posts
    833 Views
    a_blockA
    Hello Ferdinand, yes, I was talking about the plugin ID argument of GeDialog.Open() and Restore(). Thanks for your explanation. I'm completely fine with your answer, despite some seeming here and there. I do understand the problems a codebase grown over decades can cause for answering such questions definitely. Nevertheless your explanations largely sync with my expectations from quite a few experiments. Regarding the mentioned issue of the other thread, I can acknowledge, the plugin ID parameter did not seem to have influence on the issue in my experiments. This question here was really more targeted the sizing issues I have with requesters of varying content. And your answer provides me with some confidence, I can make use of different plugin IDs (I should probably rather say unique IDs from Plugin Café) even if they are not related to any registered plugins at all. While I had already thought so and did not find any issues with this practice, it's always a bit hard to know for sure from the outside. And there's always this feeling one could be doing something harmful, which will only bite at the worst possible point in future. Thanks for the clarification. Cheers, Andreas
  • 0 Votes
    2 Posts
    325 Views
    ferdinandF
    Dear user, thank you for reaching out to us. Is it possible, via C++, to add a command to the right click menu that pops up for a parameter in C4D? Unfortunately, that is not possible. The context menu of a DescriptionCustomGui is sealed off from user access. The specific context menu is not meant to be modified. I would like to call a command and somehow get the parameter that was right clicked on as well. I don't think this is possible at all, but can't hurt to ask just in case. You are right, this is also not possible, at least in the context you are most likely talking about. You can get hold of the selected element(s) in a DescriptionCustomGui via GetDescIDSelection() (Link), but this requires one to get hold of that DescriptionCustomGui obviously. Since you are very likely talking about the Attribute Manger, this is effectively not possible, since you cannot get hold of it from the SDK side (in the way you want to). For a custom GeDialog with a DescriptionCustomGui this would be possible. While we can technically get hold of an Attribute Manager when implementing nodes, I do not see a way to get hold of its DescriptionCustomGui nonetheless. Cheers, Ferdinand
  • ReadFileToMemory() in R20 crashes

    Cinema 4D SDK c++ macos r20 maxon api
    7
    1
    0 Votes
    7 Posts
    877 Views
    fwilleke80F
    Hi Manuel, sorry, I totally forgot about this one. Priorities have changed, so this isn't an issue anymore at the moment. Thanks! Cheers, Frank
  • 0 Votes
    2 Posts
    364 Views
    ferdinandF
    Dear user, the problem with your example code is that you do use a VoxelizationInterface which is not well suited for this task. The type DistanceQueryInterface(Documentation) is much better suited for the task. You should also be more cautious with statements like the following, taken from your code, voxelRef = maxon::PolyVoxelization().Create() iferr_ignore("Could not create VoxelizationRef"); as stepping over a failure of initialization will lead to crashes. At the end of this posting you will find an example for how to use DistanceQueryInterface as well as some light comments on error handling. I hope this helps and cheers, Ferdinand /* This function expects a point object (A) to be the first object in the scene, followed by a polygon object (B) as the second object. It will then return the index for closest polygon in B for each vertex in A. */ static maxon::Result<void> Pc13296(BaseDocument* doc) { iferr_scope; // Get the first and second node in the scene. The first one is expected // to be a point node, serving as a point source, and the second one is // expected to be a polygon node, serving as a polygon source. BaseObject* node = doc->GetFirstObject(); if (node == nullptr || !node->IsInstanceOf(Opoint)) { ApplicationOutput("Please provide a point object as the first node in the scene."_s); return maxon::OK; } PointObject* pointNode = static_cast<PointObject*>(node); node = node->GetNext(); if (node == nullptr || !node->IsInstanceOf(Opolygon)) { ApplicationOutput("Please provide a polygon object as the second node in the scene."_s); return maxon::OK; } PolygonObject* polygonNode = static_cast<PolygonObject*> (node); // Get access to the point and polygon data and the global transforms of both nodes. const Vector* points = pointNode->GetPointR(); const CPolygon* polygons = polygonNode->GetPolygonR(); const int pointCount = pointNode->GetPointCount(); const int polygonCount = polygonNode->GetPolygonCount(); Matrix mgPointNode = pointNode->GetMg(); // We invert it right away, as we only will need it in this form. Matrix iMgPolygonNode = ~polygonNode->GetMg(); // When an error is being raised by Cinema we should be cautious with using iferr_ingore, as // then the code will keep running in the current scope. In some cases like manipulating an // array like structure this can be useful. But when an initialization of an entity fails, we // almost never want to keep going, as trying to use that not initialized object then will be // a sure fire way to crash Cinema 4D. Instead we can either use iferr_return to simply leave // the current scope, use iferr_throw to throw a specific error or handle it manually with // iferr(). Below you will find a two examples. // Create a reference to the distance query interface. maxon::DistanceQueryRef distanceQuery = maxon::DistanceCalculator().Create() iferr_return; // Pass true for the second argument to voxelize the input to speed up larger queries. Just as // with any optimization, for smaller data sets this voxelization setup might eat up all the // performance benefits gained latter on. iferr(distanceQuery.Init(polygonNode, false)) { ApplicationOutput("Failed to initialize DistanceQueryInterfacae for @", polygonNode->GetName()); return maxon::OK; } // Go over all vertices and query them for the closest polygon (id) in the other mesh. float distance = 0; Vector p; for (int poindId = 0; poindId < pointCount; poindId++) { // The point in the point mesh converted first to global coordinates and then to local // coordinates in the polygon node. We have to do that because the points in the point // source live in their own coordinate system as well the ones in the polygon source. p = mgPointNode * iMgPolygonNode * points[poindId]; maxon::PrimitiveInformation info; distance = distanceQuery.GetClosestMeshPrimitive(p, info); ApplicationOutput("Closest polygon id for point id @: @", poindId, info.GetRealPolyIndex()); } return maxon::OK; } The output/setup: [image: 1617968576078-642545d3-3ffa-467e-9123-cf0a328b18f1-image.png]
  • Blank appearing dropdown cycle

    Cinema 4D SDK python macos
    5
    0 Votes
    5 Posts
    954 Views
    H
    @m_adam alrighty got it working. Thanks again. You can close this thread if you like. Cheers, Sebastian
  • Error: Wrong indentation of namespace member

    Cinema 4D SDK macos c++ r23
    9
    2
    0 Votes
    9 Posts
    2k Views
    fwilleke80F
    Wow, I never thought of that. Very good to know, thank you for asking! Cheers & have a nice weekend, Frank
  • SSL TLSV1_ALERT_PROTOCOL_VERSION Error on Mac

    Cinema 4D SDK r19 python macos
    3
    0 Votes
    3 Posts
    1k Views
    ?
    @m_adam Thank you, Maxime! Have a good weekend.
  • 0 Votes
    10 Posts
    1k Views
    fwilleke80F
    Thank you!
  • 0 Votes
    4 Posts
    471 Views
    fwilleke80F
    I was in deed calling the code from within PluginStart(). Calling it from PluginMessage(C4DPL_STARTACTIVITY) fixed it. Thank you, Kent! Cheers, Frank
  • Difficulty with cloners and and lifetime of objects

    Cinema 4D SDK
    13
    0 Votes
    13 Posts
    2k Views
    M
    All right, thank you for all the help. I'll close this now.