Message 1 of 3
MaxScript execution behavior via command
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I try to avoid MaxScript in my C# plugin, but sometimes I'm lazy 🙂
I pass MaxScript execution in command and string crashes Max. If I increase Initial MaxScript heap allocation to 512MB - all Ok. Strange...
If I change string interpolation to string format - Ok with smaller heap. Also very strange...
public ICommand OpenShortFileInMaxCommand
{
get
{
return _OpenShortFileInMaxCommand ?? (_OpenShortFileInMaxCommand = new RelayCommand<object>(it =>
{
if (!(it is IMatLabCSshortItem)) return;
if (SelectedShortScItem == null) return;
if (!IsShortcutFileExists) return;
if (string.IsNullOrEmpty(SelectedShortScItem.ScenePath)) return;
var fileExt = Path.GetExtension(SelectedShortScItem.ScenePath);
if (fileExt != ".max")
{
return;
}
if (MaxCore.Core.CheckForSave)
{
MaxscriptSDK.ExecuteMaxscriptCommand($"loadMaxFile (@\"{SelectedShortScItem.ScenePath}\") useFileUnits:true quiet:true");
}
},
it =>
{
if (!(it is IMatLabCSshortItem))
{
return false;
}
if (string.IsNullOrEmpty(SelectedShortScItem?.ScenePath))
{
return false;
}
if (IsShortcutFileExists == false)
{
return false;
}
var fileExt = Path.GetExtension(SelectedShortScItem.ScenePath);
return fileExt == ".max";
}));
}
}
Example of string format:
MaxscriptSDK.ExecuteMaxscriptCommand(string.Format("loadMaxFile (@\"{0}\") useFileUnits:true quiet:true", SelectedShortScItem.ScenePath));