private void Itm_Renamed(object sender, MFnDagNode dagNode) { //ToDo: get the rename system working var dag = (DMLocator)sender; if (SelectedItems.ContainsKey(dag.dagName)) { string newName = dagNode.partialPathName; string oldName = dag.dagName; isFromUpdate = true; SelectedItems.Remove(oldName); locatorName.Remove(oldName); mayaLocator.Remove(oldName); var DMLocator = new DMLocator(dagNode.dagPath, m_mSpace); SelectedItems.Add(newName, DMLocator); buildAstNodes(newName); rebuildItemNameList(); OnNodeModified(true); } dag.Dispose(); }
internal void GetNewGeom() { // VMDataBridge.DataBridge.Instance.UnregisterCallback(GUID.ToString()); if (firstRun) { firstRun = false; } else { if (SelectedItems != null) { foreach (var itm in SelectedItems.Values) { itm.Dispose(); } } } MSelectionList selectionList = new MSelectionList(); MGlobal.getActiveSelectionList(selectionList, true); if (selectionList.isEmpty) { SelectedItems = null; OnNodeModified(true); return; } var TransObjectList = selectionList.DagPaths(MFn.Type.kTransform).ToList(); var DagObjectList = selectionList.DagPaths(MFn.Type.kLocator).ToList(); SelectedItems = new Dictionary <string, DMLocator>(DagObjectList.Count); m_SelectedItemNames = new List <string>(DagObjectList.Count); foreach (var dag in TransObjectList) { if (dag.hasFn(MFn.Type.kLocator)) { var itm = new DMLocator(dag, space); itm.Renamed += Itm_Renamed; itm.Deleted += MObjOnDeleted; SelectedItems.Add(itm.dagName, itm); m_SelectedItemNames.Add(itm.dagName); // ct++; } } m_SelectedItemNamesString = ConvertStringListToString(m_SelectedItemNames); OnNodeModified(true); }
public static bool processGeometry(object geom, string name, string groupName) { bool sucess = true; if (geom is Curve) { DMCurve.ToMaya((Curve)geom, name); } else if (geom is Rectangle) { DMCurve.ToMaya((Rectangle)geom, name); } else if (geom is Surface) { DMSurface.ToMaya((Surface)geom, name, groupName); } else if (geom is CoordinateSystem) { DMLocator.ToMaya((CoordinateSystem)geom, name); } else if (geom is Mesh) { DMMesh dmMesh = new DMMesh(); dmMesh.ToMaya((Mesh)geom, name); } else if (geom is TSplineSurface) { DMMesh dmMesh = new DMMesh(); dmMesh.ToMayaFromTSplinesSurf((TSplineSurface)geom, name); } else if (geom is CoordinateSystem) { DMLocator.ToMaya((CoordinateSystem)geom, name); } else if (geom is Point) { DMLocator.ToMaya((Point)geom, name); } else { sucess = false; } return(sucess); }
internal void MObjOnChanged(object sender, MFnDagNode dagNode) { if (!isUpdating) { isUpdating = true; var dag = new DMLocator(dagNode.dagPath, space); // if (liveUpdate) // { isFromUpdate = true; if (SelectedItems.ContainsKey(dag.dagName)) { SelectedItems[dag.dagName] = dag; dynamoObject[dag.dagName] = AstFactory.BuildFunctionCall( dynamoElementFunc, new List <AssociativeNode> { AstFactory.BuildStringNode(dag.dagName), AstFactory.BuildStringNode(m_mSpace) }); /* * mayaLocator[dag.dagName] = AstFactory.BuildFunctionCall( * MayaElementFunc, * new List<AssociativeNode> * { * AstFactory.BuildStringNode(dag.dagName), * AstFactory.BuildStringNode(m_mSpace) * }); */ } OnNodeModified(true); } }
private void DeserializeNameList(string nameListString) { var splitNames = nameListString.Split(','); if (splitNames.Length > 0) { SelectedItems = new Dictionary <string, DMLocator>(splitNames.Length); foreach (var name in splitNames) { try { var itm = new DMLocator(DMInterop.getDagNode(name), space); itm.Deleted += MObjOnDeleted; itm.Changed += MObjOnChanged; SelectedItems.Add(itm.dagName, itm); } catch { Warning($"Object {name} does not exist or is not valid"); } } } }