Multiple copy like in Revit


#1

I’ve decided to create another Thread instead of this

   [http://forums.cgsociety.org/showthread.php?f=98&t=1110150](http://forums.cgsociety.org/showthread.php?f=98&t=1110150)
   
   because now, after investigating, and trying to script I understood what  I want! It is Multiple Copy! Here is a small video that displays how is  it in Revit (for those that didn't use it yet) and what I've achieved  through script!
   
   [VIDEO](http://artrender.info/tmpmike/Untitled/index.html)
   
   1: I love in revit the box around the object when copying and the line  with distance, also the possibility to make multiple copies! This line  may be the line when we copy in max with snap switched on! It would be  great to make such a tool like dimension (distance)!
   2: Max screen
   2.a common copying principle with "Clone Options" dialog!
   2.b here I use a script with "h" hotkey:
(
       	fn CopyClick =
       		try
       		(
       			maxOps.cloneNodes $ cloneType:#instance newNodes:&nnl
       			select nnl
       			print "Copied, now Move!!!"
       		)
       		catch
       		(
       			delete $
       		)--End Function
       	CopyClick()
       )--End Script
       
   It makes a clone copy in place (thx to Swordsplayer for the idea), but  it has a minus - if you press on hot key (h) a little longer, then you  can get a lot of objects in place and if your objects are heavy - it  means your scene will slow down and ....
   Another minus of it is that you have to press on h each time to copy!
   
   2.c there is a good [script by agg3d at scriptspot](http://www.scriptspot.com/3ds-max/scripts/copyclick)
(
       	fn CopyClick =
       		try
       		(
       			maxOps.cloneNodes $ cloneType:#instance newNodes:&nnl
       			select nnl
       			Sel=selection
       			p = point pos:Sel.center
       			p.pos.z = 0
       			ClickPos = pickPoint snap:#2D ()
       			ArrayFiltroGroupHead = #()
       			for obj in Sel do
       			(
       				result = isGroupHead obj
       				result1 = isGroupMember obj
       				if result == true and result1 == false then
       				(
       					append ArrayFiltroGroupHead obj
       					obj.parent = p
       				)
       				if result1 == false then
       				(
       					obj.parent = p
       				)
       			)-- Fim Loop
       			p.pos = ClickPos
       			delete p
       			CopyClick()
       		)
       		catch
       		(
       			delete p
       			delete $
       		)--End Function
       
       	CopyClick()
       
       )--End Script
   But it works only once, after this it stops and you have restart max in order to have it working! 
   
   I have tried to close the window "Clone Options" with a timer
global theTimer
       	  fn onTick =
       	  (
       		  try(
       				  local RollOutHandle = (windows.getChildHWND 0 "Clone Options" )[1] 
       				  UIAccessor.PressButtonByName RollOutHandle "OK"	
       			  )
       		  catch()
       	  )
       	  theTimer = dotNetObject "System.Windows.Forms.Timer";
       	  theTimer.interval = 1; --ms
       	  dotnet.addEventHandler theTimer "tick" onTick
       	  theTimer.start()
       	  --theTimer.Stop()
   the window is flickering - appears and quickly dissapears, which is not  good! Except this, you have to copy again, using hot key at every copy!
   
   So, 2.c is better, but it has to be improved! Please, if you find it interesting and useful the write down some ideas!

If you watch the VIDEO from above you will understand what is 1, 2 (a-c)


#2

A good idea would be the object to be copied, then moved along with the cursor (may be with box like in revit or see through) till another place where you click (and here the object becomes non see through) and another object is copied and moved along the cursor! When right click, the operation is stopped! The movement I think should be only on x and y axes!


#3

you probably don’t believe but it’s pretty easy to make this tool :wink: let me try…


#4

If you said that, then we can forget about such probabilities! I know you will do!


#5

also an additional option would be to rotate the object before placing with the wheel of the mouse with an angle mentioned in “angle snapped option” from max menu! so, when you copy - the object is moving along - if you still didn’t press left click but rotate the wheel, then your object is rotating, once you pressed left click - it is placed rotated, if right click => stop multycopy action!!!


#6

You can try to do it yourself. :slight_smile:
Check maxscript help file for “Scripted Mouse Tools” and start writhig. :slight_smile:


#7

Maybe this tool


#8

ok… here is quick and dirty code… but i hope it’s a good start:


try(destroydialog cloneObjectsDialog) catch()
rollout cloneObjectsDialog "Clone Selection" width:200
(
	local clonednodes = #(), clonenodes = #(), newnodes = #()
	local lasmessage, cloning = off, clonepoint, mousepoint, center
	
	label clonetype_lb "Clone Type:" across:2 align:#right offset:[0,4]
	radiobuttons clonetype_rb labels:#("Copy", "Instance", "Reference") align:#left offset:[8,3]
	checkbox hierarchy_cb "Expand Hierarchy" checked:on

	checkbutton startclone_bt "Clone" width:190 align:#right offset:[8,4]
	
	fn getCloneType = case clonetype_rb.state of
	(
		1: #copy
		2: #instance
		3: #reference
	)
	fn mouseTracking msg ir obj face shift ctrl alt = 
	(
		wp = ir.pos
		mp = mouse.pos
		
		case msg of
		(
			#mouseAbort: ()
			#freeMove: ()
			#mousePoint: 
			(
				cloning = off
			)
			#mouseMove: 
			(
				if not cloning then
				(
					clonepoint = center = wp
					mousepoint = mp
					cloning = on
					offset = (clonepoint - selection.center)
					maxops.clonenodes clonenodes offset:offset expandHierarchy:hierarchy_cb.state cloneType:(getCloneType()) newNodes:&newnodes
					join clonednodes newnodes
				)
				else 
				(
					delta = wp - clonepoint
					angle = mp.y - mousepoint.y
					case of 
					(
						(shift): about center scale newnodes ([1,1,1] + 0.01*angle)
						 (ctrl): about center rotate newnodes (angleaxis angle ir.dir)
						default: 
						(
							move newnodes delta
							center = wp
						)
					)
					clonepoint = wp
					mousepoint = mp
				)
			)
		)

		lasmessage = msg
		if msg == #mouseAbort then 
		(
			startclone_bt.checked = off
			#abort 
		)
		else #continue 
	)	
	on startclone_bt changed state do
	(
		if selection.count > 0 and state then
		(
			clonenodes = selection as array
			clonednodes = #()
			act = mouseTrack trackCallback:mouseTracking snap:#3D
		)
		else 
		(
			toolmode.commandmode = #select
			startclone_bt.checked = off
		)
	)
	on cloneObjectsDialog close do toolmode.commandmode = #select 
)
createdialog cloneObjectsDialog pos:[800,300]

with left mouse button down - clone and move, with control - rotate, with shift - scale…
right click, escape, button check off, or close dialog - abort


#9

much easier to do it with geometry plug-in http://forums.cgsociety.org/showpost.php?p=7598766&postcount=1


#10

OK! Thank you so much, my friends! I will take a look and let you know later! Thank you for your efforts! I appreciate very much what you do and that you support and help even new users of maxscript!


#11

Denis, you have done a very good script! In fact I can use it as it already is, but I will try to add some more options (of course I don’t know how quick it will be, but I will try)!

Now here is VIDEO2

It’s bad that they didn’t make it work like in Revit

If you see here, there is that line and when you move the object, it tends to orient along axes x or y (it’s likely scanning the angle, if it is very small, then it’s moving straight)
The second, is that it allows you, during moving to write down on your keyboard the distance manually, and if you hit enter, it moves to that distance!

Please, tell me - is it possible to put a value somehow like in video? could you point me to the place I can find this?

Thx anyone who participated!


#12

I have a script that allows you to set the distance between clones. You can see how it works here. :slight_smile:


#13

I’ve noticed this script long time ago! It’s very nice!!! you’re brave :wink:


#14

but I would like to have the possibility during copying/moving to just put down the distance/hit enter and the object to move to that point - like in revit!


#15

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.