public static object Query(string command, QueryType qType, params object[] args) { string formatCommand = MaxscriptSDK.AssembleScript(command, args); //string formatCommand = String.Format(command, args); if (qType == QueryType.Integer) { return(MaxscriptSDK.ExecuteIntMaxscriptQuery(formatCommand)); } else if (qType == QueryType.Float) { return(MaxscriptSDK.ExecuteFloatMaxscriptQuery(formatCommand)); } else if (qType == QueryType.String) { return(MaxscriptSDK.ExecuteStringMaxscriptQuery(formatCommand)); } else if (qType == QueryType.Boolean) { return(MaxscriptSDK.ExecuteBooleanMaxscriptQuery(formatCommand)); } else { return(MaxscriptSDK.ExecuteColorMaxscriptQuery(formatCommand)); } }
public static void Execute(string mxs) { try { MaxscriptSDK.ExecuteMaxscriptCommand(mxs); } catch { OnError("Couldn't Execute: " + mxs); } }
public static string Command(string command, params object[] args) { string formatCommand = MaxscriptSDK.AssembleScript(command, args); if (Execute) { MaxscriptSDK.ExecuteMaxscriptCommand(formatCommand); } if (OutputCommands) { output.Add(formatCommand); } return(formatCommand); }
private static void ResolveMultipleInheritedContainer(IIContainerObject container) { int b = 0; if (container.ContainerNode.GetUserPropBool("flightsim_resolved", ref b)) { return; } string helperPropBuffer = string.Empty; container.BabylonContainerHelper().GetUserPropBuffer(ref helperPropBuffer); List <IINode> containerHierarchy = new List <IINode>() { }; containerHierarchy.AddRange(container.ContainerNode.ContainerNodeTree(false)); int containerID = 1; container.ContainerNode.GetUserPropInt("babylonjs_ContainerID", ref containerID); int idIndex = container.ContainerNode.Name.LastIndexOf("_"); string firstContainer = container.ContainerNode.Name.Substring(0, idIndex); IINode firstContainerObject = Loader.Core.GetINodeByName(firstContainer + "_1"); if (firstContainerObject == null) { MessageBox.Show("ERROR resolve ID with FlightSim/BabylonUtilities/UpdateContainerID"); return; } //manage multiple containers inherithed from the same source foreach (IINode n in containerHierarchy) { if (n.IsBabylonContainerHelper()) { continue; } //change the guid of the node //replace the guid in the babylon helper string oldGuid = n.GetStringProperty("babylonjs_GUID", Guid.NewGuid().ToString()); n.DeleteProperty("babylonjs_GUID"); Guid newGuid = n.GetGuid(); helperPropBuffer = helperPropBuffer.Replace(oldGuid, newGuid.ToString()); n.Name = $"{n.Name}_{containerID}"; if (n.Mtl != null && FlightSimMaterialUtilities.HasFlightSimMaterials(n.Mtl) && FlightSimMaterialUtilities.HasRuntimeAccess(n.Mtl)) { if (n.Mtl.IsMultiMtl) { throw new Exception($@"Material {n.Mtl.Name} has a property ""Unique In Container"" enabled, cannot be child of a multi material"); } else { string cmd = $"mNode = maxOps.getNodeByHandle {n.Handle} \r\n" + $"newMat = copy mNode.material \r\n" + $"newMat.name = \"{n.Mtl.Name}_{containerID}\" \r\n" + $"mNode.material = newMat"; MaxscriptSDK.ExecuteMaxscriptCommand(cmd); } } } //replace animationList guid to have distinct list of AnimationGroup for each container string animationListStr = string.Empty; container.BabylonContainerHelper().GetUserPropString(s_AnimationListPropertyName, ref animationListStr); if (!string.IsNullOrEmpty(animationListStr)) { string[] animationGroupGuid = animationListStr.Split(AnimationGroup.s_PropertySeparator); foreach (string guidStr in animationGroupGuid) { Guid newAnimGroupGuid = Guid.NewGuid(); helperPropBuffer = helperPropBuffer.Replace(guidStr, newAnimGroupGuid.ToString()); } container.BabylonContainerHelper().SetUserPropBuffer(helperPropBuffer); //add ID of container to animationGroup name to identify animation in viewer container.BabylonContainerHelper().GetUserPropString(s_AnimationListPropertyName, ref animationListStr); string[] newAnimationGroupGuid = animationListStr.Split(AnimationGroup.s_PropertySeparator); foreach (string guidStr in newAnimationGroupGuid) { string propertiesString = string.Empty; if (!container.BabylonContainerHelper().GetUserPropString(guidStr, ref propertiesString)) { return; } string[] properties = propertiesString.Split(AnimationGroup.s_PropertySeparator); if (properties.Length < 4) { throw new Exception("Invalid number of properties, can't deserialize."); } string name = properties[0]; if (!string.IsNullOrEmpty(name)) { propertiesString = propertiesString.Replace(name, name + "_" + containerID); container.BabylonContainerHelper().SetUserPropString(guidStr, propertiesString); } } } container.ContainerNode.SetUserPropBool("flightsim_resolved", true); }
public static string Point3Literal(Vector3 v) { return(MaxscriptSDK.AssembleScript("[{0}, {1}, {2}]", v.X, v.Y, v.Z)); }
public static string Point3Literal <T>(T X, T Y, T Z) { return(MaxscriptSDK.AssembleScript("[{0}, {1}, {2}]", X, Y, Z)); }
public static string QuatLiteral(Quaternion q) { return(MaxscriptSDK.AssembleScript("quat {0} {1} {2} {3}", q.X, q.Y, q.Z, q.W)); }
public static string NewMeshLiteral(string name, string vertArray, string faceArray, string faceMatIdArray, string texVertArray) { return(MaxscriptSDK.AssembleScript("mesh name:\"{0}\" vertices:{1} faces:{2} materialIDs:{3} tverts:{4}", name, vertArray, faceArray, faceMatIdArray, texVertArray)); }
public override void RunPythonCommand(string command) { var pythonCommand = $"python.Execute \"{command}\""; MaxscriptSDK.ExecuteMaxscriptCommand(pythonCommand); }