ScriptSpot

Forum topic · General Scripting

Toggle xRef Scenes / xRef Objects

By remykonings · 2018-12-05

Description

Hello all,

So of course i'm aware that you can just get to the xRef Scenes / xRef Objects by going through File -> Reference.

But i like to toggle the xRef Scenese / xRef Objects by using a script. I have my own "summary script" in which i like to include them.

So i'm looking for the function to toggle these two, unfortunately i couldn't find these online. Hopefully you can help me :)

Thank you.

Comments (17)

.

miauu · 2018-12-18

Adding xRef Objects to the scene:


(
-- the file from which to load objects as xREf objects
	newSrcFile = @"D:\3D_CAD\scenes\scenes\myTestScene.max"
-- get the names of allobjects in newSrcFile
	allObjInNewSrcFile = getMAXFileObjectNames newSrcFile quiet:true
	-- load all objects as xRef objects
	newXrefObj = xrefs.addNewXRefObject newSrcFile allObjInNewSrcFile
)

Loading xRefScene


(
	newSrcFile = @"D:\3D_CAD\scenes\scenes\myTestScene.max"	
	xrefs.addNewXRefFile newSrcFile 
)

remykonings · 2018-12-18

Haha. Is this all necessary just to open the xRef Scenes window/dialog?

Same for the xRef Objects? I think there is some miscommunication :)

.

miauu · 2018-12-19

Just to open the dialogs use this:


max file xref object

max file xref scene

remykonings · 2018-12-20

Thank you. That is indeed what i was looking for. Although for some reason this doesn’t work though a FileIn function which i’m using.

Do you have any idea how this might work then?

.

miauu · 2018-12-20

Can you show the code that you use along with teh fileIn function?

remykonings · 2018-12-28

Sure. This is the file that i use to call the function.

rollout rollout4 "xRef"
(
button xrefScenes "xRef Scenes" tooltip:"Show all xRefs Scenes" width:90 across:3
button xrefObjects "xRef Objects" tooltip:"Show all xRef Objects" width:90
button copyXref "Copy xRef" tooltip:"Copy the selected xRef" width:90
button toggleXref "Toggle xRef" tooltip:"Toggle xRef" width:90 across:3

on xrefScenes pressed do (
fileIn ("W:\Algemeen\Werknemers\Remy\3Ds Max\Scripts\xRef Scenes\xRef Scene.ms")
)
on xrefObjects pressed do (
fileIn ("W:\Algemeen\Werknemers\Remy\3Ds Max\Scripts\xRef Objects\xRef Objects.ms")
)
on copyXref pressed do (
fileIn ("W:\Algemeen\Werknemers\Remy\3Ds Max\Scripts\Copy xRef\Copy xRef.mcr")
)
on toggleXref pressed do (
fileIn ("W:\Algemeen\Werknemers\Remy\3Ds Max\Scripts\Toggle xRef\Toggle xRef.ms")
)
)

.

miauu · 2018-12-28

Ok. But what is in the xRef Scene.ms for example?

*

remykonings · 2018-12-29

The only thing that is in there is what you wrote me:

max file xref scene

This works well if i just execute the function, just not in combination with the FileIn function.

.

miauu · 2018-12-29

Strange. Here is what I did:
1- open MaxScript Editor and paste this in a new file


(
	max file xref scene
)

2- save the file as xRefOpenFileIn.ms
3- create new file with this code:


macroscript miauuXRefOpenDialog
category:"miauu"
tooltip:"XRefOpenDialog"
buttonText:"XRefOpenDialog"
(
	fileIn @"C:\Users\MyUserName\Desktop\NewFolder\xRefOpenFileIn.ms"
)

and save it as mcrXrefOpenDialog.mcr file
4- drag and drop the mcrXrefOpenDialog.mcr onto 3ds max viewports and assign a hot key to it(Ctrl+T).
Every time when I press the Ctrl+T the XREf Scene dialog appears.

*

remykonings · 2018-12-30

I’ll try it out when i’m at work again in a few days. Besides the fact that you make a macroscript of it, put the function between brackets and that you make a button out of it. It seems all the same. The function is loaded from a file over a network drive but i wouldn’t see why that would be a problem here.

*

remykonings · 2018-12-30

Also, i’m noticing that you use an @ in your FileIn function while i am not. Might that make a difference?

.

miauu · 2018-12-31

There si two ways to use path to folder/files with maxscript:


@"C:\Users\MyUserName\Desktop\NewFolder\xRefOpenFileIn.ms"
-- or
"C:\\Users\\MyUserName\\Desktop\\NewFolder\\xRefOpenFileIn.ms"

Since, copyed path from the Windows explorer not contains "\\" it is easyer to put @ in front of the path and not add \ where it is needed.

*

remykonings · 2019-01-02

Oke it works now.

It seems that the problem was indeed the path.

DOES WORK:
fileIn @"W:\Algemeen\Werknemers\Remy\3Ds Max\Scripts\xRef Scenes\xRef Scenes.ms"

DOESN'T WORK:
fileIn ("W:\Algemeen\Werknemers\Remy\3Ds Max\Scripts\xRef Scenes\xRef Scenes.ms")

Thank you for your help :)

.

miauu · 2019-01-02

I am glad to help.
Happy New Year!!! :)

remykonings · 2018-12-17

I’m sorry that is my fault. I explained it a bit confusing because i wrote Toggle. What I like to just open the xRef Scenes / xRef Objects through maxscript.

Thanks miauu

.

miauu · 2018-12-05

For xRef scene:


(
	xRefScn = xrefs.getXRefFile 1	
	--	"disable"
	xRefScn.disabled = true
	--	"enable"
-- 	xRefScn.disabled = false
)

remykonings · 2018-12-17

I’m sorry that is my fault. I explained it a bit confusing because i wrote Toggle. What I like to just open the xRef Scenes / xRef Objects through maxscript.

Thanks miauu