Skip to main content

Project

The Project class represents an Anchorpoint project, providing access to project metadata, settings, and operations. Projects in Anchorpoint serve as containers for organizing files, tasks, and team collaboration within specific workspaces.

Usage

Projects are typically accessed through the API or context, but can also be managed using utility functions:

import anchorpoint
import apsync

# Get current project through API
api = anchorpoint.get_api()
project = api.get_project()

# Get project from a specific path
project = apsync.get_project("/path/to/project")

# Get project by ID
project = apsync.get_project_by_id("project_id", "workspace_id")

# Create a new project
new_project = apsync.create_project("/path/to/new/project", "My New Project", "workspace_id")

# Check if a path is within a project
is_in_project = apsync.is_project("/some/path", recursive=True)

Project Class

Properties

  • id (str): Unique identifier for the project within the workspace. Used for API calls and project references.
  • name (str): Human-readable name of the project. Can be modified by project administrators.
  • path (str): Absolute file system path to the project root directory. Where project files and folders are stored.
  • workspace_id (str): Identifier of the workspace containing this project. Links the project to its parent workspace.
  • description (str): Optional project description. Provides additional context about the project's purpose.
  • color (str): Project color for visual identification in the UI. Hex color code (e.g., "#FF5733").
  • icon (str): Path or identifier for the project icon. Used in the Anchorpoint interface for visual recognition.
  • created_at (int): Creation timestamp in seconds since epoch. When the project was first created.
  • updated_at (int): Last update timestamp in seconds since epoch. When project metadata was last modified.

Methods

  • get_members() Gets all members who have access to this project.

    Returns (class: GroupMemberList): List of project members with their access levels

  • add_member(email, access_level) Adds a new member to the project with specified access level.

    Arguments

    • email (str): Email address of the user to add
    • access_level (class: AccessLevel): Permission level for the user
  • remove_member(email) Removes a member from the project.

    Arguments

    • email (str): Email address of the user to remove
  • update_settings(settings) Updates project configuration settings.

    Arguments

    • settings (dict): Dictionary of setting key-value pairs
  • get_timeline_channels() Gets all timeline channels associated with this project.

    Returns (list of TimelineChannel): Project timeline channels

Project Utility Functions

Project Management

  • create_project(path, name, workspace_id=None) Creates a new Anchorpoint project.

    Arguments

    • path (str): Project root path
    • name (str): Project name
    • workspace_id (str): Optional workspace ID

    Returns (class: Project): Created project object

  • get_project(path) Gets project information for a given path.

    Arguments

    • path (str): Path within a project

    Returns (class: Project or None): Project object or None if not found

  • get_project_by_id(id, workspace_id) Gets a project by its ID.

    Arguments

    • id (str): Project identifier
    • workspace_id (str): Workspace identifier

    Returns (class: Project): Project object

  • get_projects(workspace_id) Gets all projects in a workspace.

    Arguments

    • workspace_id (str): Workspace identifier

    Returns (list[class: Project]): List of Project objects

  • is_project(path, recursive=False) Checks if a path is within an Anchorpoint project.

    Arguments

    • path (str): Path to check
    • recursive (bool): Whether to check parent directories

    Returns (bool): True if path is within a project

  • remove_project(project) Removes a project.

    Arguments

    • project (class: Project): Project to remove

Project File Operations

  • create_project_file(path, project_id, workspace_id) Creates a project file at the specified path.

    Arguments

    • path (str): Path where project file should be created
    • project_id (str): Project identifier
    • workspace_id (str): Workspace identifier

Project Import/Export

  • export_project(project, userIds=None) Exports project data.

    Arguments

    • project (class: Project): Project to export
    • userIds (list[str]): Optional list of user IDs to include in export

    Returns (str): Path to exported project data

  • import_project(workspace_id, project_data_path, target_path) Imports project data.

    Arguments

    • workspace_id (str): Target workspace ID
    • project_data_path (str): Path to project data to import
    • target_path (str): Target path for imported project

Project User Management

  • add_user_to_project(workspace_id, project_id, invited_from, email, access_level) Adds a user to a project.

    Arguments

    • workspace_id (str): Workspace identifier
    • project_id (str): Project identifier
    • invited_from (str): Email of user sending invitation
    • email (str): Email of user to add
    • access_level (class: AccessLevel): Access level for the user
  • remove_user_from_project(workspace_id, project_id, email) Removes a user from a project.

    Arguments

    • workspace_id (str): Workspace identifier
    • project_id (str): Project identifier
    • email (str): Email of user to remove
  • get_project_members(workspace_id, project_id) Gets all members of a project.

    Arguments

    • workspace_id (str): Workspace identifier
    • project_id (str): Project identifier

    Returns (class: GroupMemberList): List of project members

Project Dialog Management

  • show_create_project_dialog(path=None, project_id=None, remote_url=None, tags=[]) Shows the create project dialog.

    Arguments

    • path (str): Optional initial path
    • project_id (str): Optional project ID for editing existing project
    • remote_url (str): Optional remote repository URL
    • tags (list[str]): Optional list of project tags
  • close_create_project_dialog() Closes the create project dialog.

  • reload_create_project_dialog() Reloads the create project dialog.

Examples

Basic Project Information

import anchorpoint
import apsync

# Get current project
api = anchorpoint.get_api()
project = api.get_project()

if project:
print(f"Project Name: {project.name}")
print(f"Project ID: {project.id}")
print(f"Project Path: {project.path}")
print(f"Workspace ID: {project.workspace_id}")
print(f"Description: {project.description}")
print(f"Created: {project.created_at}")
print(f"Updated: {project.updated_at}")
else:
print("No project found in current context")

Working with Project Members

import anchorpoint
import apsync

# Get project and manage members
project = apsync.get_project("/path/to/project")

if project:
# Get current members
members = project.get_members()
print(f"Project has {len(members)} members:")

for member in members:
print(f"- {member.email}: {member.access_level}")

# Add new member with Admin access
try:
project.add_member("newuser@company.com", apsync.AccessLevel.Admin)
print("Successfully added new admin member")
except Exception as e:
print(f"Failed to add member: {e}")

# Add member with Member access
try:
project.add_member("viewer@company.com", apsync.AccessLevel.Member)
print("Successfully added new member")
except Exception as e:
print(f"Failed to add member: {e}")

Project-Based File Operations

import anchorpoint
import apsync
import os

# Get current project context
api = anchorpoint.get_api()
project = api.get_project()

if project:
# Set project-specific attributes on files
project_files = []
for root, dirs, files in os.walk(project.path):
for file in files:
if file.lower().endswith(('.jpg', '.png', '.fbx', '.ma')):
file_path = os.path.join(root, file)
project_files.append(file_path)

# Apply project metadata to all assets
for file_path in project_files:
# Set project identification
api.attributes.set_attribute_value(file_path, "Project Name", project.name)
api.attributes.set_attribute_value(file_path, "Project ID", project.id)

# Set relative path within project
rel_path = os.path.relpath(file_path, project.path)
api.attributes.set_attribute_value(file_path, "Project Path", rel_path)

print(f"Applied project metadata to {len(project_files)} files")

Project Creation and Management

import anchorpoint
import apsync
import os

def create_and_setup_project():
"""Create a new project and set it up with initial structure"""

ctx = anchorpoint.get_context()

# Create new project
project_path = os.path.join(ctx.path, "NewGameProject")
project_name = "Epic Adventure Game"

try:
# Create project directory structure
os.makedirs(project_path, exist_ok=True)

# Create the Anchorpoint project
project = apsync.create_project(project_path, project_name, ctx.workspace_id)
print(f"Created project: {project.name}")
print(f"Project ID: {project.id}")
print(f"Project path: {project.path}")

# Create project file for integration
apsync.create_project_file(project_path, project.id, ctx.workspace_id)

# Verify project creation
retrieved_project = apsync.get_project(project_path)
if retrieved_project:
print(f"Project verified: {retrieved_project.name}")

return project

except Exception as e:
anchorpoint.log_error(f"Project creation failed: {str(e)}")
print(f"Error: {e}")
return None

create_and_setup_project()

Project Discovery and Validation

import apsync
import anchorpoint
import os

def discover_projects_in_workspace():
"""Discover and validate projects in current workspace"""

ctx = anchorpoint.get_context()

# Get all projects in workspace
projects = apsync.get_projects(ctx.workspace_id)
print(f"Found {len(projects)} projects in workspace:")

for project in projects:
print(f"\nProject: {project.name}")
print(f" ID: {project.id}")
print(f" Path: {project.path}")

# Check if project path exists and is valid
if os.path.exists(project.path):
is_project = apsync.is_project(project.path)
print(f" Valid project: {is_project}")

# Get project by ID to verify
retrieved = apsync.get_project_by_id(project.id, ctx.workspace_id)
print(f" Retrieved successfully: {retrieved.name == project.name}")
else:
print(f" Warning: Project path does not exist!")

discover_projects_in_workspace()

Project Member Management

import apsync
import anchorpoint

def manage_project_members():
"""Manage project members using utility functions"""

ctx = anchorpoint.get_context()
project = apsync.get_project(ctx.path)

if not project:
print("Not in a project context")
return

# Get current project members
members = apsync.get_project_members(ctx.workspace_id, project.id)
print(f"Current members ({len(members)}):")

for member in members:
print(f" - {member.email}: {member.access_level}")

# Add new members with different access levels
new_members = [
("developer@company.com", apsync.AccessLevel.Member),
("lead@company.com", apsync.AccessLevel.Admin),
("viewer@company.com", apsync.AccessLevel.Guest)
]

for email, access_level in new_members:
try:
apsync.add_user_to_project(
ctx.workspace_id,
project.id,
ctx.username, # invited_from
email,
access_level
)
print(f"✓ Added {email} with {access_level} access")
except Exception as e:
print(f"✗ Failed to add {email}: {e}")

# Update member list
updated_members = apsync.get_project_members(ctx.workspace_id, project.id)
print(f"\nUpdated member count: {len(updated_members)}")

manage_project_members()

Project Import and Export

import apsync
import anchorpoint
import os
import tempfile

def project_backup_and_restore():
"""Demonstrate project export and import functionality"""

ctx = anchorpoint.get_context()
project = apsync.get_project(ctx.path)

if not project:
print("Not in a project context")
return

try:
# Export current project
print(f"Exporting project: {project.name}")
export_path = apsync.export_project(project)
print(f"Project exported to: {export_path}")

# Create a backup directory
backup_dir = tempfile.mkdtemp(prefix="project_backup_")
backup_project_path = os.path.join(backup_dir, f"{project.name}_restored")

# Import project to backup location
print(f"Importing project to: {backup_project_path}")
apsync.import_project(ctx.workspace_id, export_path, backup_project_path)

# Verify restored project
restored_project = apsync.get_project(backup_project_path)
if restored_project:
print(f"✓ Successfully restored project: {restored_project.name}")
print(f" Original ID: {project.id}")
print(f" Restored ID: {restored_project.id}")
else:
print("✗ Failed to verify restored project")

except Exception as e:
anchorpoint.log_error(f"Project backup/restore failed: {str(e)}")
print(f"Error: {e}")

project_backup_and_restore()