Itoo Software Forum

RailClone => RailClone Pro (*) => Topic started by: IT1371 on December 09, 2016, 10:17:34 AM

Title: User Library auto-layer & auto-rename?
Post by: IT1371 on December 09, 2016, 10:17:34 AM
Is there way to force any user created items in the library to be automatically assigned to a pre-defined layer and automatically rename the railclone object?
I mean if I have my own style, for example "street lamps", so when I add the railclone object to the scene and choose the style it will automatically create a layer with the name of the style and automatically rename the railclone object to match the style name?

It could be a great time saver in scene organization.
Title: Re: User Library auto-layer & auto-rename?
Post by: Michal Karmazín on December 09, 2016, 12:44:43 PM
Hi,

Please feel to try following script after new RC object import:

newRCLayer = LayerManager.newLayer();
styleNameLong = $.style;
styleNameArray = filterString(styleNameLong) "\\";
styleName = styleNameArray[styleNameArray.count];
newRCLayer.setName styleName;
newRCLayer.addNode $;
$.name = styleName;

It creates a new layer & moves there the RC object, checks the style name (& trims it, when needed) and renames this layer and RC object correspondingly.

Hope you'll find it useful.

Best regadrs,
Title: Re: User Library auto-layer & auto-rename?
Post by: IT1371 on December 14, 2016, 10:12:15 AM
Hi,

Please feel to try following script after new RC object import:

newRCLayer = LayerManager.newLayer();
styleNameLong = $.style;
styleNameArray = filterString(styleNameLong) "\\";
styleName = styleNameArray[styleNameArray.count];
newRCLayer.setName styleName;
newRCLayer.addNode $;
$.name = styleName;

It creates a new layer & moves there the RC object, checks the style name (& trims it, when needed) and renames this layer and RC object correspondingly.

Hope you'll find it useful.

Best regadrs,

This is great! But is there any way to make it automatic? So the script will run automatically when it "realizes" I import a style from a user directory?
Sorry for the late response, we are flooded with work and I just found the time.

-edit-

Just realized that Railclone automatically creates the appropriate layer that was in the source file when loading the style, but the Railclone object stays in the same layer it was created at.
Any way to change that?
Attached video that explains what I mean..

http://sendvid.com/tk6v4jx8
Title: Re: User Library auto-layer & auto-rename?
Post by: Michal Karmazín on December 15, 2016, 01:15:31 PM
Hi,

It's possible to trigger it from the Library Browser by having it added in the header of the corresponding index.xml file for such library in a following way (you'll need to paste it in all libraries you want to behave like that):

<maxscript file="rcNewLayer.ms" script="onItemSelect()" execute_on="item_select"/>

than, the onItemSelect funcition in the rcNewLayer.ms should get the style name from the Library Browser interface by $.catalog.getSelItemName() (instead of the RC object itself as in script posted before):

fn onItemSelect =
   (
   newRCLayer = LayerManager.newLayer();
   styleNameLong = $.catalog.getSelItemName();
   styleNameArray = filterString(styleNameLong) "\\";
   styleName = styleNameArray[styleNameArray.count];
   newRCLayer.setName styleName;
   newRCLayer.addNode $;
   $.name = styleName;
   )

Please find the rcNewLayer.ms attached. Hope that helps.

Best regards,
Title: Re: User Library auto-layer & auto-rename?
Post by: IT1371 on December 16, 2016, 08:44:13 AM
Hi,

It's possible to trigger it from the Library Browser by having it added in the header of the corresponding index.xml file for such library in a following way (you'll need to paste it in all libraries you want to behave like that):

<maxscript file="rcNewLayer.ms" script="onItemSelect()" execute_on="item_select"/>

than, the onItemSelect funcition in the rcNewLayer.ms should get the style name from the Library Browser interface by $.catalog.getSelItemName() (instead of the RC object itself as in script posted before):

fn onItemSelect =
   (
   newRCLayer = LayerManager.newLayer();
   styleNameLong = $.catalog.getSelItemName();
   styleNameArray = filterString(styleNameLong) "\\";
   styleName = styleNameArray[styleNameArray.count];
   newRCLayer.setName styleName;
   newRCLayer.addNode $;
   $.name = styleName;
   )

Please find the rcNewLayer.ms attached. Hope that helps.

Best regards,

exactly what I needed! thank you!