• Importing morph problem

    r21
    12
    0 Votes
    12 Posts
    2k Views
    ferdinandF
    Hello @AiMiDi, without any further feedback or questions, we will consider this topic as solved by Wednesday and flag it accordingly. Thank you for your understanding, Ferdinand
  • How to set Roughness texture to material?

    Moved
    3
    0 Votes
    3 Posts
    634 Views
    C
    Hello Maxime, Thanks for fixing the category for my post. I am new to Cinema4D. I found the correct IDs by opening the UI for the material and drag and drop the settings into the Python console. Kind Regards, Chris
  • This topic is deleted!

    1
    0 Votes
    1 Posts
    1 Views
    No one has replied
  • Get normals of an arbitrary Cinema 4d object

    r23 maxon api c++ windows sdk
    3
    1
    0 Votes
    3 Posts
    778 Views
    M
    Aha I see, this makes sense for the NormalTag data. And yeah of course cross product is what I need... Regarding the primitives not turning into polygon object, I thought that was happening with a cube, but now after testing it again it definitely is. So I must have been mistaken before. Thanks for the help, going to mark this as solved.
  • 0 Votes
    2 Posts
    390 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]
  • Wrong editor preview of material plugins with TextureTag repetitions

    s22 c++
    4
    0 Votes
    4 Posts
    976 Views
    D
    Thanks for the investigation. At least now we are aware the problem is not on our side. Cheers, Deyan
  • python plugin in debugging mode

    2
    0 Votes
    2 Posts
    932 Views
    M
    Hi @Yaroslav this is indeed possible however a bit clunky for the moment, but here a full step by step. Install pip with c4dpy -m ensurepip Install Python Visual Studio Debugger with c4dpy -m pip install ptvsd. Within Visual Studio in your launch.json just set up a basic attach setting, here is mine but for more information see Python debug configurations in Visual Studio Code. { "version": "0.2.0", "configurations": [ { "name": "Cinema 4D: Remote Debugger Attacher", "type": "python", "request": "attach", "connect": { "host": "127.0.0.1", "port": 3000 }, "pathMappings": [ { "localRoot": "${workspaceFolder}", "remoteRoot": "." } ] }, ] } The *.pyp plugin should be of course in the same workspace as your launch.json. Edit the *.pyp plugin and write the next code in the first line of your pyp file. import ptvsd ptvsd.enable_attach(address = ('127.0.0.1', 3000)) Start Cinema 4D, wait until its UI is loaded, meaning the pyp plugin is loaded, and the client (your script) is attachable from a debugger. Run the previously created debug configuration (called Cinema 4D: Remote Debugger Attacher). Put a breakpoint somewhere (like in the Execute of a CommandData) to trigger the BP. Enjoy Note this also works nicely for the script, however for script you should call ptvsd.wait_for_attach() after the ptvsd.enable_attach. Cheers, Maxime.
  • Get the String of the Font Data?

    r21 python
    4
    0 Votes
    4 Posts
    540 Views
    B
    @Cairyn @ferdinand Thanks for the response. Printing the base container with their indexes worked in my use case
  • This topic is deleted!

    1
    0 Votes
    1 Posts
    13 Views
    No one has replied
  • Write a python code into a Python Effector

    python
    10
    0 Votes
    10 Posts
    2k Views
    H
    @Cairyn Thank you for your help ! That's it. I confused it all with the wrong word. Sory... Your answers help me very nicely @ferdinand I apologize about going out of the guidelines. I understand this and will create new topic for that point
  • ObjectData::Draw

    c++ r21
    3
    1
    0 Votes
    3 Posts
    595 Views
    A
    Thanks for your answer, it solved my problem. Thank, AiMiDi
  • Limit SplineKnot tangent

    r21 c++
    3
    2
    0 Votes
    3 Posts
    837 Views
    A
    Thanks for your answer, it solved my problem. I used: Vector::ClampMax() and Vector::ClampMin() to limit the tangent to the value I want. Thank, AiMiDi
  • Dynamic elements in a CYCLE, CYCLE empty after loading document?

    c++ r20 r21 s22 r23
    9
    0 Votes
    9 Posts
    2k Views
    fwilleke80F
    Thanks, Maxime! Looks like I have it running flawlessly now. good work on Terraform looks solid! Thank you! It is pretty solid, yes Cheers & happy Easter, Frank
  • LINK EFFECTORS TO CLONERS

    python
    4
    0 Votes
    4 Posts
    1k Views
    H
    Thank you @bentraje and @ferdinand ! You make the deal of the EffectorList function much clearer ! It works well now
  • 0 Votes
    7 Posts
    1k Views
    M
    Hey guys, thanks for the explanations. My only concern is that I can't really do anything besides closing Cinema4D to cancel the operation. Just for reference my plugin is a fluid volume that needs to be visualized in the viewport. This is not an expected workload, stumbled on it by chance, but so can one of the users. Anyway we can close this thread if it's not a bug. Regards, Georgi.
  • 0 Votes
    4 Posts
    1k Views
    B
    @Cairyn @ferdinand Thanks for the response. The python generator works as expected. I did try to retrieve the cache earlier for mograph but with a python tag rather than a python generator, but it has some priority delays. Your solution is much more stable. Now, I don't have to jump to houdini for such simple scenes. Have a great day ahead!
  • Node ID relevant bits?

    4
    0 Votes
    4 Posts
    734 Views
    ferdinandF
    Hi @Virtualritz, without further questions or updates we will consider this topic as solved by Thursday and flag it accordingly. Cheers, Ferdinand
  • Content libraries. How to change path?

    6
    0 Votes
    6 Posts
    879 Views
    L
    Thank you Ferdinand
  • Blank appearing dropdown cycle

    python macos
    5
    0 Votes
    5 Posts
    1k Views
    H
    @m_adam alrighty got it working. Thanks again. You can close this thread if you like. Cheers, Sebastian
  • Best Practice to transfer a variable from another function?

    python sdk
    3
    0 Votes
    3 Posts
    567 Views
    orestiskonO
    Thanks Manuel, yes that's how I ended up doing it in the end. I thought it would've been simpler to extract a variable from the main function, since it had already calculated. All I would need is to save the variable somewhere where the button function can read it, so this is where I tried the global variables but it didn't work.