Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    Removing Materials

    Scheduled Pinned Locked Moved SDK Help
    15 Posts 0 Posters 1.3k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 19/12/2009 at 13:26, xxxxxxxx wrote:

      My planet generator creates materials for the different layers of the planet.  When the user deletes the planet object I would like the associated materials to be deleted as well so as to not clog up the material editor.

      Does anyone know how I could do this safely?

      ~Shawn

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 19/12/2009 at 13:48, xxxxxxxx wrote:

        Not unsafe whatsoever.  If there are other dangling materials, not good, but it has no adverse side-affects at all.  I've used it.  The only real problem is that it will create an undo (because it is performing a command).

        You'll need to go through the object's Texture tags, get the materials, and remove/delete them yourself if you want to have atomic control over the process.  This, obviously, will need to be done before deleting the object.  After that, good luck.  The connections (Texture tags) between the object and material will be lost after the object is deleted.  The only way around that would be to store BaseLinks to materials on each of your object somewhere else.

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 19/12/2009 at 13:52, xxxxxxxx wrote:

          I understand how to get to the material and how to remove it..   for example I would use

          textTag->GetMaterial()->Remove();

          but where would I do this so that it only happens when the object is removed from the object manager?

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 19/12/2009 at 14:10, xxxxxxxx wrote:

            As I said, if the user selects the object and deletes it, that is it.  There isn't anything you can do to get the object before it is actually deleted.  It is already too late to know which materials were associated with that object.

            Your only alternative is to track your objects and their materials.  When the user deletes the object, use that tracking information to delete the orphaned materials.  You would probably need to use a SceneHook plugin to scan the document and check to see if an object referenced in your tracking no longer exists in the document.

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 19/12/2009 at 14:13, xxxxxxxx wrote:

              This seemed to work.  When the Planet Object is deleted is seems to call Free()

              void Planet::Free(GeListNode* node)
              {
               
                BaseDocument* doc = node->GetDocument();
                BaseObject* prnt = doc->GetActiveObject();
               
                //Remove Materials when Object is deleted
                if (prnt->GetDown())
                {
                    GePrint("Planet Object Removed");
                    TextureTag* surfaceTag = (TextureTag* )(prnt->GetDown()->GetFirstTag());
                    TextureTag* lightTag = (TextureTag* )(prnt->GetDown()->GetFirstTag()->GetNext());
                    TextureTag* cloudTag = (TextureTag* )(prnt->GetDown()->GetNext()->GetFirstTag());
                    TextureTag* atmTag = (TextureTag* )(prnt->GetDown()->GetNext()->GetNext()->GetFirstTag());
               
                    surfaceTag->GetMaterial()->Remove();
                    lightTag->GetMaterial()->Remove();
                    cloudTag->GetMaterial()->Remove();
                    atmTag->GetMaterial()->Remove();
                }

              }

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 19/12/2009 at 15:12, xxxxxxxx wrote:

                You never mentioned that it was a Plugin object. 🙂

                1 Reply Last reply Reply Quote 0
                • H Offline
                  Helper
                  last edited by

                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                  On 19/12/2009 at 15:47, xxxxxxxx wrote:

                  Woops Sorry...    Thanks for your help Robert.

                  ~Shawn

                  1 Reply Last reply Reply Quote 0
                  • H Offline
                    Helper
                    last edited by

                    THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                    On 19/12/2009 at 15:53, xxxxxxxx wrote:

                    I have another question.   currently, with this plugin object,  the user has to press the CREATE PLANET button for the CreatePlanet() to be called.    I am trying to get CreatePlanet() to be called from init() to skip this button step.

                    currently I am able to get the init() to call Create Planet with,

                    BaseObject* op = static_cast<BaseTag*>(node)->GetObject();

                    CreatePlanet(op,node);

                    however, when it gets in to CreatePlanet() is returns false because I have the following code

                    if (!op)
                          return FALSE;

                    I must be passing op incorrectly to CreatePlanet but I am not sure what I am doign wrong.  Does anyone know how I would do this correctly?

                    Thanks,

                    ~Shawn

                    1 Reply Last reply Reply Quote 0
                    • H Offline
                      Helper
                      last edited by

                      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                      On 19/12/2009 at 18:42, xxxxxxxx wrote:

                      Originally posted by xxxxxxxx

                      This seemed to work.  When the Planet Object is deleted is seems to call Free()

                      Hmm, isn´t that exactly what I said?

                      *thinkingtomyself*Maybe some magic makes my posts invisible? coooool. I have three apes sitting on my chest peeing on me...phew, glad nobody can read this. I am the matrix. I am the matrix. I am the matrix. If I keep on saying this it will come true... *stopthinking*

                      1 Reply Last reply Reply Quote 0
                      • H Offline
                        Helper
                        last edited by

                        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                        On 19/12/2009 at 18:44, xxxxxxxx wrote:

                        Originally posted by xxxxxxxx

                        Not unsafe whatsoever.  If there are other dangling materials, not good

                        Well, I am not sure how you work but I don´t know a single real project that does not have several materials not associated yet. It is simply unsafe and gets worse when materials are hidden in unselected material groups, so the user doesn´t even notice the missing materials. If that´s not unsafe what is unsafe? Actually any action that removes objects the user does not associate with the action (which is the case for unused material flushing) is unsafe, not codewise but from users POV. Einsteins "Do as much as you can but not more than necessary" fits quite well here.

                        1 Reply Last reply Reply Quote 0
                        • H Offline
                          Helper
                          last edited by

                          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                          On 19/12/2009 at 19:36, xxxxxxxx wrote:

                          LOL..   yes 3DDesigner..   That is what you said..   And I appreciate your help too...     🙂
                          hence the use of the free() function    You are the man and I bow to you.   HAHA

                          ~Shawn

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post