Compare commits

...

3 Commits

Author SHA1 Message Date
Oğuzhan Koral c88d3c632d skip if elevation or units null (#446)
Build and deploy / build (push) Has been cancelled
Build and deploy / deploy-installers (push) Has been cancelled
2026-01-16 10:27:38 +03:00
Oğuzhan Koral 72f5185992 feat: do not try to hightlight on no selection (#445) 2026-01-13 10:40:31 +03:00
Oğuzhan Koral b8db07a66b Feat: add account (#443)
Build and deploy / build (push) Has been cancelled
Build and deploy / deploy-installers (push) Has been cancelled
* fix(macos): appdata path

* feat: add account via sqlite

* revert: material manager

* revert: dui url

* doc
2025-10-26 09:08:54 +03:00
5 changed files with 61 additions and 1 deletions
@@ -25,6 +25,38 @@ module SpeckleConnector3
rows.map { |row| JSON.parse(row[1]) }
end
def self.add_account(account_id, account)
unless File.exist?(SPECKLE_ACCOUNTS_DB_PATH)
File.new(SPECKLE_ACCOUNTS_DB_PATH, "w")
db = Sqlite3::Database.new(SPECKLE_ACCOUNTS_DB_PATH)
create_objects_table(db)
db.close
end
db = Sqlite3::Database.new(SPECKLE_ACCOUNTS_DB_PATH)
account_json = JSON.generate(account)
sql_query = "INSERT OR REPLACE INTO objects (hash, content) VALUES ('#{account_id}', '#{account_json}')"
begin
db.exec(sql_query)
puts "Account with hash #{account_id} has been added/updated."
rescue StandardError => e
puts "An error occurred while adding the account: #{e}"
ensure
db.close
end
end
# Creates the 'objects' table in the database if it doesn't already exist.
# @param db [Sqlite3::Database] the SQLite3 database instance.
def self.create_objects_table(db)
db.exec <<-SQL
CREATE TABLE IF NOT EXISTS objects (
hash TEXT PRIMARY KEY,
content TEXT
);
SQL
end
def self.remove_account(account_id)
db_path = SPECKLE_ACCOUNTS_DB_PATH
unless File.exist?(db_path)
@@ -0,0 +1,20 @@
# frozen_string_literal: true
require_relative '../action'
require_relative '../../accounts/accounts'
require_relative '../load_saved_streams'
module SpeckleConnector3
module Actions
# Action to add account to local Account db.
class AddAccount < Action
# @param state [States::State] the current state of the {App::SpeckleConnectorApp}
# @return [States::State] the new updated state object
def self.update_state(state, resolve_id, account_id, account)
SpeckleConnector3::Accounts.add_account(account_id, account)
js_script = "accountsBinding.receiveResponse('#{resolve_id}')"
state.with_add_queue_js_command('addAccount', js_script)
end
end
end
end
@@ -530,6 +530,8 @@ module SpeckleConnector3
units = level_data_object['units']
elevation_raw = level_data_object['elevation']
next if elevation_raw.nil? || units.nil?
is_exist = @entities_to_fill.grep(Sketchup::SectionPlane).any? { |sp| sp.name == name }
next if is_exist
@@ -25,7 +25,11 @@ module SpeckleConnector3
sketchup_model.selection.add(entity)
end
sketchup_model.active_view.zoom(sketchup_model.selection)
if sketchup_model.selection.empty?
puts 'No object is selected to highlight'
else
sketchup_model.active_view.zoom(sketchup_model.selection)
end
end
end
end
@@ -2,6 +2,7 @@
require_relative 'binding'
require_relative '../../actions/account_actions/get_accounts'
require_relative '../../actions/account_actions/add_account'
require_relative '../../actions/account_actions/remove_account'
module SpeckleConnector3
@@ -13,6 +14,7 @@ module SpeckleConnector3
def commands
@commands ||= {
getAccounts: Commands::ActionCommand.new(@app, self, Actions::GetAccounts),
addAccount: Commands::ActionCommand.new(@app, self, Actions::AddAccount),
removeAccount: Commands::ActionCommand.new(@app, self, Actions::RemoveAccount)
}.freeze
end