• c4d.CallButton(myTagPSR,c4d.ID_CA_CONSTRAINT_TAG_PSR_ADD)

    python
    6
    0 Votes
    6 Posts
    889 Views
    M
    Gload you solved your issue, if you have any questions, please feel free to open a new topic. Ho and I forget the most important, welcome in the plugincafe community Cheers, Maxime.
  • OBJ Export Options

    10
    0 Votes
    10 Posts
    2k Views
    .
    Thanks for looking at it Manuel. Sounds like your getting the same behavior I'm seeing. I'll add something to my script to parse it out. Thanks Manuel and Cairyn for taking time to help. .del
  • Different behavior on Mac for Commanddata options

    r23 python
    6
    0 Votes
    6 Posts
    678 Views
    ManuelM
    hi That's already mentioned in our application documentation. https://help.maxon.net/us/index.html#PREFSINTERFACE-PREF_INTERFACE_MAIN_GROUP Where do you think we should mention it ? Cheers, Manuel
  • Dump/Restore UserDataContainer

    4
    0 Votes
    4 Posts
    683 Views
    indexofrefractionI
    i finally succeeded in saving a BaseList2D userdata description (not the values) then loading and re-applying / cloning the full definition to a different BaseList2D, and finally copy over the values from the source to the target BaseList2D here is a similar topic for saving / loading the values (not the description) here: https://developers.maxon.net/forum/topic/11960/advice-for-saving-user-data/8 I made a comment there about copying the userdata values
  • Advice for Saving User Data?

    8
    0 Votes
    8 Posts
    1k Views
    indexofrefractionI
    @zipit said in Advice for Saving User Data?: # Write the data back. for cid, value in bc: descid = (c4d.ID_USERDATA, cid) # Check if the type of the element in op at the given descid matches # the data type we want to write, i.e. if the structure of the user # data has not changed. if isinstance(value, type(op[descid])): op[descid] = value a notice about the code part above : this gave me type errors and i solved it by not iterating through the bc, but instead through the ops UserData and skipping any DTYPE_GROUP and DTYPE_SEPARATOR (could be done also when reading the values, ofc) for descid, _ in op.GetUserDataContainer(): uid = descid[1].id dtype = descid[1].dtype name = _[c4d.DESC_NAME] value = bc[uid] print " uid={} dtype={} name={!r}".format(uid, dtype, name) if dtype == c4d.DTYPE_GROUP or dtype == c4d.DTYPE_SEPARATOR: pass elif dtype == c4d.DTYPE_SUBCONTAINER: pass # DTYPE_SUBCONTAINER - should never happen? elif isinstance(value, type(op[descid])): op[descid] = value else: pass # TYPE MISMATCH - should never happen?
  • id PluginMessage () when the scene loaded

    python sdk
    12
    0 Votes
    12 Posts
    2k Views
    ManuelM
    hi, sorry I was focused on calling a command and not a script. Even if it's pretty simple, it's not as simple as i expected to run a python script, sorry about that. Be careful that you need to create the script and relaunch c4d to be able to find it by its name. The idea is to retrieve the ID of the script and use callCommand to execute it. (as you can do with any commandData IDs) you can retrieve the ScriptList with GetScriptHead witch return a GeListHead So you can retrieve the first with GetFirst and compare the name. If you find one, you can simply return it's IDs using GetDynamicScriptID and return it. You now just have to use CallCommand with this ID. (be aware that this CallCommand will create an undo step in the undo stack) So your script will be executed when a new document is loaded. #include "maxon/apibase.h" #include "maxon/errorbase.h" #include "maxon/errortypes.h" #include "maxon/file_utilities.h" #include "maxon/application.h" #include "c4d_general.h" #include "c4d_commanddata.h" #include "c4d_baseplugin.h" #include "c4d_scenehookdata.h" #include "c4d_baselist.h" static Int32 GetScriptID(const maxon::String& scriptName) { iferr_scope; // check all script // Retrieves the script head BaseList2D* scriptHead = static_cast<BaseList2D*>(GetScriptHead(0)->GetFirst()); // for all script for (BaseList2D* script = scriptHead; script != nullptr; script = script->GetNext()) { // retrieves the name of the script maxon::String name = script->GetName(); // if the name match the argument, return the id of the script if (name.IsEqual(scriptName)) return GetDynamicScriptID(script); } // return NOTOK if no script founded. return NOTOK; } class pc12835_scenehook : public SceneHookData { public: static NodeData* Alloc() { return NewObjClear(pc12835_scenehook); } Bool Message(GeListNode* node, Int32 type, void* data) override { if (type == MSG_DOCUMENTINFO) { DocumentInfoData* const msg = static_cast<DocumentInfoData*>(data); if (msg == nullptr) return false; // switch message sub-type switch (msg->type) { case MSG_DOCUMENTINFO_TYPE_LOAD: { // define my script name maxon::String scriptName = "myscript"_s; // search the ID of the scrip const Int32 scriptID = GetScriptID(scriptName); // if the script have been founded, execute it. if (scriptID != NOTOK) CallCommand(scriptID); break; } case MSG_DOCUMENTINFO_TYPE_UNDO: case MSG_DOCUMENTINFO_TYPE_REDO: { ApplicationOutput("undo or redo done"_s); break; } } return true; } return SceneHookData::Message(node, type, data); }; }; Of course you need to register your sceneHookData with RegisterSceneHookPlugin Cheers, Manuel
  • Python, tool attributes and hotkeys

    s22 python sdk
    8
    0 Votes
    8 Posts
    2k Views
    John_DoJ
    @m_magalhaes Yes please, and sorry for the delay :3
  • Compiling my plugin on R23

    6
    1
    0 Votes
    6 Posts
    1k Views
    P
    Ok, success. Copying the plugin folder from pc to mac was the issue!
  • Polygonize() and scene camera

    Moved c++ sdk
    4
    0 Votes
    4 Posts
    526 Views
    ManuelM
    hi, i don't think there's a particular reason for not keeping the camera but the function description is : Returns a copy of the document in which all objects are converted to polygon objects. As a camera doesn't generate polygon, it just doesn't follow. I'm expecting the same for light, atmosphere, background, floor etc. Cheers, Manuel
  • r23 console

    python
    9
    0 Votes
    9 Posts
    2k Views
    oli_dO
    I confirm that with versionn 10.15.6 it works. Once again thank you very much Maxime for your availability and quick answers! Best regards
  • Invoke Dialog from Python Tag

    6
    0 Votes
    6 Posts
    1k Views
    indexofrefractionI
    Hi Manuel, I just thought it must be possible to Message something to a CommandData plugin, too. The idea behind the CommandData was to combine some other functionality, but I guess i just get a new plugin ID and go the MessageData way... best, Index hm, somehow I cant find how to tag this as solved
  • Copy All Parameters of One Object to Another in Real Time?

    r21 python
    4
    0 Votes
    4 Posts
    506 Views
    B
    Thanks for the response @m_magalhaes Oh thanks. It now works on native c4d emitter but not in xparticles emitter. No worries, the solution by @zipit works @zipit Thanks. It works as expected. Here's the code I used added in a python tag orig = doc.SearchObject("original") dup = doc.SearchObject("duplicate") orig_container = orig.GetDataInstance() orig_container.CopyTo(dup.GetDataInstance(), flags= c4d.COPYFLAGS_PRIVATE_CONTAINER_COPY_IDENTICAL, trans=None) c4d.EventAdd()
  • Overlaying icons (like Alembic)

    r20 r21 s22 c++ classic api
    9
    1
    0 Votes
    9 Posts
    1k Views
    fwilleke80F
    OK, I got it. Once it's all figured out, the solution seems laughably simple. In case anybody else needs to maintain R20 compatibility and wants to use custom icon overlays, here's a solution: In MyObject class declaration: (R20 code) class MyObject : public ObjectData { INSTANCEOF(MyObject, ObjectData); // ... private: #if API_VERSION < 21000 BaseBitmap *_customIcon; ///< Used to store a node's custom icon in R20 #endif }; public: #if API_VERSION < 21000 MyObject() : _customIcon(nullptr) { } ~ MyObject() { if (_customIcon) BaseBitmap::Free(_customIcon); } #endif In MyObject::Message(): (R20 code) const BaseContainer &dataRef = op->GetDataInstanceRef(); // // 1. Copy default icon into customIcon // // Load default icon IconData defaultIconData; if (!GetIcon(node->GetType(), &defaultIconData)) return false; // Free _customIcon if it has been allocated before, because // it will now receive the pointer to a newly allocated BaseBitmap. if (_customIcon) BaseBitmap::Free(_customIcon); // Get the actual bitmap that is our icon _customIcon = defaultIconData.GetClonePart(); if (!_customIcon) return false; // // 2. Blit overlay into customIcon // // Load overlay icon IconData overlayIcon; const Int32 overlayIconId = MyFunctionToGetTheIconId(); if (overlayIconId == NOTOK) return false; const Bool overlayIconloaded = GetIcon(overlayIconId, &overlayIcon); if (overlayIconloaded) { BlitOverlayBitmap(overlayIcon.bmp, _customIcon, overlayIcon.x, overlayIcon.y, overlayIcon.w, overlayIcon.h, 32, 32); // // 3. Set cid->dat to use customIcon // cid->dat->bmp = _customIcon; cid->dat->x = 0; cid->dat->y = 0; cid->dat->w = _customIcon->GetBw(); cid->dat->h = _customIcon->GetBh(); cid->filled = true; } And BlitOverlayBitmap(), a variation of your BlitOverlayIcon(): void BlitOverlayBitmap(BaseBitmap *overlay, BaseBitmap *dest, Int32 x, Int32 y, Int32 bw, Int32 bh, Int32 xOffset, Int32 yOffset) { if (!overlay || !dest) return; BaseBitmap *overlayAlpha = overlay->GetInternalChannel(); BaseBitmap *destAlpha = dest->GetInternalChannel(); const Int32 destW = dest->GetBw(); const Int32 destH = dest->GetBh(); if (bw > destW) bw = destW; if (bh + yOffset > destH) bh = destH - yOffset; if (bw + xOffset > destW) bw = destW - xOffset; UInt16 aa, a, rr, r, gg, g, bb, b; aa = a = rr = r = gg = g = bb = b = 0xff; for (Int32 py = 0; py < bh; py++) { for (Int32 px = 0; px < bw; px++) { // get color and alpha from overlay icon overlay->GetPixel(x + px, y + py, &r, &g, &b); overlay->GetAlphaPixel(overlayAlpha, x + px, y + py, &a); // get color and alpha from background icon if available dest->GetPixel(px + xOffset, py + yOffset, &rr, &gg, &bb); if (destAlpha) { dest->GetAlphaPixel(destAlpha, px + xOffset, py + yOffset, &aa); } // blend overlay color against existing icon background color Float blend = a / 255.0; dest->SetPixel(px + xOffset, py + yOffset, (Int32)Blend(rr, r, blend), (Int32)Blend(gg, g, blend), (Int32)Blend(bb, b, blend)); // use only the overlay alpha if the opacity is higher to keep the original icon complete // and only in case the background has an alpha at all if (destAlpha && aa < a) { dest->SetAlphaPixel(destAlpha, px + xOffset, py + yOffset, a); } } } } Thanks for patience & support! Cheers, Frank
  • Blip before Correctly Updating

    c++ r20 sdk
    16
    0 Votes
    16 Posts
    2k Views
    D
    @m_magalhaes Sorry about the late reply again! I went to build some simplified code to post and I might have figured it out in the process. It seems that if I correctly mark the children with AddDependence then GetCache returns the cache I expect. Having the object lower in the object manager than mine causes it to lag behind slightly, but that seems consistent with other Cinema objects. Dan
  • Broken Links in Documentation

    python sdk
    6
    0 Votes
    6 Posts
    633 Views
    r_giganteR
    Hi guys, we've should have fixed the caching issue in the documentation and we kindly ask, before emptying the cache, to see if the issue persists on your side. In case you still experience the issue, please follow-up with a new post in this thread. Thanks for your help! R
  • Debug Python related CRASH

    10
    0 Votes
    10 Posts
    2k Views
    indexofrefractionI
    @zipit just FYI, the CacheInterface immediately crashes R20 but works on R21 @m_adam Ok, thanks! I was doing this in every Python Tag and I have 100-200 of those in the File. I don't really need to do this, it was just a "beauty" thing... that did end up ugly
  • Get the Next Object of doc.SearchObject() Method?

    r21 python
    3
    0 Votes
    3 Posts
    610 Views
    B
    @m_adam Ah gotcha. Thanks for the confirmation and the sample code.
  • Crash in ChannelShader plugin

    s22 c++ macos
    9
    1
    0 Votes
    9 Posts
    779 Views
    fwilleke80F
    I’m confident they will find out Thanks for everything!
  • C4D R21.207 Console don't do anything

    r21 python
    10
    1
    0 Votes
    10 Posts
    2k Views
    C
    Finally fix it! I reinstalled c4d and everything goes well! Thank you for all you helps!
  • Copy Pixels from Active BaseDraw?

    python
    5
    0 Votes
    5 Posts
    569 Views
    ?
    Hi, Thank you @m_adam and @zipit . I am specifically interested in copying the Viewport pixels for speed. Thank you both for your help.