Compare commits

...

43 Commits

Author SHA1 Message Date
Jedd Morgan 3d0117f701 Removed old workflows (#442)
Build and deploy / build (push) Has been cancelled
Build and deploy / deploy-installers (push) Has been cancelled
2026-02-06 09:27:17 +03:00
Mucahit Bilal GOKER 08fe6f07cf Merge pull request #450 from specklesystems/bilal/cnx-3067-running-sketchup-when-speckle-folder-is-missing
fix: Make initialization robust when app data directory is missing
2026-02-06 08:08:06 +03:00
bimgeek 37be889932 revert check 2026-02-05 17:57:41 +03:00
Mucahit Bilal GOKER ed124dd288 init fix 2026-02-05 17:12:19 +03:00
Oğuzhan Koral 760d8a033d Treat grouped mesh as sketchup entity (#449)
Build and deploy / build (push) Has been cancelled
Build and deploy / deploy-installers (push) Has been cancelled
2026-01-30 10:34:27 +03:00
Oğuzhan Koral 96cd122645 Fix: add definition attributes to block instances (#448)
* wip

* get definition and instance props under properties

* Reordering docs
2026-01-16 15:38:33 +03:00
Oğuzhan Koral 533768eb14 strip out @ from detached props (#447) 2026-01-16 14:22:50 +03:00
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
Oğuzhan Koral 366b961039 Do not init diff materials (#440)
Build and deploy / build (push) Has been cancelled
Build and deploy / deploy-installers (push) Has been cancelled
2025-10-14 14:02:59 +03:00
Oğuzhan Koral e244a7e2e5 Convert argb to int always to be safe (#439)
Build and deploy / build (push) Has been cancelled
Build and deploy / deploy-installers (push) Has been cancelled
2025-10-14 13:28:52 +03:00
Mucahit Bilal GOKER 9b55764b38 replace logos (#437) 2025-10-03 12:28:26 +03:00
Oğuzhan Koral 4b8012f94b fix(macos): appdata path (#438) 2025-09-17 20:35:49 +03:00
Oğuzhan Koral 9871000d84 no more netlify url (#436)
Build and deploy / build (push) Has been cancelled
Build and deploy / deploy-installers (push) Has been cancelled
2025-07-23 17:47:27 +01:00
kekesidavid 17a056b3b9 fix(sketchup) fix for orphan edges (#435)
* fix for orphan edges

* fix
2025-07-10 13:27:34 +03:00
Oğuzhan Koral a8c5bd573f Try adding object ids to render material proxies (#434)
Build and deploy / build (push) Has been cancelled
Build and deploy / deploy-installers (push) Has been cancelled
2025-06-26 22:12:23 +03:00
Oğuzhan Koral 1d2fe047bf Fix: initializing sketchup connector on large models takes a lot (#433)
* Attach observers to only orphan edges

* Do not try to read entities on load
2025-06-26 19:36:35 +03:00
Jedd Morgan 3465f86605 chore(ci): Replace GitVersion (#431) 2025-06-26 11:58:30 +03:00
Oğuzhan Koral 540e727b73 Iterate sections planes over level proxies (#432) 2025-06-23 18:59:24 +03:00
Oğuzhan Koral 8c576f820c Default to unnamed folder name if name is empty string (#429) 2025-05-22 17:28:38 +03:00
Jedd Morgan df3b673064 refactor(ci): Update workflow to use new consolidated deployment workflow (#428)
Build and deploy / build (push) Has been cancelled
Build and deploy / deploy-installers (push) Has been cancelled
* Updated workflow

* update workflow

* target main
2025-04-25 10:43:27 +01:00
Oğuzhan Koral 69bde5539c Add serverUrl and workspaceSlug to model cards (#427)
Build and deploy / build (push) Has been cancelled
Build and deploy / deploy-installers (push) Has been cancelled
2025-04-21 15:06:19 +03:00
Oğuzhan Koral aa12b7b11b remove unnessary logging (#426) 2025-04-21 14:11:45 +03:00
Oğuzhan Koral e0b3b3cca2 Convert revit data object natively (#425) 2025-04-21 14:08:20 +03:00
Jedd Morgan ea9a5741d7 Update config.yml (#424) 2025-04-21 10:30:19 +03:00
Oğuzhan Koral 1fe1c8d5a8 Fix the source of the issue (#423)
Build and deploy / build (push) Has been cancelled
Build and deploy / deploy-installers (push) Has been cancelled
2025-03-28 16:47:56 +03:00
Oğuzhan Koral ac58560a69 Verbose about menu commands and guard about name (#422)
Build and deploy / build (push) Has been cancelled
Build and deploy / deploy-installers (push) Has been cancelled
2025-03-24 15:32:39 +03:00
Oğuzhan Koral d0b234bf3d delete ruby.yml temp (#421)
Build and deploy / build (push) Has been cancelled
Build and deploy / deploy-installers (push) Has been cancelled
2025-03-19 13:32:09 +03:00
oguzhankoral 981fe05c15 deploy over main 2025-03-19 11:50:17 +03:00
Oğuzhan Koral 918550465b No more beta (#418) 2025-03-19 10:20:46 +03:00
Oğuzhan Koral 963d4f1738 Add remove account and remove models (#417) 2025-03-19 10:16:34 +03:00
oguzhankoral d809732280 Merge branch 'dui3/alpha'
# Conflicts:
#	.circleci/config.yml
2025-03-17 23:16:02 +03:00
oguzhankoral c4e38a11b7 run on ubuntu-22.04 2025-03-17 20:03:42 +03:00
oguzhankoral 7abe215bc2 sorry circleci, have you back for now 2025-03-17 20:01:04 +03:00
oguzhankoral 0f269430bc no more circleci 2025-03-17 19:29:39 +03:00
Oğuzhan Koral b8a298c54b Fix: various papercuts (#409)
Build and deploy / build (push) Has been cancelled
Build and deploy / deploy-installers (push) Has been cancelled
* Do not report converted grouped meshes

* remember last selected account on db
2025-03-10 18:36:58 +03:00
Oğuzhan Koral e1d33cd250 fix the highlight freeze (#408) 2025-03-10 16:18:07 +03:00
Oğuzhan Koral 4563dec9bc Debounce progress update (#407) 2025-03-07 21:07:44 +03:00
Oğuzhan Koral de284083fd add defintiion and layer name to instance proxy (#406)
Build and deploy / build (push) Has been cancelled
Build and deploy / deploy-installers (push) Has been cancelled
2025-03-07 12:19:11 +03:00
oguzhankoral 20528f72df Merge remote-tracking branch 'origin/development' 2024-03-19 13:32:03 +03:00
oguzhankoral ad9af9bb3d Merge remote-tracking branch 'origin/development' 2024-02-27 12:38:00 +03:00
oguzhankoral 133308141b Merge branch 'development' 2023-11-28 13:57:11 +03:00
57 changed files with 570 additions and 326 deletions
+17
View File
@@ -0,0 +1,17 @@
version: 2.1
# Define the jobs we want to run for this project
jobs:
build:
docker:
- image: cimg/base:2023.03
steps:
- run: echo "so long and thanks for all the fish"
# Orchestrate our job run sequence
workflows:
build_and_test:
when:
false
jobs:
- build
+23 -20
View File
@@ -8,54 +8,57 @@ on:
workflow_call:
outputs:
semver:
description: "The computed version number for this run"
description: "The full SemVer 2.0 version of this build, e.g. '3.0.0-alpha.1234' (note: no 'v'-prefix)"
value: ${{ jobs.build.outputs.semver }}
file_version:
description: "The assembly info version for this run"
description: "The file info version, e.g. '3.0.0.1234'"
value: ${{ jobs.build.outputs.file_version }}
jobs:
build:
runs-on: ubuntu-latest
outputs:
semver: ${{ steps.set-version.outputs.semver }}
file_version: ${{ steps.set-info-version.outputs.file-version }}
file_version: ${{ steps.set-version.outputs.file-version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v3.0.0
with:
versionSpec: 6.0.5 # github actions doesnt like 6.1.0 onwards https://github.com/GitTools/actions/blob/main/docs/versions.md
- id: set-version
name: Set version to output
shell: bash
run: |
TAG=${{ github.ref_name }}
if [[ "${{ github.ref }}" != refs/tags/* ]]; then
TAG="v3.0.99.${{ github.run_number }}"
fi
SEMVER="${TAG#v}"
FILE_VERSION=$(echo "$TAG" | sed -E 's/^v([0-9]+\.[0-9]+\.[0-9]+).*/\1/')
FILE_VERSION="$FILE_VERSION.${{ github.run_number }}"
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v3.0.0
echo "semver=$SEMVER" >> "$GITHUB_OUTPUT"
echo "file-version=$FILE_VERSION" >> "$GITHUB_OUTPUT"
echo $SEMVER
echo $FILE_VERSION
- name: Set connector version
run: |
python patch_version.py ${{steps.gitversion.outputs.semVer}}
python patch_version.py ${{steps.set-version.outputs.semver}}
- uses: montudor/action-zip@v1
with:
args: zip -q -r sketchup.zip vendor speckle_connector_3/ speckle_connector_3.rb
- name: ⬆️ Upload artifacts
uses: actions/upload-artifact@v4
with:
name: output-${{steps.gitversion.outputs.semVer}}
name: output-${{steps.set-version.outputs.semver}}
path: sketchup.zip
retention-days: 1
if-no-files-found: error
compression-level: 0 # no compression
- id: set-version
name: Set version to output
run: echo "semver=${{steps.gitversion.outputs.semVer}}" >> "$GITHUB_OUTPUT" # version will be retrieved from tag?
- id: set-info-version
name: Set version to output
run: echo "file-version=${{steps.gitversion.outputs.AssemblySemVer}}" >> "$GITHUB_OUTPUT" # version will be retrieved from tag?
-78
View File
@@ -1,78 +0,0 @@
name: Update issue Status
on:
issues:
types: [closed]
jobs:
update_issue:
runs-on: ubuntu-latest
steps:
- name: Get project data
env:
GITHUB_TOKEN: ${{secrets.GHPROJECT_TOKEN}}
ORGANIZATION: specklesystems
PROJECT_NUMBER: 9
run: |
gh api graphql --header 'GraphQL-Features: projects_next_graphql' -f query='
query($org: String!, $number: Int!) {
organization(login: $org){
projectNext(number: $number) {
id
fields(first:20) {
nodes {
id
name
settings
}
}
}
}
}' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json
echo 'PROJECT_ID='$(jq '.data.organization.projectNext.id' project_data.json) >> $GITHUB_ENV
echo 'STATUS_FIELD_ID='$(jq '.data.organization.projectNext.fields.nodes[] | select(.name== "Status") | .id' project_data.json) >> $GITHUB_ENV
echo "$PROJECT_ID"
echo "$STATUS_FIELD_ID"
echo 'DONE_ID='$(jq '.data.organization.projectNext.fields.nodes[] | select(.name== "Status") | .settings | fromjson | .options[] | select(.name== "Done") | .id' project_data.json) >> $GITHUB_ENV
echo "$DONE_ID"
- name: Add Issue to project #it's already in the project, but we do this to get its node id!
env:
GITHUB_TOKEN: ${{secrets.GHPROJECT_TOKEN}}
ISSUE_ID: ${{ github.event.issue.node_id }}
run: |
item_id="$( gh api graphql --header 'GraphQL-Features: projects_next_graphql' -f query='
mutation($project:ID!, $id:ID!) {
addProjectNextItem(input: {projectId: $project, contentId: $id}) {
projectNextItem {
id
}
}
}' -f project=$PROJECT_ID -f id=$ISSUE_ID --jq '.data.addProjectNextItem.projectNextItem.id')"
echo 'ITEM_ID='$item_id >> $GITHUB_ENV
- name: Update Status
env:
GITHUB_TOKEN: ${{secrets.GHPROJECT_TOKEN}}
ISSUE_ID: ${{ github.event.issue.node_id }}
run: |
gh api graphql --header 'GraphQL-Features: projects_next_graphql' -f query='
mutation($project:ID!, $status:ID!, $id:ID!, $value:String!) {
set_status: updateProjectNextItemField(
input: {
projectId: $project
itemId: $id
fieldId: $status
value: $value
}
) {
projectNextItem {
id
}
}
}' -f project=$PROJECT_ID -f status=$STATUS_FIELD_ID -f id=$ITEM_ID -f value=${{ env.DONE_ID }}
+13 -7
View File
@@ -5,8 +5,8 @@ name: Build and deploy
on:
push:
branches: ["dui3/alpha", "deploy/*"] # Continuous delivery on every long-lived branch
tags: ["v3.*"] # Manual delivery on every 3.x tag
branches: ["main", "installer-test/**"]
tags: ["v3.*.*"] # Manual delivery on every 3.x tag
jobs:
build:
@@ -16,15 +16,21 @@ jobs:
runs-on: ubuntu-latest
needs: build
env:
IS_TAG_BUILD: ${{ github.ref_type == 'tag' }}
IS_PUBLIC_RELEASE: ${{ github.ref_type == 'tag' }}
steps:
- name: 🔫 Trigger Build Installers
uses: ALEEF02/workflow-dispatch@v3.0.0
- name: 🔫 Trigger Build Installer(s)
uses: the-actions-org/workflow-dispatch@v4.0.0
with:
workflow: Build Sketchup
workflow: Build Installers
repo: specklesystems/connector-installers
token: ${{ secrets.CONNECTORS_GH_TOKEN }}
inputs: '{ "run_id": "${{ github.run_id }}", "semver": "${{ needs.build.outputs.semver }}", "file_version": "${{ needs.build.outputs.file_version }}", "public_release": ${{ env.IS_TAG_BUILD }} }'
inputs: '{
"run_id": "${{ github.run_id }}",
"semver": "${{ needs.build.outputs.semver }}",
"file_version": "${{ needs.build.outputs.file_version }}",
"repo": "${{ github.repository }}",
"is_public_release": ${{ env.IS_PUBLIC_RELEASE }}
}'
ref: main
wait-for-completion: true
wait-for-completion-interval: 10s
-50
View File
@@ -1,50 +0,0 @@
name: Move new issues into Project
on:
issues:
types: [opened]
jobs:
track_issue:
runs-on: ubuntu-latest
steps:
- name: Get project data
env:
GITHUB_TOKEN: ${{secrets.GHPROJECT_TOKEN}}
ORGANIZATION: specklesystems
PROJECT_NUMBER: 9
run: |
gh api graphql --header 'GraphQL-Features: projects_next_graphql' -f query='
query($org: String!, $number: Int!) {
organization(login: $org){
projectNext(number: $number) {
id
fields(first:20) {
nodes {
id
name
settings
}
}
}
}
}' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json
echo 'PROJECT_ID='$(jq '.data.organization.projectNext.id' project_data.json) >> $GITHUB_ENV
echo 'STATUS_FIELD_ID='$(jq '.data.organization.projectNext.fields.nodes[] | select(.name== "Status") | .id' project_data.json) >> $GITHUB_ENV
- name: Add Issue to project
env:
GITHUB_TOKEN: ${{secrets.GHPROJECT_TOKEN}}
ISSUE_ID: ${{ github.event.issue.node_id }}
run: |
item_id="$( gh api graphql --header 'GraphQL-Features: projects_next_graphql' -f query='
mutation($project:ID!, $id:ID!) {
addProjectNextItem(input: {projectId: $project, contentId: $id}) {
projectNextItem {
id
}
}
}' -f project=$PROJECT_ID -f id=$ISSUE_ID --jq '.data.addProjectNextItem.projectNextItem.id')"
echo 'ITEM_ID='$item_id >> $GITHUB_ENV
-38
View File
@@ -1,38 +0,0 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
name: Ruby
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['2.7']
steps:
- uses: actions/checkout@v3
- name: Set up Ruby
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
# change this to (see https://github.com/ruby/setup-ruby#versioning):
# uses: ruby/setup-ruby@v1
uses: ruby/setup-ruby@0a29871fe2b0200a17a4497bae54fe5df0d973aa # v1.115.3
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Run tests
run: bundle exec rake
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

+64 -5
View File
@@ -1,8 +1,10 @@
# frozen_string_literal: true
require 'JSON'
require 'fileutils'
require_relative '../ext/sqlite3'
require_relative '../constants/path_constants'
require_relative '../preferences/preferences'
module SpeckleConnector3
# Accounts to communicate with models on user's account.
@@ -11,11 +13,13 @@ module SpeckleConnector3
def self.load_accounts
db_path = SPECKLE_ACCOUNTS_DB_PATH
unless File.exist?(db_path)
raise(
IOError,
"No Accounts db found. Please read the guide for different options for adding your account:\n
https://speckle.guide/user/manager.html#adding-accounts"
)
# Ensure parent directory exists before creating the database file
FileUtils.mkdir_p(File.dirname(db_path))
File.new(SPECKLE_ACCOUNTS_DB_PATH, "w")
db = Sqlite3::Database.new(SPECKLE_ACCOUNTS_DB_PATH)
Preferences.create_objects_table(db)
db.close
return []
end
db = Sqlite3::Database.new(db_path)
@@ -24,6 +28,61 @@ module SpeckleConnector3
rows.map { |row| JSON.parse(row[1]) }
end
def self.add_account(account_id, account)
unless File.exist?(SPECKLE_ACCOUNTS_DB_PATH)
# Ensure parent directory exists before creating the database file
FileUtils.mkdir_p(File.dirname(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)
raise(
IOError,
"No Accounts db found. Please read the guide for different options for adding your account:\n
https://speckle.guide/user/manager.html#adding-accounts"
)
end
db = Sqlite3::Database.new(db_path)
begin
db.exec("DELETE FROM objects WHERE hash = '#{account_id}'")
puts "Account with hash #{account_id} has been removed."
rescue StandardError => e
puts "An error occurred: #{e}"
ensure
db.close
end
end
def self.get_account_by_id(id)
accounts = load_accounts
accounts.select { |acc| acc['id'] == id }[0]
@@ -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
@@ -1,8 +1,8 @@
# frozen_string_literal: true
require_relative 'action'
require_relative '../accounts/accounts'
require_relative 'load_saved_streams'
require_relative '../action'
require_relative '../../accounts/accounts'
require_relative '../load_saved_streams'
module SpeckleConnector3
module Actions
@@ -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 remove account from database.
class RemoveAccount < 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)
SpeckleConnector3::Accounts.remove_account(account_id)
js_script = "accountsBinding.receiveResponse('#{resolve_id}')"
state.with_add_queue_js_command('removeAccount', js_script)
end
end
end
end
@@ -17,7 +17,9 @@ module SpeckleConnector3
def self.update_state(state, resolve_id, data)
model_card_id = data['modelCardId']
account_id = data['accountId']
server_url = data['serverUrl']
workspace_id = data['workspaceId']
workspace_slug = data['workspaceSlug']
project_id = data['projectId']
model_id = data['modelId']
project_name = data['projectName']
@@ -32,7 +34,7 @@ module SpeckleConnector3
has_dismissed_update_warning = data['hasDismissedUpdateWarning']
baked_object_ids = data['bakedObjectIds'].nil? ? nil : data['bakedObjectIds'].values
receive_card = Cards::ReceiveCard.new(model_card_id, account_id, workspace_id,
receive_card = Cards::ReceiveCard.new(model_card_id, account_id, server_url, workspace_id, workspace_slug,
project_id, model_id,
project_name, model_name,
selected_version_id, selected_version_source_app, selected_version_user_id,
@@ -22,7 +22,9 @@ module SpeckleConnector3
send_card = Cards::SendCard.new(
data['modelCardId'],
data['accountId'],
data['serverUrl'],
data['workspaceId'],
data['workspaceSlug'],
data['projectId'],
data['projectName'],
data['modelId'],
@@ -21,7 +21,9 @@ module SpeckleConnector3
send_card = Cards::SendCard.new(
id,
card['account_id'],
card['server_url'],
card['workspace_id'],
card['workspace_slug'],
card['project_id'],
card['project_name'],
card['model_id'],
@@ -36,7 +38,9 @@ module SpeckleConnector3
{
modelCardId: send_card.model_card_id,
accountId: send_card.account_id,
serverUrl: send_card.server_url,
workspaceId: send_card.workspace_id,
workspaceSlug: send_card.workspace_slug,
projectId: send_card.project_id,
modelId: send_card.model_id,
sendFilter: send_card.send_filter,
@@ -51,7 +55,7 @@ module SpeckleConnector3
# TODO: CONVERTER_V2: Extract into new actions
receive_cards = receive_cards_hash.collect do |id, card|
receive_card = Cards::ReceiveCard.new(id, card['account_id'], card['workspace_id'], card['project_id'], card['model_id'],
receive_card = Cards::ReceiveCard.new(id, card['account_id'], card['server_url'], card['workspace_id'], card['workspace_slug'], card['project_id'], card['model_id'],
card['project_name'], card['model_name'], card['selected_version_id'],
card['selected_version_source_app'], card['selected_version_user_id'],
card['latest_version_id'], card['latest_version_source_app'],
@@ -63,7 +67,9 @@ module SpeckleConnector3
{
modelCardId: receive_card.model_card_id,
accountId: receive_card.account_id,
serverUrl: receive_card.server_url,
workspaceId: receive_card.workspace_id,
workspaceSlug: receive_card.workspace_slug,
projectId: receive_card.project_id,
modelId: receive_card.model_id,
projectName: receive_card.project_name,
@@ -0,0 +1,34 @@
# frozen_string_literal: true
require_relative '../action'
require_relative '../../cards/send_card'
require_relative '../../cards/receive_card'
require_relative '../../filters/send/everything_filter'
require_relative '../../filters/send/selection_filter'
require_relative '../../filters/send_filters'
require_relative '../../sketchup_model/dictionary/model_card_dictionary_handler'
module SpeckleConnector3
module Actions
# Action to remove cards.
class RemoveModels < 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, data)
data.each do |model_card|
SketchupModel::Dictionary::ModelCardDictionaryHandler.remove_card_dict(state.sketchup_state.sketchup_model, model_card)
new_speckle_state = if model_card['typeDiscriminator'] == 'ReceiverModelCard'
state.speckle_state.without_receive_card(model_card['id'])
else
state.speckle_state.without_send_card(model_card['id'])
end
state = state.with_speckle_state(new_speckle_state)
end
# Resolve promise
js_script = "baseBinding.receiveResponse('#{resolve_id}')"
state.with_add_queue_js_command('removeModels', js_script)
end
end
end
end
@@ -0,0 +1,21 @@
# frozen_string_literal: true
require_relative '../action'
require_relative '../../preferences/preferences'
module SpeckleConnector3
module Actions
class GetUserSelectedAccountId < 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)
user_selected_account_id = Preferences.get_user_selected_account_id
accountsConfig = {
userSelectedAccountId: user_selected_account_id
}
js_script = "configBinding.receiveResponse('#{resolve_id}', #{accountsConfig.to_json})"
state.with_add_queue_js_command('getUserSelectedAccountId', js_script)
end
end
end
end
@@ -0,0 +1,18 @@
# frozen_string_literal: true
require_relative '../action'
require_relative '../../preferences/preferences'
module SpeckleConnector3
module Actions
class SetUserSelectedAccountId < 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)
Preferences.set_user_selected_account_id(account_id)
js_script = "configBinding.receiveResponse('#{resolve_id}')"
state.with_add_queue_js_command('setUserSelectedAccountId', js_script)
end
end
end
end
@@ -26,7 +26,8 @@ module SpeckleConnector3
unless path.nil?
new_path_entities = path[-1].definition.entities
new_path_entities.add_observer(observers[ENTITIES_OBSERVER])
edges = new_path_entities.grep(Sketchup::Edge)
# attach observers to only orphan edges since face edges can be detected via face changes.
edges = new_path_entities.grep(Sketchup::Edge).filter { |edge| edge.faces.none? }
edges.each do |edge|
edge.add_observer(observers[ENTITY_OBSERVER])
edge.start.add_observer(observers[ENTITY_OBSERVER])
@@ -29,6 +29,7 @@ module SpeckleConnector3
error: error,
stackTrace: error.backtrace
}
js_error_script = "#{@view_name}.receiveResponse('#{@args.first}', #{host_app_error.to_json})"
state.with_add_queue_js_command("error_#{@view_name}", js_error_script)
end
@@ -6,7 +6,7 @@ require_relative '../constants/mat_constants'
module SpeckleConnector3
module Actions
# Action to initialize materials
# Action to initialize materials (legacy for diff colors)
class InitializeMaterials < Action
# @param state [States::State] the current state of the {App::SpeckleConnectorApp}
# @return [States::State] the new updated state object
@@ -23,18 +23,16 @@ module SpeckleConnector3
new_sketchup_state = States::SketchupState.new(sketchup_model)
sketchup_model.rendering_options['DisplaySectionPlanes'] = true
new_state = state.with(:@sketchup_state => new_sketchup_state)
# Init materials again
new_state = InitializeMaterials.update_state(new_state)
# Read speckle entities
new_speckle_entities = SketchupModel::Reader::SpeckleEntitiesReader.read(sketchup_model.entities)
new_speckle_state = new_state.speckle_state.with_speckle_entities(Immutable::Hash.new(new_speckle_entities))
#new_speckle_entities = SketchupModel::Reader::SpeckleEntitiesReader.read(sketchup_model.entities)
#new_speckle_state = new_state.speckle_state.with_speckle_entities(Immutable::Hash.new(new_speckle_entities))
# POC: Reconsider it when we will do caching between sessions!
new_speckle_state = new_speckle_state.with_empty_object_references
# new_speckle_state = new_speckle_state.with_empty_object_references
# Read mapped entities
new_mapped_entities = SketchupModel::Reader::MapperReader.read_mapped_entities(sketchup_model.entities)
new_speckle_state = new_speckle_state.with_mapped_entities(Immutable::Hash.new(new_mapped_entities))
new_state = new_state.with_speckle_state(new_speckle_state)
# new_mapped_entities = SketchupModel::Reader::MapperReader.read_mapped_entities(sketchup_model.entities)
# new_speckle_state = new_speckle_state.with_mapped_entities(Immutable::Hash.new(new_mapped_entities))
# new_state = new_state.with_speckle_state(new_speckle_state)
# Read preferences from database and model.
preferences = Preferences.read_preferences(new_state.sketchup_state.sketchup_model)
@@ -18,6 +18,7 @@ module SpeckleConnector3
converter = Converters::ToNativeV2.new(state,
root_obj['instanceDefinitionProxies'] || [],
root_obj['renderMaterialProxies'] || [],
root_obj['levelProxies'] || [],
source_application,
model_card)
start_time = Time.now.to_f
@@ -17,6 +17,7 @@ module SpeckleConnector3
# @return [States::State] the new updated state object
def self.update_state(state, resolve_id, model_card_id)
# Set active path always to model to be safe always. Later we can address it
start_time = Time.now.to_f
state.sketchup_state.sketchup_model.active_path = nil
units = Converters::SKETCHUP_UNITS[state.sketchup_state.length_units]
model_card = state.speckle_state.send_cards[model_card_id]
@@ -53,11 +54,29 @@ module SpeckleConnector3
base[:colorProxies] = unpacked_colors
base[:units] = units
elapsed_time = (Time.now.to_f - start_time).round(3)
puts "==== Converting objects executed in #{elapsed_time} sec ===="
start_time = Time.now.to_f
sender_progress_args = {
modelCardId: model_card_id,
progress: {
progress: nil,
status: 'Serializing'
}
}
state.instant_message_sender.call("sendBinding.emit('setModelProgress', #{sender_progress_args.to_json})")
id, batches, refs = converter.serialize(base, state.user_state.preferences)
elapsed_time = (Time.now.to_f - start_time).round(3)
puts "==== Serializing objects executed in #{elapsed_time} sec ===="
new_speckle_state = new_speckle_state.with_object_references(model_card.project_id, refs)
new_speckle_state = new_speckle_state.with_empty_changed_entity_persistent_ids
new_speckle_state = new_speckle_state.with_empty_changed_entity_ids
puts "Cached/Total object: #{converter.cached_object_count}/#{converter.object_count}"
puts("converted #{base.count} objects for stream #{model_card.project_id}")
state = state.with_speckle_state(new_speckle_state)
+11 -1
View File
@@ -27,27 +27,37 @@ module SpeckleConnector3
# @return [String] workspace id of the card.
attr_reader :workspace_id
# @return [String] workspace slug of the card.
attr_reader :workspace_slug
# @return [String] server url of the card.
attr_reader :server_url
# @return [Boolean] card is valid or not.
attr_reader :valid
# rubocop:disable Metrics/ParameterLists
def initialize(model_card_id, account_id, workspace_id, project_id, project_name, model_id, model_name)
def initialize(model_card_id, account_id, server_url, workspace_id, workspace_slug, project_id, project_name, model_id, model_name)
super()
@model_card_id = model_card_id
@account_id = account_id
@workspace_id = workspace_id
@workspace_slug = workspace_slug
@project_id = project_id
@project_name = project_name
@model_id = model_id
@model_name = model_name
@server_url = server_url
@valid = true
self[:model_card_id] = model_card_id
self[:account_id] = account_id
self[:workspace_id] = workspace_id
self[:workspace_slug] = workspace_slug
self[:project_id] = project_id
self[:project_name] = project_name
self[:model_id] = model_id
self[:model_name] = model_name
self[:server_url] = server_url
self[:valid] = @valid
end
# rubocop:enable Metrics/ParameterLists
@@ -48,7 +48,9 @@ module SpeckleConnector3
def initialize(
model_card_id,
account_id,
server_url,
workspace_id,
workspace_slug,
project_id,
model_id,
project_name,
@@ -63,7 +65,7 @@ module SpeckleConnector3
expired,
baked_object_ids = nil
)
super(model_card_id, account_id, workspace_id, project_id, project_name, model_id, model_name)
super(model_card_id, account_id, server_url, workspace_id, workspace_slug, project_id, project_name, model_id, model_name)
@selected_version_id = selected_version_id
@selected_version_source_app = selected_version_source_app
@selected_version_user_id = selected_version_user_id
+3 -1
View File
@@ -26,7 +26,9 @@ module SpeckleConnector3
def initialize(
model_card_id,
account_id,
server_url,
workspace_id,
workspace_slug,
project_id,
project_name,
model_id,
@@ -35,7 +37,7 @@ module SpeckleConnector3
send_filter,
send_settings
)
super(model_card_id, account_id, workspace_id, project_id, project_name, model_id, model_name)
super(model_card_id, account_id, server_url, workspace_id, workspace_slug, project_id, project_name, model_id, model_name)
@send_filter = send_filter
@send_settings = send_settings
@latest_created_version_id = latest_created_version_id
@@ -1,19 +1,19 @@
# frozen_string_literal: true
require_relative 'card'
module SpeckleConnector3
module Cards
# Send card for sketchup connector to communicate speckle.
class SendCardMultipleFilters < Card
# @return [Hash{String=>Filter}] filters of the card.
attr_reader :filters
def initialize(card_id, account_id, project_id, model_id, filters)
super(card_id, account_id, project_id, model_id)
@filters = filters
self[:filters] = filters
end
end
end
end
# # frozen_string_literal: true
#
# require_relative 'card'
#
# module SpeckleConnector3
# module Cards
# # Send card for sketchup connector to communicate speckle.
# class SendCardMultipleFilters < Card
# # @return [Hash{String=>Filter}] filters of the card.
# attr_reader :filters
#
# def initialize(card_id, account_id, project_id, model_id, filters)
# super(card_id, account_id, project_id, model_id)
# @filters = filters
# self[:filters] = filters
# end
# end
# end
# end
+1 -1
View File
@@ -26,7 +26,7 @@ module SpeckleConnector3
_run(*parameters)
end
rescue StandardError => e
action = Actions::HandleError.new(e, @binding.name, @action, parameters)
action = Actions::HandleError.new(e, @binding.nil? ? "unknown binding" : @binding.name, @action, parameters)
app.update_state!(action)
end
end
@@ -22,7 +22,7 @@ module SpeckleConnector3
SPECKLE_DUI3 = 'speckle_dui3'
def dialog_title
"Speckle (Beta) for SketchUp"
"Speckle for SketchUp"
end
private
@@ -9,6 +9,8 @@ module SpeckleConnector3
# @return [UI::Command] the command that can be added to Sketchup menu or toolbar
def self.sketchup_command(command, menu_text)
UI::Command.new(menu_text) do
puts '### COMMAND CALLED BY MENU ###'
puts "Name: #{menu_text}"
command.run
end
end
@@ -65,10 +65,10 @@ module SpeckleConnector3
def self.initialize_dui3_speckle_command(app)
cmd = MenuCommandHandler.sketchup_command(
InitializeDUI3Speckle.new(app, nil), 'Initialize Speckle (Beta)'
InitializeDUI3Speckle.new(app, nil), 'Initialize Speckle'
)
cmd.tooltip = 'Speckle (Beta) for SketchUp'
cmd.status_bar_text = 'Opens the Speckle Connector (Beta)'
cmd.tooltip = 'Speckle for SketchUp'
cmd.status_bar_text = 'Opens the Speckle Connector'
cmd.small_icon = '../../img/s2logo_dui3.png'
cmd.large_icon = '../../img/s2logo_dui3.png'
cmd
@@ -14,7 +14,7 @@ module SpeckleConnector3
path = ENV.fetch('APPDATA')
Pathname.new(File.join(path, 'Speckle')).cleanpath.to_s
when OS_MAC
File.join(Dir.home, '.config/Speckle')
File.join(Dir.home, 'Library/Application Support/Speckle')
else
raise 'Speckle could not determine your Appdata path'
end
@@ -53,5 +53,10 @@ module SpeckleConnector3
SPECKLE_CORE_MODELS_INSTANCES_INSTANCE_PROXY = 'Speckle.Core.Models.Instances.InstanceProxy'
SPECKLE_CORE_MODELS_INSTANCES_INSTANCE_DEFINITION_PROXY = 'Speckle.Core.Models.Instances.InstanceDefinitionProxy'
SPECKLE_CORE_OTHER_RENDER_MATERIAL_PROXY = 'Objects.Other.RenderMaterialProxy'
SPECKLE_CORE_OTHER_LEVEL_PROXY = 'Objects.Other.LevelProxy'
SPECKLE_CORE_OTHER_COLOR_PROXY = 'Speckle.Core.Models.Proxies.ColorProxy'
# DATA OBJECTS
SPECKLE_OBJECT_DATA_OBJECT = 'Objects.Data.DataObject'
SPECKLE_OBJECT_DATA_OBJECT_REVIT = 'Objects.Data.DataObject:Objects.Data.RevitObject'
end
@@ -109,13 +109,12 @@ module SpeckleConnector3
next
end
# 3.3. Determine prop is dynamically detached or not
# 3.3. Check prop needs to split into chunks
chunked_detach_match = prop.match(/^@\((\d*)\)/)
# 3.4. Determine prop is dynamically detached or not
is_detach_prop = prop[0] == '@'
is_dynamically_detached = prop[0] == '@' && prop.length > 2 && prop[1] == '@'
prop = prop[2..-1] if is_dynamically_detached
# 3.4. Check prop needs to split into chunks
chunked_detach_match = prop.match(/^@\((\d*)\)/)
# 3.5. If split chunk is needed and prop value is array, then run chunking process
if value.is_a?(Array) && chunked_detach_match
@@ -165,11 +164,18 @@ module SpeckleConnector3
next
end
# 3.6 we cleanup the semantic @ or @@ we used so far for detaching or chunking
if is_dynamically_detached
prop = prop[2..-1]
else
prop = prop[1..-1] if is_detach_prop
end
child = traverse_value(value, is_detach_prop)
is_base = value.is_a?(Hash) && !value[:speckle_type].nil?
# 3.6. traverse value according to value is a speckle object or not
# 3.7. traverse value according to value is a speckle object or not
traversed_base[prop] = if is_base
if child[:referencedId] && child[:speckle_type] == 'reference'
is_detach_prop ? detach_helper(child[:referencedId]) : child
@@ -34,7 +34,17 @@ module SpeckleConnector3
edges.each { |edge| remove_edge_have_coplanar_faces(edge) }
# Remove remaining orphan edges
# the commented out code throws an exception over deleted elements
# even if they are rejected by deleted? flag
# edges.reject(&:deleted?).select { |edge| edge.faces.empty? }.each(&:erase!)
edges.each do |edge|
next if edge.deleted?
begin
edge.erase! if edge.faces.empty?
rescue Sketchup::DeletedEntityError
# Ignore deleted edge
end
end
merged_faces(faces)
end
@@ -22,6 +22,7 @@ require_relative '../speckle_objects/built_elements/network'
require_relative '../speckle_objects/speckle/core/models/collection'
require_relative '../speckle_objects/speckle/core/models/gis_layer_collection'
require_relative '../speckle_objects/instance_definition_proxy'
require_relative '../speckle_objects/data/revit_data_object'
require_relative '../sketchup_model/dictionary/speckle_entity_dictionary_handler'
require_relative '../ui_data/report/conversion_result'
require_relative '../convertors/conversion_error'
@@ -48,16 +49,19 @@ module SpeckleConnector3
# @return [Array<SpeckleObjects::InstanceDefinitionProxy>]
attr_reader :root_definition_proxies
attr_reader :level_proxies
# @return [Array<SpeckleObjects::RenderMaterialProxy>]
attr_accessor :root_render_material_proxies
# @param definition_proxies [Array<SpeckleObjects::InstanceDefinitionProxy>]
# @param render_material_proxies [Array<SpeckleObjects::RenderMaterialProxy>]
# @param model_card [SpeckleConnector3::Cards::ReceiveCard]
def initialize(state, definition_proxies, render_material_proxies, source_app, model_card)
def initialize(state, definition_proxies, render_material_proxies, level_proxies, source_app, model_card)
super(state, model_card)
@root_definition_proxies = definition_proxies
@root_render_material_proxies = render_material_proxies
@level_proxies = level_proxies
@definition_proxies = {}
@source_app = source_app.downcase
@converted_faces = []
@@ -94,6 +98,8 @@ module SpeckleConnector3
LAYER_COLLECTION = SpeckleObjects::Speckle::Core::Models::LayerCollection
GIS_LAYER_COLLECTION = SpeckleObjects::Speckle::Core::Models::GisLayerCollection
REVIT_DATA_OBJECT = SpeckleObjects::RevitDataObject
BASE_OBJECT_PROPS = %w[applicationId id speckle_type].freeze
CONVERTABLE_SPECKLE_TYPES = %w[
Objects.Geometry.Line
@@ -117,6 +123,7 @@ module SpeckleConnector3
Speckle.Core.Models.Collections.Collection:Speckle.Core.Models.Collections.Layer
Speckle.Core.Models.Collections.Collection:Objects.GIS.RasterLayer
Speckle.Core.Models.Collections.Collection:Objects.GIS.VectorLayer
Objects.Data.DataObject:Objects.Data.RevitObject
].freeze
def from_revit
@@ -195,6 +202,7 @@ module SpeckleConnector3
default_commit_layer = sketchup_model.layers.layers.find { |layer| layer.display_name == '@Untagged' }
traverse_commit_object(obj, default_commit_layer, @entities_to_fill)
create_levels
create_levels_from_section_planes
check_hiding_layers_needed
try_create_instance
@@ -377,6 +385,10 @@ module SpeckleConnector3
# rubocop:enable Metrics/PerceivedComplexity
def speckle_object_to_native(obj)
if SPECKLE_OBJECTS_WITH_NATIVE_CONVERSION[obj['speckle_type']]
return SPECKLE_OBJECTS_WITH_NATIVE_CONVERSION[obj['speckle_type']]
end
return DISPLAY_VALUE.method(:to_native) unless obj['displayValue'].nil? && obj['@displayValue'].nil?
SPECKLE_OBJECT_TO_NATIVE[obj['speckle_type']]
@@ -409,6 +421,10 @@ module SpeckleConnector3
SPECKLE_CORE_MODELS_COLLECTION_VECTOR_LAYER => GIS_LAYER_COLLECTION.method(:to_native)
}.freeze
SPECKLE_OBJECTS_WITH_NATIVE_CONVERSION = {
SPECKLE_OBJECT_DATA_OBJECT_REVIT => REVIT_DATA_OBJECT.method(:to_native)
}
def entities_to_bake(obj, entities)
entities_to_bake = entities
object_id = obj['applicationId'].to_s # TODO: CONVERTER_V2: faces have integer application id..!!?
@@ -451,15 +467,15 @@ module SpeckleConnector3
end
faces = converted_entities.select { |e| e.is_a?(Sketchup::Face) }
@converted_faces += faces if faces.any?
if from_revit
# Create levels as section planes if they exists
create_levels(state, obj)
# Create layers from category of object and place object in it
# create_layers_from_categories(state, obj, converted_entities)
end
# Create speckle entities from sketchup entities to achieve continuous traversal.
converted_entities.each do |converted|
if converted.is_a?(Sketchup::ComponentDefinition)
next # no need to report definitions
end
if !from_sketchup && converted.is_a?(Sketchup::Face)
next # Otherwise we have many noise in report and causing delay post-receive
end
@conversion_results.push(UiData::Report::ConversionResult.new(UiData::Report::ConversionStatus::SUCCESS,
obj['id'],
obj['speckle_type'],
@@ -505,25 +521,29 @@ module SpeckleConnector3
nil
end
# @param state [States::State] state of the speckle application
def create_levels(state, speckle_object)
level = speckle_object['level']
return state if level.nil?
# return state unless level['speckle_type'].include?('Objects.BuiltElements.Level')
def create_levels
return if level_proxies.empty?
level_name = level['name'] || level['id']
is_exist = @entities_to_fill.grep(Sketchup::SectionPlane).any? { |sp| sp.name == level_name }
return state if is_exist
level_proxies.each do |level_proxy|
level_data_object = level_proxy['value']
name = level_data_object['name'] || level_data_object['id']
units = level_data_object['units']
elevation_raw = level_data_object['elevation']
elevation = SpeckleObjects::Geometry.length_to_native(level['elevation'], level['units'])
next if elevation_raw.nil? || units.nil?
section_plane = @entities_to_fill.add_section_plane([0, 0, elevation + LEVEL_SHIFT_VALUE], [0, 0, -1])
section_plane.name = level_name
section_plane.layer = levels_layer
SketchupModel::Dictionary::SpeckleEntityDictionaryHandler.write_initial_base_data(
section_plane, level['applicationId'], level['id'], level['speckle_type'], [], model_card.project_id
)
state
is_exist = @entities_to_fill.grep(Sketchup::SectionPlane).any? { |sp| sp.name == name }
next if is_exist
elevation = SpeckleObjects::Geometry.length_to_native(elevation_raw, units)
section_plane = @entities_to_fill.add_section_plane([0, 0, elevation + LEVEL_SHIFT_VALUE], [0, 0, -1])
section_plane.name = name
section_plane.layer = levels_layer
SketchupModel::Dictionary::SpeckleEntityDictionaryHandler.write_initial_base_data(
section_plane, level_data_object['applicationId'], level_data_object['id'], level_data_object['speckle_type'], [], model_card.project_id
)
end
end
end
# rubocop:enable Metrics/ClassLength
@@ -37,12 +37,17 @@ module SpeckleConnector3
# @return [SketchupModel::Definitions::UnpackResult]
attr_reader :unpacked_entities
attr_reader :object_count
attr_reader :cached_object_count
# @param model_card [Cards::SendCard] sender card
def initialize(state, unpacked_entities, model_card)
super(state, model_card)
@send_filter = model_card.send_filter
@conversion_results = []
@unpacked_entities = unpacked_entities
@object_count = 0
@cached_object_count = 0
end
def convert_entities_to_base_blocks_poc
@@ -64,11 +69,9 @@ module SpeckleConnector3
# @return [String, Integer, Array<Object>] base id of base and batches
def serialize(base_and_entity, preferences)
serializer = SpeckleConnector3::Converters::BaseObjectSerializer.new(preferences)
t = Time.now.to_f
id = serializer.serialize(base_and_entity)
batches = serializer.batch_json_objects
write_to_speckle_folder(id, batches)
puts "Generating traversed object elapsed #{(Time.now.to_f - t).round(5)} s"
return id, batches, serializer.object_references
end
@@ -102,9 +105,6 @@ module SpeckleConnector3
# @param entity [Sketchup::Entity]
def entity_has_changed?(entity)
# We do not necessarily consider grouped meshes for caching?
return false if entity.is_a?(SpeckleObjects::Geometry::GroupedMesh)
speckle_state.changed_entity_persistent_ids.include?(entity.persistent_id.to_s) ||
speckle_state.changed_entity_ids.include?(entity.entityID.to_s)
end
@@ -122,26 +122,28 @@ module SpeckleConnector3
# @param speckle_state [States::SpeckleState]
# rubocop:disable Metrics/MethodLength
def from_native_to_speckle(entity, preferences, speckle_state, parent, ignore_cache, &convert)
@object_count += 1
persistent_id = entity.is_a?(SpeckleObjects::Geometry::GroupedMesh) ? entity.faces.first.persistent_id.to_s : entity.persistent_id.to_s
# Where we do send caching!
if !ignore_cache && !entity_has_changed?(entity) &&
speckle_state.object_references_by_project[model_card.project_id] &&
speckle_state.object_references_by_project[model_card.project_id].keys.include?(entity.persistent_id.to_s)
reference = speckle_state.object_references_by_project[model_card.project_id][entity.persistent_id.to_s]
speckle_state.object_references_by_project.keys.include?(model_card.project_id) &&
speckle_state.object_references_by_project[model_card.project_id].keys.include?(persistent_id)
reference = speckle_state.object_references_by_project[model_card.project_id][persistent_id]
add_to_report(entity, reference)
@cached_object_count += 1
return speckle_state, reference
end
if entity.is_a?(SpeckleObjects::Geometry::GroupedMesh)
mesh = SpeckleObjects::Geometry::Mesh.from_faces(speckle_state: speckle_state, faces: entity.faces,
units: @units, model_preferences: preferences[:model])
add_to_report(entity, mesh)
return speckle_state, mesh
end
if entity.is_a?(Sketchup::Edge)
line = SpeckleObjects::Geometry::Line.from_edge(speckle_state: speckle_state, edge: entity,
units: @units, model_preferences: preferences[:model]).to_h
add_to_report(entity, line)
add_to_report(entity, line) unless entity.parent.is_a?(Sketchup::ComponentDefinition)
return speckle_state, line
end
@@ -34,6 +34,41 @@ module SpeckleConnector3
)
end
# this is needed to get last selected account
def self.get_user_selected_account_id
db = Sqlite3::Database.new(SPECKLE_CONFIG_DB_PATH)
row_data = db.exec("SELECT content FROM 'objects' WHERE hash = 'accounts'")
is_config_accounts_exist = !row_data.empty?
return nil unless is_config_accounts_exist
# Select data
row_data = db.exec("SELECT content FROM 'objects' WHERE hash = 'accounts'").first.first
# Parse string to hash
data_hash = JSON.parse(row_data).to_h
# Get current theme value
data_hash['userSelectedAccountId']
end
def self.format_user_selected_accounts_insert(account_id)
"('accounts', '{\"userSelectedAccountId\": \"#{account_id}\"}');"
end
def self.format_user_selected_accounts_update(account_id)
"{\"userSelectedAccountId\": \"#{account_id}\"}"
end
def self.set_user_selected_account_id(account_id)
db = Sqlite3::Database.new(SPECKLE_CONFIG_DB_PATH)
row_data = db.exec("SELECT content FROM 'objects' WHERE hash = 'accounts'")
is_config_accounts_exist = !row_data.empty?
if !is_config_accounts_exist
db.exec("INSERT INTO 'objects' VALUES #{format_user_selected_accounts_insert(account_id)}")
else
db.exec("UPDATE 'objects' SET content = '#{format_user_selected_accounts_update(account_id)}' WHERE hash = 'accounts'")
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)
@@ -48,11 +48,15 @@ module SpeckleConnector3
instance_dictionaries = SketchupModel::Dictionary::BaseDictionaryHandler
.attribute_dictionaries_to_speckle(entity)
instance_att = instance_dictionaries.any? ? { dictionaries: instance_dictionaries } : {}
definition_dictionaries = SketchupModel::Dictionary::BaseDictionaryHandler
.attribute_dictionaries_to_speckle(entity.definition)
instance_att = instance_dictionaries.any? ? { "Instance Attributes": instance_dictionaries, "Definition Attributes": definition_dictionaries } : {}
instance_proxies[instance_id] = SpeckleObjects::InstanceProxy.new(
definition_id,
entity.name,
entity.definition.name,
entity.layer.display_name,
SpeckleObjects::Other::Transform.from_transformation(entity.transformation, @units).value,
depth,
@units,
@@ -98,8 +102,8 @@ module SpeckleConnector3
grouped_meshes = faces.group_by { |face| [face.layer, face.material || face.back_material] }
grouped_meshes.each do |(layer, mat), faces|
material_id = mat.nil? ? 'none' : mat.persistent_id.to_s
grouped_mesh_id = "#{layer.name} - #{material_id} - #{entity.definition.persistent_id.to_s}"
grouped_mesh = SpeckleObjects::Geometry::GroupedMesh.new(faces, layer, mat, grouped_mesh_id)
# grouped_mesh_id = "#{layer.name} - #{material_id} - #{entity.definition.persistent_id.to_s}"
grouped_mesh = SpeckleObjects::Geometry::GroupedMesh.new(faces, layer, mat)
flat_atomic_objects[grouped_mesh.persistent_id.to_s] = grouped_mesh
definition_proxy.add_object_id(grouped_mesh.faces.first.persistent_id.to_s)
end
@@ -72,6 +72,22 @@ module SpeckleConnector3
hash
end
# @param obj [Object] object to write
# @param dict [Sketchup::AttributeDictionary] attribute dictionary to write data.
def self.hash_to_dict(dict_name, obj, dict)
dict_to_write = dict.attribute_dictionary(dict_name, true)
obj.each do |key, value|
# value = obj.instance_variable_get(var)
# var_name = var.to_s[1..-1]
if value.is_a?(Hash) # FIXME or not, depends:-> This doesn't cover arrays that has objects in it.
hash_to_dict(key.to_s, value, dict_to_write)
else
dict_to_write[key] = value
end
end
end
# @return [String] the name of the dictionary to read from
def self.dictionary_name
raise NotImplementedError 'Implement this in subclass'
@@ -13,30 +13,14 @@ module SpeckleConnector3
# @param sketchup_model [Sketchup::Model] sketchup model to save cards into it's attribute dictionary
def self.save_send_card_to_model(send_card, sketchup_model)
send_cards_dict = send_cards_dict(sketchup_model)
serialize_obj_to_dict(send_card.model_card_id, send_card, send_cards_dict)
hash_to_dict(send_card.model_card_id, send_card, send_cards_dict)
end
# @param receive_card [Cards::ReceiveCard] card to save model
# @param sketchup_model [Sketchup::Model] sketchup model to save cards into it's attribute dictionary
def self.save_receive_card_to_model(receive_card, sketchup_model)
receive_cards_dict = receive_cards_dict(sketchup_model)
serialize_obj_to_dict(receive_card.model_card_id, receive_card, receive_cards_dict)
end
# @param obj [Object] object to write
# @param dict [Sketchup::AttributeDictionary] attribute dictionary to write data.
def self.serialize_obj_to_dict(dict_name, obj, dict)
dict_to_write = dict.attribute_dictionary(dict_name, true)
obj.each do |key, value|
# value = obj.instance_variable_get(var)
# var_name = var.to_s[1..-1]
if value.is_a?(Hash) # FIXME or not depends: This doesn't cover arrays that has objects in it.
serialize_obj_to_dict(key.to_s, value, dict_to_write)
else
dict_to_write[key] = value
end
end
hash_to_dict(receive_card.model_card_id, receive_card, receive_cards_dict)
end
def self.remove_card_dict(sketchup_model, data)
@@ -101,7 +85,7 @@ module SpeckleConnector3
dict_to_write = dict_to_write.attribute_dictionary(dict_name, true)
dict_to_write = dict_to_write.attribute_dictionary(var_name, true)
value.each do |key, hash_value|
serialize_obj_to_dict(key.to_s, hash_value, dict_to_write)
hash_to_dict(key.to_s, hash_value, dict_to_write)
end
else
dict_to_write.set_attribute(dict_name, var_name, value)
@@ -34,7 +34,7 @@ module SpeckleConnector3
unless material.nil?
if render_material_proxies.has_key?(material.persistent_id.to_s)
render_material_proxies[material.persistent_id.to_s].add_object_id(entity.persistent_id.to_s)
render_material_proxies[material.persistent_id.to_s].try_add_object_id(entity.persistent_id.to_s)
else
convert_material_and_add_to_proxies(material, entity)
end
@@ -43,7 +43,7 @@ module SpeckleConnector3
unless back_material.nil?
if render_material_proxies.has_key?(back_material.persistent_id.to_s)
render_material_proxies[back_material.persistent_id.to_s]
.add_object_id("#{entity.persistent_id.to_s}_back")
.try_add_object_id("#{entity.persistent_id.to_s}_back")
else
convert_material_and_add_to_proxies(back_material, entity, true)
end
@@ -12,17 +12,24 @@ module SpeckleConnector3
def self.highlight_entities(sketchup_model, entity_ids)
sketchup_model.selection.clear
# below code causing huge performance bottleneck since iterate nestedly, I was initially considering to cover all cases,
# but not worth to have highlighting sub elements since we already highlight the parent. This can be only an issue when user sends
# only the sub elements
# Flat entities to select entities on card
flat_entities = SketchupModel::Query::Entity.flat_entities(sketchup_model.entities)
# flat_entities = SketchupModel::Query::Entity.flat_entities(sketchup_model.entities)
flat_entities.each do |entity|
sketchup_model.entities.each do |entity|
next unless entity_ids.include?(entity.persistent_id.to_s)
sketchup_model.selection.add(entity.instances) if entity.is_a?(Sketchup::ComponentDefinition)
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
@@ -0,0 +1,17 @@
# frozen_string_literal: true
require_relative '../base'
require_relative '../../constants/type_constants'
module SpeckleConnector3
module SpeckleObjects
class DataObject < Base
SPECKLE_TYPE = SPECKLE_OBJECT_DATA_OBJECT
def self.to_native(state, data_object, layer, _entities, &convert_to_native)
properties = data_object['properties']
return state
end
end
end
end
@@ -0,0 +1,25 @@
# frozen_string_literal: true
require_relative '../base'
require_relative '../../constants/type_constants'
require_relative '../other/display_value'
require_relative '../../sketchup_model/dictionary/base_dictionary_handler'
module SpeckleConnector3
module SpeckleObjects
class RevitDataObject < Base
SPECKLE_TYPE = SPECKLE_OBJECT_DATA_OBJECT_REVIT
def self.to_native(state, revit_data_object, layer, entities, &convert_to_native)
properties = revit_data_object['properties']
new_state, instance_and_definition = SpeckleObjects::Other::DisplayValue.to_native(state, revit_data_object, layer, entities, &convert_to_native)
instance, _definition = instance_and_definition
attr = instance.attribute_dictionary('Speckle', true)
SketchupModel::Dictionary::BaseDictionaryHandler.hash_to_dict('Revit Parameters', properties, attr) if properties
return new_state, instance_and_definition
end
end
end
end
@@ -28,15 +28,19 @@ module SpeckleConnector3
# @return [Sketchup::Material] material that faces belong to
attr_reader :material
# @return [String] structured id for grouped mesh
# @return [String] fake id for grouped mesh
attr_reader :persistent_id
# @return [String] fake id for grouped mesh
attr_reader :entityID
# @return Hash{String=>Sketchup::Face}
attr_reader :mesh_groups
def initialize(faces, layer, material, persistent_id)
def initialize(faces, layer, material)
@faces = faces
@persistent_id = persistent_id
@persistent_id = faces.first.persistent_id.to_s
@entityID = faces.first.persistent_id.to_s
@layer = layer
@material = material
@mesh_groups = {}
@@ -8,13 +8,15 @@ module SpeckleConnector3
module SpeckleObjects
class InstanceProxy < Base
SPECKLE_TYPE = SPECKLE_CORE_MODELS_INSTANCES_INSTANCE_PROXY
def initialize(definition_id, name, transform, max_depth, units, sketchup_attributes: {}, application_id: nil)
def initialize(definition_id, name, definitionName, layerName, transform, max_depth, units, sketchup_attributes: {}, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
application_id: application_id,
id: nil
)
self[:name] = name if name != ""
self[:definition] = definitionName if definitionName != ""
self[:layer] = layerName if layerName != ""
self[:units] = units
self[:definitionId] = definition_id
self[:maxDepth] = max_depth
@@ -44,7 +44,7 @@ module SpeckleConnector3
# @param argb [Numeric] int value of the corresponding color
# @return [Sketchup::Color] sketchup color
def self.from_int(argb)
Sketchup::Color.new((argb >> 16) & 255, (argb >> 8) & 255, argb & 255, (argb >> 24) & 255)
Sketchup::Color.new((argb.to_i >> 16) & 255, (argb.to_i >> 8) & 255, argb.to_i & 255, (argb.to_i >> 24) & 255)
end
end
end
@@ -114,7 +114,8 @@ module SpeckleConnector3
speckle_folders = layers_relation[:elements].reject { |layer_or_fol| layer_or_fol[:elements].nil? }
speckle_folders.each do |speckle_folder|
sub_folder = folder.add_folder(speckle_folder[:name])
folder_name = speckle_folder[:name] == '' ? 'Unnamed' : speckle_folder[:name]
sub_folder = folder.add_folder(folder_name)
sub_folder.visible = speckle_folder[:visible] unless speckle_folder[:visible].nil?
to_native_layer_folder(speckle_folder, color_proxies, sub_folder, sketchup_model, project_id, model_id)
end
@@ -35,9 +35,11 @@ module SpeckleConnector3
end
# @param object_id [String] application id of the object to add into proxy list
def add_object_id(object_id)
object_ids.append(object_id)
self[:objects] = object_ids
def try_add_object_id(object_id)
unless object_ids.include?(object_id)
object_ids.append(object_id)
self[:objects] = object_ids
end
end
end
end
@@ -12,6 +12,23 @@ module SpeckleConnector3
module Speckle
module Core
module Models
class Debouncer
def initialize(wait_time)
@wait_time = wait_time
@mutex = Mutex.new
@thread = nil
end
def call(&block)
@mutex.synchronize do
@thread&.kill # Cancel the previous execution
@thread = Thread.new do
sleep @wait_time
block.call
end
end
end
end
# ModelCollection object that collect other speckle objects under it's elements.
class ModelCollection < Collection
DIRECT_SHAPE = SpeckleObjects::BuiltElements::Revit::DirectShape
@@ -61,6 +78,8 @@ module SpeckleConnector3
application_id: sketchup_model.guid
)
last_sent_time = Time.now
count = 0
entities.each do |entity|
layer_collection = LayerCollection.get_or_create_layer_collection(entity.layer, model_collection)
@@ -83,13 +102,10 @@ module SpeckleConnector3
status: progress == 1 ? 'Completed' : 'Converting'
}
}
action = Proc.new do
if Time.now - last_sent_time >= 1
state.instant_message_sender.call("sendBinding.emit('setModelProgress', #{sender_progress_args.to_json})")
last_sent_time = Time.now
end
state.worker.add_job(Job.new(entity.persistent_id.to_s, &action))
state.worker.do_work(Time.now.to_f, &action)
end
return speckle_state, model_collection
@@ -1,7 +1,9 @@
# frozen_string_literal: true
require_relative 'binding'
require_relative '../../actions/get_accounts'
require_relative '../../actions/account_actions/get_accounts'
require_relative '../../actions/account_actions/add_account'
require_relative '../../actions/account_actions/remove_account'
module SpeckleConnector3
module Ui
@@ -11,7 +13,9 @@ module SpeckleConnector3
class AccountsBinding < Binding
def commands
@commands ||= {
getAccounts: Commands::ActionCommand.new(@app, self, Actions::GetAccounts)
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
end
@@ -11,6 +11,7 @@ require_relative '../../actions/base_actions/add_model'
require_relative '../../actions/base_actions/highlight_model'
require_relative '../../actions/base_actions/highlight_objects'
require_relative '../../actions/base_actions/remove_model'
require_relative '../../actions/base_actions/remove_models'
require_relative '../../actions/base_actions/get_send_filters'
require_relative '../../actions/base_actions/update_send_filter'
require_relative '../../actions/base_actions/get_document_state'
@@ -27,6 +28,7 @@ module SpeckleConnector3
highlightModel: Commands::ActionCommand.new(@app, self, Actions::HighlightModel),
highlightObjects: Commands::ActionCommand.new(@app, self, Actions::HighlightObjects),
removeModel: Commands::ActionCommand.new(@app, self, Actions::RemoveModel),
removeModels: Commands::ActionCommand.new(@app, self, Actions::RemoveModels),
# Since we send exact model card with updateModel, I can use directly AddModel action, it will replace
updateModel: Commands::ActionCommand.new(@app, self, Actions::AddModel),
getSourceApplicationName: Commands::ActionCommand.new(@app, self, Actions::GetSourceAppName),
@@ -4,6 +4,8 @@ require_relative 'binding'
require_relative '../../actions/config_actions/get_is_dev_mode'
require_relative '../../actions/config_actions/get_config'
require_relative '../../actions/config_actions/update_config'
require_relative '../../actions/config_actions/get_user_selected_account_id'
require_relative '../../actions/config_actions/set_user_selected_account_id'
module SpeckleConnector3
module Ui
@@ -15,7 +17,9 @@ module SpeckleConnector3
@commands ||= {
getIsDevMode: Commands::ActionCommand.new(@app, self, Actions::GetIsDevMode),
getConfig: Commands::ActionCommand.new(@app, self, Actions::GetConfig),
updateConfig: Commands::ActionCommand.new(@app, self, Actions::UpdateConfig)
updateConfig: Commands::ActionCommand.new(@app, self, Actions::UpdateConfig),
getUserSelectedAccountId: Commands::ActionCommand.new(@app, self, Actions::GetUserSelectedAccountId),
setUserSelectedAccountId: Commands::ActionCommand.new(@app, self, Actions::SetUserSelectedAccountId)
}.freeze
end
end
+1 -1
View File
@@ -85,7 +85,7 @@ module SpeckleConnector3
end
# File.exist?(@htm_file) ? dialog.set_file(@htm_file) : dialog.set_url('http://localhost:9091')
# dialog.set_url('http://localhost:8082') # uncomment this line if you want to use your local version of ui
dialog.set_url('https://boisterous-douhua-e3cefb.netlify.app/') # uncomment this line if you want to use deployed ui on netlify
dialog.set_url('https://dui.speckle.systems/') # uncomment this line if you want to use deployed ui on netlify
add_exec_callback(dialog)
dialog
end
+1 -1
View File
@@ -5,7 +5,7 @@ module SpeckleConnector3
# An interface to Sketchup user interface. This object controls the menu `Extensions->Speckle` in Sketchup's menu,
# the Speckle toolbar and sending message to the user via Sketchup.
class SketchupUi
MENU_TITLE = 'Speckle Beta'
MENU_TITLE = 'Speckle'
BEFORE_NEVER_SHOWN = -1
# @return [Sketchup::Menu] the menu of the Speckle