LC #42 Pipers Alley

View Full Version : Cloning a reference to an equivalent reference...

04-05-2012, 01:31 PM
I would like to solve the problem from :

I have a object with this stack:
modifier B
modifier A
Editable Poly

I would like to create a new Reference from this, with the same position of the derived-object line: modifier A is a instance and modifier B is a copy...

Based on the code from i have this:
fn refCopy source_obj =
-- Create a point as base for the copy and assign a uniquename
new_obj = point name:(uniqueName

-- Put in same place as old object
new_obj.transform = source_obj.transform

-- Give it a clean base to add Modifiers to
new_obj.baseObject = copy source_obj.baseObject

-- Get modifier count
modC = source_obj.modifiers.count

-- Make sure there are modifiers
if modC != 0 then
-- Loop through all modifiers and copy them backwards (topmost is nr1!)
for i in 1 to ModC do
-- Copy the modifier before the last
addModifier new_obj ( copy source_obj.modifiers[i] ) before:i

-- Instance base object only, leaving mods
new_obj.baseObject = source_obj.baseObject

-- Return the new object

with undo on (
newObject = refCopy selection[1]
select newObject

But this would create a new object with this stack:
modifier B
modifier A
Editable Poly

Because all modifiers are copies...

CGTalk Moderation
04-05-2012, 01:31 PM
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.