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

Can Data channel do this?

12 REPLIES 12
SOLVED
Reply
Message 1 of 13
andresfeho
1948 Views, 12 Replies

Can Data channel do this?

I have trying to do something quite simple with new data channel mod, and is just bringing a selection by material ID (everything ok until this point), and then growing or shrinking the selection, that is actually what I couldn't do inside the data channel. I can use curves and smooth op to chance the radius of the scale, but not the actual selection. 

I found that Genome from thinkbox can do something exactly what I was trying to do, but I really don't know if data channel (that is quite new) is able to do this. 
I leave you the Genome link to illustrate my inquire. 

http://www.thinkboxsoftware.com/gnm-growing-face-selection-mod/

 

Thanks!

Tags (1)
12 REPLIES 12
Message 2 of 13
darawork
in reply to: andresfeho

"Magma Loop nodes"...

I'm already interested on how your query works out.
This is all news to me.

Darawork
AutoDesk User
Windows 10/11, 3DS Max 2022/24, Revit 2022, AutoCad 2024, Dell Precision 5810/20, ASUS DIY, nVidia Quadro P5000/RTX 5000/GTX760

Message 3 of 13
andresfeho
in reply to: darawork

Hey Dara, thanks, I would love to be able to do something like this. I know it seems to be quite simple but it can be pretty handy for vertex paint mask based on vertex selection, and growing or shrinking it can give you a lot of control. I have tried using the maxscript operator but it seems that is not just as simple as writing $.EditablePoly.GrowSelection () or something like that (because I also guess that you have to establish some kind of control to set how many steps you want it to grow or shrink, or if the script will only do the process once and then you have to add multiple maxscript operators to repeat the steps the times you want it, but it seems quite silly)

I really hope someone answer to this post 🙂

Tags (1)
Message 4 of 13
Swordslayer
in reply to: andresfeho

I guess you could do it using the maxscript operator, but since you'd be writing maxscript anyway, a simple maxscript modifier seems as just as good solution and more controllable (you'd have to use custom attributes (most easily added via Parameter Editor) to drive the iterations parameter on the data channel modifier, that would add another rollout to the Data Channel modifier). I made one and attached it as a zip here:

 

growSel.gif

 

Yet another option is using MCG for this, basically the same applies as with the MAXScript modifier.

Message 5 of 13
andresfeho
in reply to: Swordslayer

Hi Swordslayer, thank you very much for your answer and your help (that was pretty fast!). There is something I didn't understand; you're saying that I can use that script but adding that into the data channel modifier? you mean adding the control using the parameter rollout and setting it over the data channel? Sorry if it pretty obvious but I'm not following that instruction. 

In the other hand, have you ever tried writing onto the data channel maxscript operator? because I tried some stuffs on it but I guess that you are limited to the inputs you have at that moment, because it seems pretty clear that you cannot call the EditablePoly interface (they use on the example polyop to call selection to the object) 
I'm pretty noob at coding as you can see, but I really would like to know what are the possibilities with the maxscript operator.

Thanks for the script!

Best

Tags (1)
Message 6 of 13
Swordslayer
in reply to: andresfeho

No, sorry for the confusion, the script is scripted mesh modifier, it uses TriMesh which is quite different from EditablePoly which is used in Data Channel. What I meant was that you could use Parameter Editor to add a parameter to the Data Channel modifier and then use that parameter in the Maxscript operator. But as you'd be using maxscript anyway, it felt more straightforward to me to use scripted modifier directly.

 

I only use polyop whenever I can anyway, so for me that's not a limitation (I also wrote a polyop style Edit poly methods wrapper just because I like polyop so much). The EditablePoly interface is highly dependent on current selection level and modifier panel being active so in general, it's better avoided - in contrast, the polyop methods always work. Growing selection with polyop is done the same way as they do it in the linked Genome example, for example to get the neighbors using edges you'd convert face selection to edges - polyop.getEdgesUsingFace - then convert those edges to faces - polyop.getFacesUsingEdge - and the returned bitarray is the expanded selection. Same applies if you wanted to grow by verts (which is what I used in the modifier).

 

Message 7 of 13
andresfeho
in reply to: Swordslayer

Hi S., sorry but until today I had the chance to check the post. 

Now I get it, I didn't understood that you were telling me to control the parameter from the maxscript operator, but you're right, in that case I can control it from the modifier instead.

Thanks for the full explanation, I never tried before the polyop becase I never checked the properties and options it has. Your tips become pretty handy, I'll try to do by my self the maxscript operator just to practice because for pratical use I can use your approach.

Thanks again for taking the time to answer.

Cheers!

Tags (2)
Message 8 of 13
Swordslayer
in reply to: andresfeho

I checked it and it's actually a bit more involved to make it work in DCM - you cannot use Parameter Editor to add the parameters - well, you can, but in that case, just changing the parameters won't update the result. You'd have to add a notify call in the set handler of the attributes yourself, in that case it works (you can also see the attached file if you are curious). 

 

DCM_notify.gif

Message 9 of 13
andresfeho
in reply to: Swordslayer

Hey S. 

I have downloaded your file to check it out. It is exactly what I was trying to do, just that you added a controller on the modifier. I'm wondering how did you add the controller because inside the script it only do reference to iterations as a variable for the function and the parameter editor is not showing me it (also I don't see the connection between the controller and the script, unless you're doing it by wire parameters, or just calling iterations = inside you're pulling the data? )

I cannot completely understand the script (at least to replicate it), but it works perfect!

Thanks again for everything.

Message 10 of 13
Swordslayer
in reply to: andresfeho

 

Hi, at first I tried adding the custom attributes using the Parameter Editor, which felt like the most userfriendly way to add custom attributes. However, a parameter added this way didn't trigger an update when changed. This is what was happening:

 

DCM_params.gif

 

You can tell that this goes against the interactivity everyone is used to with modifiers in max. So I made my own custom attributes where I added a call to notifyDependents whenever the parameter changes:

 

MXS_CA = attributes "MXS_Params" attribID:#(0x79177be, 0x53ba62b7)
(
	parameters main rollout:params
	(
		numIters type:#integer ui:spnIters
		on numIters set val do notifyDependents this partIDmsg:#select
	)

	rollout params "MAXScript Parameters"
	(
		spinner spnIters "Iterations: " type:#integer range:[0,100,1]
	)
)
custAttributes.add $.modifiers[Data_Channel] MXS_CA

It looks the same way custom attributes generated by the Parameter Editor would look but there's the on numIters set line in addition. What it does is whenever the value of the iterations changes, it triggers an update of the selection of the dependents of the attributes (and since they are added to the Data Channel modifier, it gets that notification).

 

As for the script itself, here we go:

 

on process theNode theMesh elementType outputType outputArray do
(
-- the function to get expanded selection, given the polyMesh, current selection and number of iterations fn growVertSel obj sel iterations = ( for i = 1 to iterations do sel = polyop.getVertsUsingFace obj (polyop.getFacesUsingVert obj sel) return sel ) if theMesh == undefined then return 0 -- no polyMesh to work on, nothing to do here local numVerts = polyop.getNumVerts theMesh if numVerts == 0 then return 0 -- no vertices to work on, nothing to do here
-- we want the DataChannel, since the attributes are extending it, let's get the dependents of the PolyMesh and find one of them of the right type local dcm = for ref in refs.dependents theMesh where isKindOf ref DataChannelModifier do exit with ref
-- I've saved the vertex selection to VData channel 1 with the 1st Vertex Input-Output pair, let's retrieve it (for some reason, you have to add one so we're getting VData channel 2 here)
-- it's just ones and zeroes, so I'm testing each value if it's bigger than one and if it is, collecting that vertex as selected
local vertSel = for v = 1 to numVerts where polyop.getVDataValue theMesh 2 v > 0 collect v
-- now that we have the selection, get the expanded selection bitarray (basically a list of true/false values for each vertex in the mesh)
local grownSel = growVertSel theMesh (vertSel as bitArray) dcm.numIters outputArray.count = numVerts -- these will be the returned vertex values, initialize it to their count

-- for each vertex number, check if its value in the bitarray is set to true and collect either 1 or 0 selection value based on that for i = 1 to numVerts do outputArray[i] = if grownSel[i] then 1. else 0. )
Message 11 of 13
andresfeho
in reply to: Swordslayer

Hi S., I just have read your post. Thanks for the detailed explanation, it is going to take me a while to understand it completely, but is really nice to have it line by line explained. 

I have just one question that probably is to obvious but is just to check. When I started watching at the default script on the maxscript operator, it shows theMesh and some other things that I asume that are the only inputs that I can use inside the maxscript operator on DCM, I'm right?

Thanks again for the detailed explanation you did,

Best

Message 12 of 13
Swordslayer
in reply to: andresfeho

Yes, though as you can see, the modifier itself is not a parameter that's passed to the handler, yet there's still a way to access it (and by extension the attributes assigned to it). And as with scripted controllers, you can assign anything that's also accessible in global scope. Plus there are other things you can access via the polyMesh like vertex/edge/poly flags (there's for example a flag that tells you if the given subobject faces back or not in the current viewport) and so on. There's a lot that can be done with maxscript 🙂
Message 13 of 13
schneck
in reply to: Swordslayer

This script is great and seems to do exactly what I want: with a "Delete Mesh" modifier on top of the stack I want to delete a growing selection over time. I animated the spinner value and everything works fine in the viewport and even when I create a preview of the animation with the grab viewport tool.

But when I try to render the sequence there isn't any progress. I’m unexperienced with the DataChannel Modifier. How can I solve this?

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

Post to forums  

Autodesk Design & Make Report