• Shader that gets data from an object: Refresh

    r20 r21 s22 maxon api c++
    6
    0 Votes
    6 Posts
    1k Views
    fwilleke80F
    It works like a charm! Thank you again! I was surprised at how little code was required. Sharing is caring. In case anyone needs it, here's the code: #include "ge_prepass.h" #include "c4d_general.h" #include "c4d_baselinkarray.h" #include "c4d_basedocument.h" /// /// \brief Registers observers and sends messages to them. /// class Observable { public: /// /// \brief Subscribes a new observer. /// /// \param[in] observer Pointer to an AtomGoal /// \param[in] doc The document that owns the AtomGoal /// /// \return A maxon error object if anything went wrong, otherwise maxon::OK /// maxon::Result<void> Subscribe(C4DAtomGoal *observer, BaseDocument *doc); /// /// \brief Unsubscribes an observer /// /// \param[in] observer Pointer to an AtomGoal that has previously been subscribed /// \param[in] doc The document that owns the AtomGoal /// void Unsubscribe(C4DAtomGoal *observer, BaseDocument *doc); /// /// \brief Sends a messages to all subscribed observers /// /// \param[in] type Message type /// \param[in] doc The document that owns the subscribed observers /// \param[in] data Optional message data /// void Message(Int32 type, BaseDocument *doc, void *data = nullptr) const; private: BaseLinkArray _observers; }; maxon::Result<void> Observable::Subscribe(C4DAtomGoal *observer, BaseDocument *doc) { if (!observer) return maxon::NullptrError(MAXON_SOURCE_LOCATION, "Observer must not be nullptr!"_s); // Check if this observer is already registered const Int32 observerIndex = _observers.Find(observer, doc); if (observerIndex != NOTOK) return maxon::OK; // Register new observer if (!_observers.Append(observer)) { return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION, "Failed to add observer to the list!"_s); } return maxon::OK; } void Observable::Unsubscribe(C4DAtomGoal *observer, BaseDocument *doc) { if (observer && doc) { const Int32 observerIndex = _observers.Find(observer, doc); if (observerIndex != NOTOK) { _observers.Remove(observerIndex); } } } void Observable::Message(Int32 type, BaseDocument *doc, void *data) const { for (Int32 i = 0; i < _observers.GetCount(); ++i) { C4DAtomGoal *atom = _observers.GetIndex(i, doc); if (atom) { atom->Message(type, data); } } }
  • Getting a GadgetID during BFM_INTERACTSTART

    python
    6
    0 Votes
    6 Posts
    654 Views
    ?
    Thank you both! @zipit & @m_magalhaes
  • This topic is deleted!

    1
    0 Votes
    1 Posts
    9 Views
    No one has replied
  • Hide description element using MessageData::CoreMessage() function

    r21
    5
    0 Votes
    5 Posts
    885 Views
    ManuelM
    hi, I'm a bit surprised that your render can be triggered from a NodeData (but why not) But i don't understand why you can't use GetDDescription to update your node. That's what i did (in a probably too naive way) but you got the idea. I just got a boolean display_aboard on my ObjectData and i switch it as i needed. If i presse the button, i switch and i set dirty my node, if i receive the message that the render is finished (or stopped) i set my bool to false and i SetDirty my node. static const Int32 g_pc12584ButtonID = 1000; class pc12584_object : public ObjectData { INSTANCEOF(pc12584_object, ObjectData); public: static NodeData* Alloc() { return NewObjClear(pc12584_object); }; Bool Init(GeListNode* node) override { display_aboard = false; return true; } BaseObject* GetVirtualObjects(BaseObject* op, HierarchyHelp* hh) override { BaseObject* null = BaseObject::Alloc(Onull); return null; } Bool GetDDescription(GeListNode* node, Description* description, DESCFLAGS_DESC& flags) override { if (!description->LoadDescription(Obase)) return false; const DescID* singleid = description->GetSingleDescID(); const Int32 ID = g_pc12584ButtonID; const DescID cid = DescLevel(ID, DTYPE_BUTTON, 0); if (!singleid || cid.IsPartOf(*singleid, nullptr)) { BaseContainer bc = GetCustomDataTypeDefault(DTYPE_BUTTON); bc.SetInt32(DESC_CUSTOMGUI, CUSTOMGUI_BUTTON); if (display_aboard) bc.SetString(DESC_NAME, "Aboard Render"_s); else bc.SetString(DESC_NAME, "Render"_s); bc.SetInt32(DESC_ANIMATE, DESC_ANIMATE_OFF); bc.SetInt32(DESC_SCALEH, 1); description->SetParameter(cid, bc, DescLevel(ID_OBJECTPROPERTIES)); } flags |= DESCFLAGS_DESC::LOADED; return SUPER::GetDDescription(node, description, flags); } Bool Message(GeListNode* node, Int32 type, void* data) override { switch (type) { case MSG_DESCRIPTION_COMMAND: { DescriptionCommand* dc = (DescriptionCommand*)data; const Int32 id = dc->_descId[0].id; if (id == g_pc12584ButtonID) { display_aboard = !display_aboard; node->SetDirty(DIRTYFLAGS::DESCRIPTION); } break; } case g_pc12584Message: { display_aboard = false; node->SetDirty(DIRTYFLAGS::DESCRIPTION); break; } } return SUPER::Message(node, type, data); }; private: Bool display_aboard = false; }; // function to send a message to the ObjectData. static maxon::Result<void> PC12854_Message(BaseDocument* doc) { iferr_scope; // update the first object BaseObject* op = doc->GetFirstObject(); if (op == nullptr) return maxon::NullptrError(MAXON_SOURCE_LOCATION); op->Message(g_pc12584Message); return maxon::OK; } Cheers, Manuel
  • Adding Keyboard Message: KEY_ENTER & KEY_TAB

    4
    0 Votes
    4 Posts
    569 Views
    ManuelM
    hi, @indexofrefraction, as @blastframe said, let's keep that thread clean and ask your question in another thread, this is working on my system. @blastframe , we will take into consideration your request. Cheers, Manuel
  • Store generator's property

    python
    4
    0 Votes
    4 Posts
    598 Views
    ManuelM
    hi can we considered this thread as resolved ? Cheers, Manuel
  • 0 Votes
    11 Posts
    1k Views
    ManuelM
    hi can we considered this thread as solved ? (even if there's no real right answer) Cheers, Manuel
  • Python Tag does not update during rendering

    python
    9
    0 Votes
    9 Posts
    1k Views
    ManuelM
    hi, we got some information in our documentation. For example you can't add an object in the document from a tag while the generator can return a hierarchy. But you can easily draw information on the viewport with a tag. Cheers, Manuel
  • Xcode update to 11.7... do it or not?

    macos
    3
    0 Votes
    3 Posts
    335 Views
    fwilleke80F
    OK, thanks!
  • Disable a Command Plugin

    python
    11
    0 Votes
    11 Posts
    1k Views
    ?
    @m_magalhaes Thanks Manuel (and @zipit ) for your help. Please let us know about why the Message isn't working.
  • Something to watch out for with GetAllAssets

    s22 c++
    2
    2 Votes
    2 Posts
    476 Views
    M
    Hi Thanks for the extra warning, just in case it was stated in the S22 API change. Cheers, Maxime.
  • Changing camera/take/render setting in the render queue

    3
    0 Votes
    3 Posts
    1k Views
    B
    @m_adam Thanks. I gave that a shot, but unfortunately, it's still adding multiple copies of the same camera. Am I doing something wrong? docs = c4d.documents doc = docs.GetActiveDocument() cams = getSelectedCameras(doc.GetActiveObjects(0)) path = doc.GetDocumentPath() cFile = path + '\\' + fName queue = docs.GetBatchRender() queue.Open() base = doc.GetActiveBaseDraw() for cam in cams: docs.LoadDocument(cFile, c4d.SCENEFILTER_OBJECTS | c4d.SCENEFILTER_MATERIALS) base.SetSceneCamera(cam) docs.SaveDocument(doc, cFile, c4d.SAVEDOCUMENTFLAGS_DONTADDTORECENTLIST, c4d.FORMAT_C4DEXPORT) queue.AddFile(cFile, queue.GetElementCount())
  • set sculpting layer data from high resolution mesh.

    3
    1
    0 Votes
    3 Posts
    509 Views
    J
    @m_magalhaes Thank you for reply. I am going to use it for this project. Hope it gets fixed soon. Thank you.
  • BaseBitmap.CopyPartTo() with grayscale image

    python sdk
    5
    0 Votes
    5 Posts
    905 Views
    oli_dO
    Thank you very much Maxime for the reply. I'm looking forward to the r23 and the python 3 with a lot of impatience. Cheers
  • TreeView Multiple Selection With LMB

    Moved
    13
    0 Votes
    13 Posts
    2k Views
    Danchyg1337D
    @m_adam Now i see the problem. Thanks alot for helping!
  • SDK for node based materials, status?

    r21 sdk
    3
    1 Votes
    3 Posts
    656 Views
    F
    @r_gigante said in SDK for node based materials, status?: With regard to your question, we confirm that at the moment there are no news concerning this topic but, again, we are aware of the relevance of the request and it will be delivered accordingly to our product development plan. Thanks! On a related note: Is there any statement from MAXON on the future of the old xpresso-style node system? We are looking to implement a node-system in our plugin, and since API for the new node system is not out yet we may consider using the legacy xpresso API instead. On the other hand, it would not be a good idea to invest resources in this if that part of the SDK might be deprecated and replaced with the new node system. I realize that you may not be able to provide much info on the roadmap here, but any information that you can give would be super helpful for making this decision! Cheers /Filip
  • MSG_GETCUSTOMICON: Bitmap in IconData always empty

    s22 c++ classic api
    5
    0 Votes
    5 Posts
    771 Views
    M
    Hi Frank, sorry for coming late to the party, the API changed within the R21 where by default the icon is not more filled because it's up to you to fill it with what you need. Just in case for other people, not interested in C++ (since the manual is pretty obvious) there is a Python example in Where you can have custom icons, you can find an example of how to achieve custom icon within Python in py-custom_icon_r21.pyp. Cheers, Maxime.
  • Encrypted Loggers or Custom LoggerTypes?

    r20 r21 s22 c++
    7
    0 Votes
    7 Posts
    759 Views
    ManuelM
    hi, I've asked the devs. We should have everything needed to do what you want. Encrypting file is builtin with maxon::Url scheme. There's already several algorithm, you just have to specify your CryptoKey. When you create a logger to a file (or it could be a web server), you attach it to a maxon::Url, it should be automatically encrypted. But that's not working and that's why I've asked the devs. I don't know if it's a limitation or a bug. What I wanted to do was create a maxon::LoggerType::EncryptedFile(), but I don't see how to do this. as i said, the encrypted part should be done by the maxon::Url (streaming) part Cheers, Manuel
  • This topic is deleted!

    1
    0 Votes
    1 Posts
    4 Views
    No one has replied
  • How to refresh a deleted object link in Python?

    6
    0 Votes
    6 Posts
    1k Views
    X
    Hi: It feels like a good question, otherwise I wouldn't have known that XPresso had this problem.I think your problem is that XPresso Tag adds links to user data.If you add user data links to Python nodes, you will have no problem putting splines in the links.Or drag the spline directly to XPresso manager, output the object, there will be no problem. import c4d #Welcome to the world of Python def main(): #global spline global obj global time spline = op[c4d.ID_USERDATA,1] if spline != None: SplineHelp = c4d.utils.SplineHelp() SplineHelp.InitSpline(spline) offset = SplineHelp.GetOffsetFromReal(time, 0) pos = SplineHelp.GetPos(offset) #print(pos) obj.SetAbsPos(pos) [image: 1598474349417-7854567857885.jpg]