Jump to content
Developer Wiki and Function Reference Links ×

Create a new palette


Shubham Joshi

Recommended Posts

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

 

 

  • Like 1
Link to comment

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.

  • Like 1
Link to comment
  • 2 weeks later...

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);

 

  • Like 1
Link to comment

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

 

 

Link to comment

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 by Hippocode
Link to comment

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);

 

Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...