PolyTools3D, indeed, the IObjectWrapper looks very promising, I didn’t even know there as such a thing to begin with. This is why the docs should have a couple of examples presenting the basic functionality and ways to achieve it.
Excuse my next question, but I’m really fresh to this whole C# and even if I know how to write some basic code, this somehow escapes me (and I don’t have a C# guru to pray to yet): how do I create a IObjectWrapper object from a INode / IObjectState / an object in the scene? Using those interfaces is a bit mysterious to me at this moment…
You have an example in this thread (post #11):
http://forums.cgsociety.org/showthread.php?t=1138801
//Prepare object
IINode node = global.COREInterface.GetINodeByHandle(handle);
IObjectState os = node.EvalWorldState(0, true);
IObjectWrapper ow = global.ObjectWrapper.Create();
ow.Init(0, os, false, 0, 0);
//Get verts/faces
int vertsNum = ow.NumVerts;
int facesNum = ow.NumFaces;
Here’s a part of my mxs/c#sdk function for meshop.getElementsUsingFace replacement.
Is there any faster method available for converting IBitarray to maxscript bitarray?
...
IBitArray = g.BitArray.Create IMesh.NumFaces_
IBitArray.ClearAll()
IMesh.ElementFromFace ((firstBit faces)-1) IBitArray IAdjFaceList
IMesh.FaceSel = IBitArray
elementFaces = getFaceSelection obj
faces -= elementFaces
...
Sure, I did my tests on a ~100k mesh and got these numbers:
[quote=]getEditableMeshElementsSDK() Time: 2.591sec. Mem: 680928L
getEditableMeshElements() Time: 205.979sec. Mem: 681248L
Both of functions seem to produce identical results.
Don’t quite understand what I should compare, so here’re my functions.
fn getEditableMeshElementsSDK obj = (
fn firstBit bits = (
local b
for n in bits while not (b = n; bits[n]) do ()
b
)
local g = (dotnetclass "Autodesk.Max.GlobalInterface").Instance
local INode = g.COREInterface14.GetINodeByHandle obj.inode.handle
local IMesh = (INode.EvalWorldState 0 true ).Obj.Mesh_
local IAdjFaceList = g.AdjFaceList.Create IMesh (g.AdjEdgeList.Create IMesh)
local IBitArray = g.BitArray.Create IMesh.NumFaces_
local faces = #{1..obj.numfaces}
local elements = #()
-- CACHED FUNCTIONS
local IMeshElementFromFace = IMesh.ElementFromFace
local IBitArrayClearAll = IBitArray.ClearAll
while not faces.isEmpty do (
IBitArrayClearAll()
IMeshElementFromFace ((firstBit faces)-1) IBitArray IAdjFaceList
IMesh.FaceSel = IBitArray
elementFaces = getFaceSelection obj
faces -= elementFaces
append elements elementFaces
)
elements
)
fn getEditableMeshElements obj = (
fn firstBit bits =
(
local b
for n in bits while not (b = n; bits[n]) do ()
b
)
local faces = #{1..obj.numfaces}
local meshopgetElementsUsingFace = meshop.getElementsUsingFace
local elements = #()
while not faces.isEmpty do (
element = meshopgetElementsUsingFace obj (firstBit faces)
append elements element
faces -= element
)
elements
)
Have you seen this thread?
http://forums.cgsociety.org/showthread.php?p=8027554#post8027554
I definitely have seen it before, thx. Feel like reinventing the wheel
I’m trying to create CustomAttrib using SDK-NET.
I really need help. Problems I have:
- How to define the descriptor (or the plugin) to get right parameters names (the track view show really extrange names)
- When saving the scene in 3dsMax, the customAttrib is saved but the parameters values are the ones from creation, not the modified ones.
The C# code:
http://www.proin3d.org/pathscripts/DOWNLOAD/TEMP/CustomAttrib-01.cs
The compiled dll (must change the extension from ._dll to .dll)
http://www.proin3d.org/pathscripts/DOWNLOAD/TEMP/CustomAttrib._dll
The maxscript to test it (must change the path for loading the dll):
http://www.proin3d.org/pathscripts/DOWNLOAD/TEMP/NET_CustomAttrib-01.ms
Any help will be wellcomed. I’m absolutely new with SDK plugins and its Descriptors.