Notifications
Clear all

[Closed] Parenting by pickbutton

I remove the Thread on scriptspot check it out.
in your previous thread one bothers me a lot, believe me i’ve never beg, i ask my questions.
I consider myself as a lazy student in maxscripting and also think that you are as lazy as me but in manner. I respect those who teach me that was why i didn’t swear at you and i respect others knowledge and property that is why i delete the Thread.

End of philosophy class

1 Reply
(@denist)
Joined: 10 months ago

Posts: 0

i don’t care about you posts on ScriptSpot. i didn’t read them.
i just see more and more encrypted scripts on this site, so it becomes less and less helpful as a learning resource.

here is an almost complete solution (i hope so). it might be too complicated for junior mxs codes but i hope it will be interesting any way…

global LinkAttribute = attributes LinkAttribute attribID:#(0x543755e7, 0xa116de52)
(
	fn getAffectedNode = 
	(
		if isvalidobj (owner = custattributes.getowner this) do (refs.dependentnodes owner)[1]
	)
	fn isValidChild obj = (iskindof obj NodeMonitor and isvalidnode obj.node)
	
	local child_handler
	local rename_handler
	fn setNodeMonitorUpdate = 
	(
		if child_handler != undefined do deleteChangeHandler child_handler
		if (node = getAffertedNode()) != undefined do
		(
			child_handler = when children node change id:#link_attrib node do 
			(
				if rename_handler != undefined do deleteChangeHandler rename_handler
				if isValidChild this.child do
				(
					rename_handler = when name this.child.node change id:#link_attrib do 
					(
						this.params.updateChild()
					)
				)
				this.child = if isvalidnode node.children[1] then NodeMonitor node:node.children[1] else undefined
				this.params.updateChild()
			)
		)
	)

	parameters params rollout:params
	(
		child type:#maxObject subAnim:on	
		on child set val do if isValidChild val and (node = getAffectedNode()) != undefined do
		(
			node.children.parent = undefined 
			val.node.parent = node
		)
	)
	rollout params "Current Child" 
	(
		pickbutton ui_child "NONE" width:150 autoDisplay:on tooltips:"Pick a Child"
			
		fn updateChild = 
		(
			ui_child.text = try (child.node.name) catch("NONE")
		)
		on ui_child picked obj do if isvalidnode obj do 
		(
			child = NodeMonitor node:obj
			setNodeMonitorUpdate()
		)
		on params open do
		(
			updateChild()
		)
	)
	on create do setNodeMonitorUpdate()
	on postload do setNodeMonitorUpdate()
	on update do setNodeMonitorUpdate()
)

(
	delete objects
	child1 = box pos:[40,0,0] wirecolor:yellow
	child2 = box pos:[80,0,0] wirecolor:orange

	parent = box isselected:on wirecolor:green 
		
	attr_mod = EmptyModifier name:"Link Attribute Holder"
	custattributes.add attr_mod LinkAttribute
	addmodifier parent attr_mod
	ok
)	

you always free to ask me question if you have any

Interesting you even didn’t read my post and swear at me…??? it seems that i’m talking to a big baby with a good knowledge of Maxscript.

You can, not taking care of sb or someone’s post, do be take care of your tongue (Engage your brain before your mouth).OK big baby

After philosophy class…By the help of paul neal i could do what you did in your script (Actually he did what you did), my problem appears when i want the box which (in your script) you assigned as parent, by hitting a button become a child of an object.

This was my try

———————————————————–==============================


  
  R=teapot pos:[-100,0,0] wirecolor:blue R.name="R_Hand_linker"
  R2=plane pos:[-100,0,0] wirecolor:orange length:80 width:80 R2.name="Main_CNT" 
  r3=box pos:[-70,-120,0] wirecolor:yellow
  r4=box pos:[-40,-120,0] wirecolor:green
  RR=circle pos:[40,0,0] wirecolor:green
  sph=#()
  s1=$R_Hand_linker
  s2=$Main_CNT
  for i = 1 to 2 do
  (
  append sph s1
  append sph s2
  )
  
  def=attributes nodeStore
  (
  	parameters nodesP rollout:nodesR
  	(
  	refNodes type:#maxObjectTab tabSize:0 tabSizeVariable:true
  	theObject type:#node ui:linkObject animatable:false
  	)
  
  		rollout nodesR "Nodes" width:162 height:193
  		(
  
  		local btW=135, btW2=65
  		pickbutton linkObject "Get_parent" pos:[9,14] width:60 height:21 autodisplay: true
  		button firstParent "First_Parent" pos:[80,14] --width:60 height:21
  		local obj01 = undefined--local obj01 = undefined
  
  
  				fn parenting =
  				(
  				s1.parent = obj01
  				)
  				-----------------------------------
  				on firstParent pressed do
  				(
  				s1.parent = s2
  				linkObject.text ="Get_parent"
  				)
  
  				---------------------------------
  
  				on linkObject picked obj do
  				(
  				obj01 = obj
  				parenting()
  
  				)
  		)
  )
  
  ah=(EmptyModifier())
  addModifier RR ah
  custAttributes.add ah def
  
  for s in sph do
  (
  obj=nodeTransformMonitor node:s1  forwardTransformChangeMsgs:false
  append RR.modifiers[1].refNodes obj
  )
  
  

this is the script’s problem

when there is no (s2=$Main_CNT) it works fine and even you rename the (R_Hand_linker) it works well, but when you add second node (i call it a second node) in this script it get crazy.at first it seems it work well but when saving the file and open it again it get crazy ,saying “… attempt to access a deleted scene object”?

i don’t care of because you are a baby… if i was swearing it was only about scriptspot.

only thing i want to say… your solution is very far from mine. like a kindergarten from university. lean mxs and try to do it from right resourcers

Ok denist if you saying so i get completely disappointed for this issue, you mean it is not possible
to store more than one node, or actually by saying (nodetransformMonitor) can watch one object as a node, ok , my only source is (Maxscript help) is there any other reliable source? is it possible doing this in 3ds max, i know, when sth is difficult for you well impossible for me, but In your opinion what should i search.

i believe that this forum is the best resource today to learn max scripting, ask a question, and get a right answer.

There was a misunderstanding for me on 15 post i thought that you said “solving this problem is faraway mine” which i answered “i get completely disappointed for this issue”, defiantly as it names shows ” Weak referencing”, so can we assign multiply node in attribute holder or not.in some script i saw they did that, just like the matrix issue. and i’ve never get angery when hear that i am in the kindergarten of maxscript because it is true.

There was a misunderstanding for me on 15 post i thought that you said “solving this problem is faraway mine” which i answered “i get completely disappointed for this issue …”, defiantly as it names shows ” Weak referencing ” , so can we assign multiply node in attribute holder or not. in some script i saw they did that, just like the matrix issue. and i’ve never get angery when hear that i am in the kindergarten of maxscript because it is true.

would you two please put an stop on swearing and philosophy class.

it is hard for me to ask this way ( please …), but it’s a pity if you leave this tread at this point.consider 305 view it is interesting for others as well i think.

At-least for me this is a very interesting post, as a rigger i’m quite sure that i’’ll face the same problem later.
denisT would you please finish what you’ve started. As rigEater said paul neal solution for this issue was ( weak referencing ) the name is so clear you can’t store more than one node (i work on it when “mirroring pose by another object position” ) but you’ve done it in a better way.is storing a node in attribute holder depends on Pickbutton?, i mean we must have a pick button then
picking an object then store it?, or no we can use button or listbox as well and etc.

In your script if i understand correctly
1_ you store the obj that Pickbutton picked as a node and solve the renaming problem as-well
2_Can you please (as rigeater said) link the parent in your script to sth else or any command you like but on the parent , which if i’m correct, it needs another node monitoring or valuable script line.

I know that this issue is much away higher of my knowledge of scripting but at-least finish what you’ve started for other 305 viewer,

Thanks anyway

NodeMonitor or NodeTransformMonitor is for one node only. if you want to store many nodes in parameter block you have to use several #maxObject type properties or #maxObjectTab

NodeMonitor node is specially designed object to disable sending any notification messages to avoid dependency loop.

it makes every update of anything related to stored node problematic. in my snipped i showed how rename and delete(undo/redo) issues can be solved.

about link/unlink… i don’t see any reason do it using a custom attribute. but if you give me a scenario i can suggest probably a better way to make it.

Page 2 / 3