| |  | Gut zu wissen: Hilfreiche Tipps und Tricks aus der Praxis prägnant, und auf den Punkt gebracht für Autodesk Produkte | | |  | PNY präsentiert die PRO Elite™ High Endurance microSD-Flash-Speicherkarten für Videoüberwachung und kontinuierliche Aufzeichnung, eine Pressemitteilung
|
Autor
|
Thema: Toolbar per Code platzieren (572 / mal gelesen)
|
Mario Rosenbohm Mitglied Vermessungsingenieur
 
 Beiträge: 121 Registriert: 09.10.2003 AutoCAD Civil 3D 2022 CADdy V.17 Laptop Win10 Intel i7 2.71GHz, 64GB Ram
|
erstellt am: 05. Mai. 2022 08:50 <-- editieren / zitieren --> Unities abgeben:         
Hallo, ich versuche, eine/die Toolbar/s per Programcode um die Zeichenfläche herum zu platzieren. Dies gelingt mit nicht. Wenn ich das ganze in dem CUI-Editor mache, legt AutoCAD die Toolbar an die gewünschte Position. Wird das ganze im Plugin(Code) erledigt tut sich nichts. Obwohl in der CUI die gleichen Werte gesetzt sind, wie durch das Editieren der CUI im Editor. Habe ich irgend etwas vergessen? Im Code sind einige eigene Datenklassen benutzt, aber er sollte lesbar sein. Code: public static CustomizationSection placeToolbars(clToolbarPlaces tbPlaces) { CustomizationSection csMain = null; if ((tbPlaces != null) && (tbPlaces.CheckedToolbarIds.Count > 0)) { string user = Environment.UserName; clUserPlace userPlace = null; // search user defined saved places if ((tbPlaces.UserPlaces != null) && (tbPlaces.UserPlaces.Count > 0)) { foreach (clUserPlace up in tbPlaces.UserPlaces) { if (up.Description.Equals(user)) { userPlace = up; break; } } } // otherwise use default if (userPlace == null) userPlace = tbPlaces.DefaultPlace; if ((userPlace.Places != null) && (userPlace.Places.Count > 0)) { String mainCuixName = (Application.GetSystemVariable("MENUNAME") as String) + ".cuix"; csMain = new CustomizationSection(mainCuixName, false); if (csMain != null) { string cuWorkspaceName = (string)Application.GetSystemVariable("WSCURRENT"); Workspace cuWorkspace = csMain.getWorkspace(cuWorkspaceName); if (cuWorkspace != null) { // First remove the workspace toolbars foreach (clToolbarPlace tbPlace in userPlace.Places) { if ((tbPlace != null) && (tbPlaces.CheckedToolbarIds.ContainsKey(tbPlace.ID))) { foreach (String partCuiFName in csMain.PartialCuiFiles) { if (partCuiFName.ToLower().Contains(tbPlaces.CheckedToolbarIds[tbPlace.ID].CuiName.ToLower())) { CustomizationSection csPart = new CustomizationSection(partCuiFName); Toolbar tbFind = csPart.MenuGroup.Toolbars.FindToolbarWithName(tbPlaces.CheckedToolbarIds[tbPlace.ID].Name); if (tbFind != null) { WorkspaceToolbar wsToolbar = cuWorkspace.WorkspaceToolbars.FindWorkspaceToolbar( tbFind.ElementID, csPart.MenuGroup.Name); if (wsToolbar != null) { wsToolbar.Display = 0; cuWorkspace.WorkspaceToolbars.Remove(wsToolbar); } } } } } } //if (csMain.IsModified) csMain.Save(); // now set the position in partial cui and create new workspacetoolbars Dictionary<string, CustomizationSection> changedCUIS = new Dictionary<string, CustomizationSection>(); foreach (clToolbarPlace tbPlace in userPlace.Places) { if ((tbPlace != null) && (tbPlaces.CheckedToolbarIds.ContainsKey(tbPlace.ID))) { clToolbarId tbId = tbPlaces.CheckedToolbarIds[tbPlace.ID]; if (tbId != null) { foreach (String partCuiFName in csMain.PartialCuiFiles) { if (partCuiFName.ToLower().Contains(tbId.CuiName.ToLower())) { CustomizationSection csPart = new CustomizationSection(partCuiFName); Toolbar tbFind = csPart.MenuGroup.Toolbars.FindToolbarWithName(tbId.Name); if (tbFind != null) { switch (tbPlace.Side) { case "T": tbFind.ToolbarVisible = ToolbarVisible.show; tbFind.ToolbarOrient = ToolbarOrient.top; tbFind.XCoordinate = tbPlace.RowCol; tbFind.YCoordinate = tbPlace.Order; break; case "B": tbFind.ToolbarVisible = ToolbarVisible.show; tbFind.ToolbarOrient = ToolbarOrient.bottom; tbFind.XCoordinate = tbPlace.RowCol; tbFind.YCoordinate = tbPlace.Order; break; case "L": tbFind.ToolbarVisible = ToolbarVisible.show; tbFind.ToolbarOrient = ToolbarOrient.left; tbFind.YCoordinate = tbPlace.RowCol; tbFind.XCoordinate = tbPlace.Order; break; case "R": tbFind.ToolbarVisible = ToolbarVisible.show; tbFind.ToolbarOrient = ToolbarOrient.right; tbFind.YCoordinate = tbPlace.RowCol; tbFind.XCoordinate = tbPlace.Order; break; case "F": tbFind.ToolbarVisible = ToolbarVisible.show; tbFind.ToolbarOrient = ToolbarOrient.floating; tbFind.XCoordinate = tbPlace.Order; tbFind.YCoordinate = tbPlace.RowCol; break; } WorkspaceToolbar wsToolbar = cuWorkspace.WorkspaceToolbars.FindWorkspaceToolbar( tbFind.ElementID, csPart.MenuGroup.Name); if (wsToolbar == null) { wsToolbar = new WorkspaceToolbar(cuWorkspace, tbFind); } if (wsToolbar.MenuGroup.ToLower().Equals(tbId.CuiName.ToLower())) { switch (tbPlace.Side) { case "T": wsToolbar.Display = 1; wsToolbar.ToolbarOrient = ToolbarOrient.top; wsToolbar.DockRow = tbPlace.RowCol; wsToolbar.DockColumn = tbPlace.Order; wsToolbar.XCoordinate = tbPlace.Order; wsToolbar.YCoordinate = tbPlace.RowCol; break; case "B": wsToolbar.Display = 1; wsToolbar.ToolbarOrient = ToolbarOrient.bottom; wsToolbar.DockRow = tbPlace.RowCol; wsToolbar.DockColumn = tbPlace.Order; wsToolbar.XCoordinate = tbPlace.Order; wsToolbar.YCoordinate = tbPlace.RowCol; break; case "L": wsToolbar.Display = 1; wsToolbar.ToolbarOrient = ToolbarOrient.left; wsToolbar.DockRow = tbPlace.RowCol; wsToolbar.DockColumn = tbPlace.Order; wsToolbar.YCoordinate = tbPlace.Order; wsToolbar.XCoordinate = tbPlace.RowCol; break; case "R": wsToolbar.Display = 1; wsToolbar.ToolbarOrient = ToolbarOrient.right; wsToolbar.DockRow = tbPlace.RowCol; wsToolbar.DockColumn = tbPlace.Order; wsToolbar.YCoordinate = tbPlace.Order; wsToolbar.XCoordinate = tbPlace.RowCol; break; case "F": wsToolbar.Display = 2; wsToolbar.ToolbarOrient = ToolbarOrient.floating; wsToolbar.XCoordinate = tbPlace.Order; wsToolbar.YCoordinate = tbPlace.RowCol; break; } } } if (!changedCUIS.ContainsKey(partCuiFName.ToLower())) { changedCUIS.Add(partCuiFName.ToLower(), csPart); } } } } } } foreach (CustomizationSection csPart in changedCUIS.Values) csPart.Save(); changedCUIS.Clear(); if (cuWorkspace.UserModified()) { csMain.Workspaces.SetDefaultWorkspace(cuWorkspace.ElementID); bool test = csMain.UpdateWorkspaceComplete(); } csMain.Save(); } } } } return csMain; }
beste Grüße Mario
[Diese Nachricht wurde von Mario Rosenbohm am 10. Mai. 2022 editiert.] Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
| Anzeige.:
Anzeige: (Infos zum Werbeplatz >>)
 |