Exception when copying

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 10 October 2012   #1
Exception when copying

I have a script which calls for a copy of an object. Works fine in most cases but I had a file recently where it threw a system exception on attempt to copy one object. Can't for the life of me figure out why. Does anyone know under what conditions an attempt to run the line ''copy $ '' throws such an error? I mean if the mesh object exists why shouldn't it copy?
I don't care about this particular case - my only concern is that it suspends the script flow and exposes the code which I don't want happening unexpectedly. I need to allow for exceptions.

Last edited by floatingworld : 10 October 2012 at 12:27 AM.
 
Old 10 October 2012   #2
If you are only interested in the geometry you can try using the mesh methods.


NewMesh = Mesh mesh:$.mesh
NewMesh.transform = $.transform


Alternatively you can use try/catch.


try
(
	copy $
)
catch
(
	msg = getCurrentException()
	format "Object: % failed to copy.\n\t%\n" $.name msg
)
__________________
Juan Martinez | Blog | Animator
 
Old 10 October 2012   #3
Hmm even the mesh solution isn't working. Have to get to the bottom of this. I try to avoid try catch clauses - its a sign of poor programming skills
 
Old 10 October 2012   #4
Originally Posted by DannyBoy3: Hmm even the mesh solution isn't working. Have to get to the bottom of this. I try to avoid try catch clauses - its a sign of poor programming skills

i can give many samples where using of try/catch is a sing of master programming skills.
 
Old 10 October 2012   #5
Originally Posted by floatingworld: Does anyone know under what conditions an attempt to run the line ''copy $ '' throws such an error?

'$' means current selection. in case of multiple selection it might be a situation where cross-dependent nodes can be copied only in specific order. a random copy order can cause failure.
the clone function always resolves this situation.
 
Old 10 October 2012   #6
The problem arises when atttempting to copy mesh with morpher modifier. Clone doesnt solve prob...clone as what? If copy, then system exception, I don't want an instance or reference clone.
 
Old 10 October 2012   #7
Originally Posted by floatingworld: The problem arises when atttempting to copy mesh with morpher modifier. Clone doesnt solve prob...clone as what? If copy, then system exception, I don't want an instance or reference clone.

did you try to clone with expandHierarchy ON?
 
Old 10 October 2012   #8
Well that seemed to work. Is it to do with whether or not dependencies of the children are carried forward or not? If so, why isn't this on by default? Thnx once again denis.
 
Old 10 October 2012   #9
Originally Posted by floatingworld: Is it to do with whether or not dependencies of the children are carried forward or not? If so, why isn't this on by default?

by default a list of nodes for copy has to be sorted by 'dependency'. btw it's a good challenge. does anyone know how to sort nodes by dependency? i do.

Last edited by denisT : 10 October 2012 at 07:06 AM.
 
Old 10 October 2012   #10
Originally Posted by denisT: does anyone know how to sort nodes by dependency? i do.
Something like:
(
	clearListener()
	
	fn sortByDependency node1 node2 nds: =
	(
		local pos1 = findItem nds node1
		local s = 0
		for i = pos1+1 to nds.count do
		(
			if (findItem (refs.dependentNodes node1 firstOnly:false baseObjectOnly:false) nds[i] !=0) do s = 1
			if (findItem (refs.dependentNodes nds[i] firstOnly:false baseObjectOnly:false) node1 !=0) do s = -1
		)
		s
	)

	sel = getCurrentSelection()
	format "unsorted:\n%\n" sel
	qSort sel sortByDependency nds:sel
	format "sorted:\n%\n" sel
)

It could probably be optimized but you get the idea...
 
Old 10 October 2012   #11
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 07:54 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.