Community
3ds Max Programming
Welcome to Autodesk’s 3ds Max Forums. Share your knowledge, ask questions, and explore popular 3ds Max SDK, Maxscript and Python topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Attach two mesh in c# api

14 REPLIES 14
SOLVED
Reply
Message 1 of 15
elpie89
1219 Views, 14 Replies

Attach two mesh in c# api

Hi all,

I have to attach two mesh and to do it I have to use the .Net API.

Every time I need to find something in the c# API I'm completely lost.

Can I have some help?

Thanks

 

14 REPLIES 14
Message 2 of 15
istan
in reply to: elpie89

I would write a MXS and call it from C# with ExecuteMAXScript()..

Message 3 of 15
elpie89
in reply to: istan

I need to add this feature on the BabylonExporter unfortunately

https://github.com/BabylonJS/Exporters

I need to do it in a proper way or they will never accept the pull request

Message 4 of 15
istan
in reply to: elpie89

So what's the problem to pass a string which is holding the MXS code to a C# function? You'll have to have 3dsmax running anyway..

Message 5 of 15
elpie89
in reply to: istan

Sorry I already had this discussion with someone else, and make me completely upset.

It is not a big priority for me right now, if I want to do it fast I will do it as you said.

But calling max script is a really dirty solution, there is no way to maintain and verify that string in the long term.

 

Message 6 of 15
istan
in reply to: elpie89

I leave it up to you. It was just a suggestion. IMHO maintaining a MXS file is more simple than with C#. E.g. no need to compile against a certain Max Version, no VS debugging necessary, simple interactive development, ..

Message 7 of 15
Anonymous
in reply to: istan

You have to use the epi, Editable Poly interface to do that.

 

To do that, get the node, the ref object, cast it to polyobject then get the interface EPoly. The EPoly interface has the attach method which you can use to attach multiple objects together.

Message 8 of 15
Anonymous
in reply to: Anonymous

Message 9 of 15
elpie89
in reply to: Anonymous

How do you do the conversion?

IEPoly epoly = (IEPoly)myObject.GetInterface( EPOLY13_INTERFACE );

 EPOLY13_INTERFACE does not exist.

Message 10 of 15
Anonymous
in reply to: elpie89

 

class EPolyInterface
{
    private static readonly IGlobal Global = GlobalInterface.Instance;
    public static readonly IInterface_ID EditablePolyInterfaceID = Global.Interface_ID.Create(0x092779, 0x634020);
}

 

 

Message 11 of 15
elpie89
in reply to: Anonymous

I'm trying to do what you say and I get the EditablePoly Interface without problem, thanks to you.

bu this cast should work, instead epoly is always null

What am I missing?

 

IEPoly epoly = (IEPoly)mNode.GetInterface(EPolyInterface.EditablePolyInterfaceID);

Message 12 of 15
elpie89
in reply to: elpie89

So this actually works

IEPoly epoly = (IEPoly)mNode.ActualINode.ObjectRef.GetInterface( Loader.EditablePoly);

Before to do this I need to convert the mesh in a Editable Poly

How can I do it?

Thanks

Message 13 of 15
Anonymous
in reply to: elpie89

For the MNMesh class, there are two methods, which can convert your object to an MNMesh or bact to a Mesh object.

These are the two methods:

 

IMesh m = Global.Mesh;
IMNMesh mn = Global.MNMesh;
mn.OutToTri(m);
mn.SetFromTri(m);
Message 14 of 15
Anonymous
in reply to: Anonymous

But if you have a Mesh object (Editable Mesh), then you can add one mesh object to the other one since the IMesh has an Add method.

 

IMesh mesh1 = Global.IMesh.Create();
IMesh mesh2 = Global.IMesh.Create();

mesh1.Add(mesh2);

And in fact: Doing operations on a mesh object is almost always faster then doing the same on an Editable Poly object. So first do your job first on a Mesh object, then convert it to an EditablePoly object.

Message 15 of 15
elpie89
in reply to: Anonymous

So thanks again, I'm doing some progress understanding how does it work under the hood

But this has still no sense for me

How you see in the watch section seems like the add function doesn't work, or probably I' m missing something else

I'm doing this on a simple teapot

 

Thanks again for your patient

Capture.JPG

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report