Shubham Joshi Posted November 12, 2020 Share Posted November 12, 2020 Hello Everyone, I want to create a new palette in current workspace. I use CreateToolPalette(const TXString& inIdentifier, iWorkspacesToolPalette** outtoolpalette) API Where I am setting inIdentifier using createIdentifier (EWorkspaceItemType inItemType, TXString& outIdentifier); API At this API an exception is comming Access violation writting location How to fix it. Thanks and regards 1 Quote Link to comment
Tobias Döngi Posted November 13, 2020 Share Posted November 13, 2020 Hello, I'm using following code to create new tool palettes: VCOMError XGWorkspaceCreator::CreateNewToolPalette(const TXString& paletteName, IWorkspaceFile* workspaceFile, IWorkspaceToolPalette** newToolPalette) { VCOMError error = kVCOMError_Failed; if (workspaceFile) { TXString toolPaletteID; CREATE_TOOLPALETTE_ID(toolPaletteID, error); workspaceFile->CreateToolPalette(toolPaletteID, newToolPalette); (*newToolPalette)->SetDisplayName(XG::Win2MacString(paletteName)); } return error; } Where workspaceFile points to a workspace file within Vectorworks program directory. 1 Quote Link to comment
Hippocode Posted November 23, 2020 Share Posted November 23, 2020 Make sure that the workspace interfaces are initiated correctly. This is a snippet of my workspace wrapper class and confirmed to be working: VCOMPtr<IWorkspaces> pWorkspace(IID_Workspaces); // Get current workspace file name. TXString workspaceFileName; gSDK->GetCurrentWorkspaceFile(workspaceFileName); // Current workspace full file name. TXString workspaceFullFileName = workspaceFileName + ".vww"; VCOMPtr<IWorkspaceFile> pWorkspaceFile(IID_WorkspaceFile); if(pWorkspaceFile && pWorkspace) { errorCode = pWorkspaceFile->Open(workspaceFullFileName, kFileReadPermission); VCOMPtr< IWorkspaceToolPalette > pToolPalette; VCOMPtr< IWorkspaceTool > pTool; TXString ToolPaletteName = "VectorMEP"; TXString ToolPaletteIdentifier; if(VCOM_SUCCEEDED(errorCode)) errorCode = pWorkspace->CreateIdentifier(VectorWorks::Workspaces::EWorkspaceItemType::eWorkspaceItemType_ToolPalette, ToolPaletteIdentifier); if(VCOM_SUCCEEDED(errorCode)) errorCode = pWorkspaceFile->CreateToolPalette(ToolPaletteIdentifier, &pToolPalette); pToolPalette->SetDisplayName(ToolPaletteName); 1 Quote Link to comment
Shubham Joshi Posted November 25, 2020 Author Share Posted November 25, 2020 Hello, @Tobias Döngi @Hippocode Thank you for your reply. I created a new palette successfully in current workspace. But to show in workspace I have to mannual select a palette from a palette list. I set the visibility property to true using palette->SetVisibilityState(true); Thanks and Regards Quote Link to comment
Hippocode Posted November 25, 2020 Share Posted November 25, 2020 (edited) Well it could be any of these settings. I'm setting all these to show the palette in a specific spot. bool inTearOffState = false; bool inTopPosition = false; Sint16 ToolinSortStyle = 1; Sint16 ToolinViewStyle = 2; Sint16 ToolSetinSortStyle = 1; Sint16 ToolSetinViewStyle = 2; bool inVisibilityState = true; bool inWindowShadeState = false; EWindowHomeCorner inHomeCorner = EWindowHomeCorner::eWindowHomeCorner_ScreenUpperLeft; Sint16 inHorizontalOffset = 0; Sint16 inVerticalOffset = 0; ViewRect screenRect; gSDK->GetScreenSize(screenRect); ViewPt Center = screenRect.Center(); inHorizontalOffset = +Center.x; inVerticalOffset = +Center.y; if(VCOM_SUCCEEDED(errorCode)) errorCode = pToolPalette->SetTearOffState(inTearOffState); if(VCOM_SUCCEEDED(errorCode)) errorCode = pToolPalette->SetToolSetPosition(inTopPosition); if(VCOM_SUCCEEDED(errorCode)) errorCode = pToolPalette->SetToolSetSortStyle(ToolSetinSortStyle); if(VCOM_SUCCEEDED(errorCode)) errorCode = pToolPalette->SetToolSetViewStyle(ToolSetinViewStyle); if(VCOM_SUCCEEDED(errorCode)) errorCode = pToolPalette->SetToolViewStyle(ToolinViewStyle); if(VCOM_SUCCEEDED(errorCode)) errorCode = pToolPalette->SetToolSortStyle(ToolinSortStyle); if(VCOM_SUCCEEDED(errorCode)) errorCode = pToolPalette->SetVisibilityState(inVisibilityState); if(VCOM_SUCCEEDED(errorCode)) errorCode = pToolPalette->SetWindowShadeState(inWindowShadeState); if(VCOM_SUCCEEDED(errorCode)) errorCode = pToolPalette->SetHomeCorner(inHomeCorner); if(VCOM_SUCCEEDED(errorCode)) errorCode = pToolPalette->SetHomeCornerOffset(inHorizontalOffset, inVerticalOffset); Edited November 25, 2020 by Hippocode Quote Link to comment
Tobias Döngi Posted November 26, 2020 Share Posted November 26, 2020 It depends on which platform you are creating the new palette. Under Windows you cannot set the visibility state by API. This is due to the fact that NVI is using a third party module for rendering all the palettes. You can see this when opening a Windows workspace file in a text editor. There is a special tag WindowsOSData. That's a xml subsystem with own palettes and settings specific to the Windows platform. You can retrieve this data by calling: TXString newWinOSData; workspaceFile->GetWindowsOSData(newWinOSData); Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.