convert selected object(s) to Xrefs...

Become a member of the CGSociety

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

Thread Tools Search this Thread Display Modes
  01 January 2009
Question convert selected object(s) to Xrefs...

Hi guys,
I want to do thing like the UI button "convert selected object(s) to Xrefs..."
The purpose of this process is swap Object via Xref.
I try the follow code

   boneAry = #($bone01,$bone02)
   saveNodes boneAry "d:\\123.max" quite:true
   bName = for n in boneAry collect
   xrefs.addNewXRefObject "d:\\123.max" bName
  -- change the srcfilename --
  iXref = objXRefMgr.GetRecord 1
  iXref.srcFileName = "d:\\123_new.max"

now I have done convert bone to XrefObj.
Change to the source file that i want.
But it become two bone01 and two bone02 in my scenes, not replace.
I have no idea to do the convert part...
Any one knows ... ?
  01 January 2009

Changing the filename of an xref record shouldn't add new objects to the scene. However, the first part of your code imports the xref with the original nodes still in the scene. Simply delete the nodes after saving should fix that:
boneAry = #($bone01, $bone02)
if saveNodes boneAry "d:\\123.max" quiet:true then
    bName = for n in boneAry collect
    if xrefs.addNewXRefObject "d:\\123.max" bName != undefined then
        delete boneAry
    ) -- else addNewXRefObject failed
) -- else saveNodes failed

-- change the srcfilename --
--iXref = objXRefMgr.GetRecord 1
--iXref.srcFileName = "d:\\123_new.max"

  01 January 2009
Thank's for reply!
but my situation is more complicated
because there is a obj have skin modifier refer to the bones.
so i can't delete the origin bone... i need exactly the UI button do, "convert it to Xref...",
I still can't find a way to do it.
Maybe I need to save my skin data to file. Remove the skin mod than add it with new Xref Bone...

but there is a small should in my mind say...the sould be a smart way.

Last edited by NoFlame : 01 January 2009 at 04:13 AM. Reason: some word worng
  01 January 2009
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
Society of Digital Artists

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

All times are GMT. The time now is 04:45 AM.

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