(SDK) equivalent to mxs "modPanel"

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

REPLY TO THREAD
 
Thread Tools Display Modes
  02 February 2016
(SDK) equivalent to mxs "modPanel"

I swear I have searched for this several times and I can't find anything.

What's the way to get the current object selected in the modify panel through the SDK? The other modpanel commands can help me too (and if it's in SDK.NET, perfect).

Thanks again.
__________________
Andrés FC.
P3D_PathScripts
 
  02 February 2016
GetCurEditObject()
Returns a pointer to the object (or modifier) that is currently being edited in the modifier panel.

You may also want to take a look at the IDerivedObject Class.
__________________
Jorge Rodríguez
PolyTools3D

Last edited by PolyTools3D : 02 February 2016 at 11:59 PM. Reason: Added method and URL
 
  02 February 2016
From MXS you can test it like:
(
 	GlobalInterface = (dotnetclass "Autodesk.Max.GlobalInterface").Instance
 	I7 = GlobalInterface.COREInterface7
 	
 	currObject = I7.CurEditObject
 	
 	format "METHODS\n\n"
 	showmethods currObject
 	
 	format "\n\nPROPERTIES\n\n"
 	showproperties currObject
 	
 	messagebox currObject.Name -- For modifiers
 )

As all methods starting with 'Get' in the SDK, it was implemented as a property in C#, so it is <INTERFACE>.CurEditObject instead of <INTERFACE>.GetCurEditObject().
__________________
Jorge Rodríguez
PolyTools3D
 
  02 February 2016
Thanks a lot, Jorge! That's just what I needed... and much more.
Never thought I had to search directly in the CoreInterface.
There are lot of things accessible from there. In less than 10 years, I'm sure I will be able to do something serious in Max!
__________________
Andrés FC.
P3D_PathScripts
 
  02 February 2016
Here's a code in SDK.NET to get the current object:
        // GetCurrentObject in ModifyPanel
        static public void GetCurrentObject_Test()
        {
            IGlobal global = GlobalInterface.Instance;
            IInterface14 ip = global.COREInterface14;

            IBaseObject modif = ip.CurEditObject;

            if (modif == null)
            {
                //("Modify Panel closed or any node selected");
            }
            else
            {
                Type modifType = modif.GetType();
                string modifTypeName = modifType.Name;

                if (modifTypeName == "OSModifier") //Autodesk.Max.Wrappers.OSModifier
                {
                    //("It's an Object Space Modifier");
                    IModifier theModif = modif as IModifier;
                }
                else
                {
                    if (modifTypeName == "Modifier") //Autodesk.Max.Wrappers.Modifier
                    {
                        //("It's a World Space Modifier");
                        IModifier theModif = modif as IModifier;
                    }
                    else
                    {
                        //("It's the Base Object");
                    }
                }
            }
        }

What is a headache, and haven't got how to do it, it's to get the "dependentnodes" of this modifier.
I have found this code in the SDK help, but I'm not able to convert it to SDK.NET:
INode* GetNodeFromObject(BaseObject* obj) {
  ULONG handle = 0;
  rm->NotifyDependents(FOREVER, (PartID)&handle, REFMSG_GET_NODE_HANDLE);
  INode *node = GetCOREInterface()->GetINodeByHandle(handle);
  return node;
}

My attemp of "translation" is:
        static public IINode GetNodeFromObject(IBaseObject obj)
        {
            IGlobal global = GlobalInterface.Instance;
            IInterface14 ip = global.COREInterface14;

            // make an interval class and set it to forever
            IInterval interval = global.Interval.Create();
            interval.SetInfinite();

            uint handle = 0;
            IReferenceMaker rm = default(IReferenceMaker);
            RefMessage message = (RefMessage)544; //NodeHandle
            SClass_ID sclass = (SClass_ID)16; //GeometryObject
           
            rm.NotifyDependents(interval, (UIntPtr)handle, message, sclass, false, obj); //fails
            IINode node = ip.GetINodeByHandle(handle);
            return node;
        }

But it doesn't work at all.
'NotifyDependents' has more parameters in C# version than in C++, and there's any serious description;

RefResult NotifyDependents(IInterval changeInt, UIntPtr partID, RefMessage message, SClass_ID sclass, bool propagate, IReferenceTarget hTarg);

Any suggestions?
__________________
Andrés FC.
P3D_PathScripts
 
  02 February 2016
Originally Posted by aaandres: ...What is a headache, and haven't got how to do it, it's to get the "dependentnodes" of this modifier...
...Any suggestions?...

The refs structure source code is in the SDK. Take a look at "refs.cpp"
__________________
Jorge Rodríguez
PolyTools3D
 
  02 February 2016
Originally Posted by PolyTools3D: The refs structure source code is in the SDK. Take a look at "refs.cpp"

Thanks for your reply, Jorge.
Sadly, I can't understand anything of what I see there. My know-how of c++ is equal to zero. Not even by intuition I can follow it.
__________________
Andrés FC.
P3D_PathScripts
 
  02 February 2016
look at FindNodeFromBaseObject in the Interface7. it has to work in your case.

but if you want to know all nodes for example that some modifier is applied to, you have to search all its dependents.
 
  02 February 2016
Originally Posted by aaandres: What is a headache, and haven't got how to do it, it's to get the "dependentnodes" of this modifier.
I have found this code in the SDK help, but I'm not able to convert it to SDK.NET:
INode* GetNodeFromObject(BaseObject* obj) {
  ULONG handle = 0;
  rm->NotifyDependents(FOREVER, (PartID)&handle, REFMSG_GET_NODE_HANDLE);
  INode *node = GetCOREInterface()->GetINodeByHandle(handle);
  return node;
}


Any suggestions?


the code above works only for BaseObjects. It can't work for Modifiers (or ReferenceTargets) in general.
 
  02 February 2016
Originally Posted by aaandres:
 
           IReferenceMaker rm = default(IReferenceMaker);
           rm.NotifyDependents(interval, (UIntPtr)handle, message, sclass, false, obj); //fails

But it doesn't work at all.

it has to be not a default ReferenceMaker. It must be the maker made for your object.

but anyway, as i said it works only for BaseObjects.
 
  02 February 2016
Hi DenisT.
Thanks for your help. 'FindNodeFromBaseObject' works fine but, as you said, only retreives one node.

IINode node = ip.FindNodeFromBaseObject(modif);

When you say " It must be the maker made for your object."... is not that (more or less) what I'm looking for?
I'm totaly lost. Please, can you show me the way?
__________________
Andrés FC.
P3D_PathScripts
 
  02 February 2016
what do you want to know? what nodes is a specified modifier applied to?
 
  02 February 2016
there is another statement of the question:
what nodes are depends on a specified modifier?
 
  02 February 2016
Originally Posted by denisT: what do you want to know? what nodes is a specified modifier applied to?

Yes. Or more generally, create a function in C# that does the same than "refs.dependentNodes" in MaxScript.

Originally Posted by denisT: there is another statement of the question:
what nodes are depends on a specified modifier?

I don't understand the question. Sorry.
__________________
Andrés FC.
P3D_PathScripts
 
  02 February 2016
Originally Posted by aaandres: Yes. Or more generally, create a function in C# that does the same than "refs.dependentNodes" in MaxScript.
I don't understand the question. Sorry.


my questions above might have a different answers.

If a modifier is applied to some node this node depends on this modifier.
But if a node depends on some modifier it doesn't automatically mean that this modifier is applied to this node.
See the difference?
 
reply share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 07:24 PM.


Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.