Compare commits

..

4 Commits

Author SHA1 Message Date
oguzhankoral 18caf16621 WIP 2024-02-12 18:09:31 +03:00
oguzhankoral c781534950 Trigger sketchup only saved stream not exists 2024-02-12 11:52:18 +03:00
oguzhankoral 886ede61e1 Enrich selected account info and fix same user id issue 2024-02-12 11:31:02 +03:00
oguzhankoral 5a42ea39ce Disable reload 2024-02-12 11:30:39 +03:00
48 changed files with 378 additions and 821 deletions
+34 -47
View File
@@ -26,17 +26,21 @@ jobs:
build-connector: # Reusable job for basic connectors build-connector: # Reusable job for basic connectors
executor: executor:
name: win/default # comes with python 3.7.3 name: win/default # comes with python 3.7.3
shell: powershell.exe shell: cmd.exe
parameters: parameters:
slug: slug:
type: string type: string
default: "" default: ""
environment:
SSM: 'C:\Program Files\DigiCert\DigiCert One Signing Manager Tools'
steps: steps:
- checkout - checkout
- attach_workspace: - attach_workspace:
at: ./ at: ./
- run:
name: Create Innosetup signing cert
shell: powershell.exe
command: |
echo $env:PFX_B64 > "speckle-sharp-ci-tools\SignTool\AEC Systems Ltd.txt"
certutil -decode "speckle-sharp-ci-tools\SignTool\AEC Systems Ltd.txt" "speckle-sharp-ci-tools\SignTool\AEC Systems Ltd.pfx"
- run: - run:
name: Set Environment Variable name: Set Environment Variable
shell: powershell.exe shell: powershell.exe
@@ -48,36 +52,25 @@ jobs:
python patch_version.py $semver python patch_version.py $semver
environment: environment:
WORKFLOW_NUM: << pipeline.number >> WORKFLOW_NUM: << pipeline.number >>
- unless: # Build installers unsigned on non-tagged builds - run:
condition: << pipeline.git.tag >> name: Build Installer
steps: command: speckle-sharp-ci-tools\InnoSetup\ISCC.exe speckle-sharp-ci-tools\sketchup.iss /Sbyparam=$p
- run: shell: cmd.exe #does not work in powershell
name: Build Installer
command: speckle-sharp-ci-tools\InnoSetup\ISCC.exe speckle-sharp-ci-tools\sketchup.iss /Sbyparam=$p #- run:
shell: cmd.exe # does not work in powershell # name: Patch
- when: # Setup certificates and build installers signed for tagged builds # shell: powershell.exe
condition: << pipeline.git.tag >> # command:
steps: # | # If no tag, use 0.0.0.1 and don't make any YML (for testing only!)
- run: # $tag = if([string]::IsNullOrEmpty($env:CIRCLE_TAG)) { "0.0.0" } else { $env:CIRCLE_TAG }
name: "Digicert Signing Manager Setup" # $semver = if($tag.Contains('/')) {$tag.Split("/")[1] } else { $tag }
command: | # $ver = if($semver.Contains('-')) {$semver.Split("-")[0] } else { $semver }
cd C:\ # $channel = if($semver.Contains('-')) {$semver.Split("-")[1] } else { "latest" }
curl.exe -X GET https://one.digicert.com/signingmanager/api-ui/v1/releases/smtools-windows-x64.msi/download -H "x-api-key:$env:SM_API_KEY" -o smtools-windows-x64.msi # $version = "$($ver).$($env:CIRCLE_BUILD_NUM)"
msiexec.exe /i smtools-windows-x64.msi /quiet /qn | Wait-Process # New-Item -Force "speckle-sharp-ci-tools/Installers/sketchup/$channel.yml" -ItemType File -Value "version: $semver"
- run: # echo $version
name: "Create Auth & OV Signing Cert" # python patch_version.py $semver
command: | # speckle-sharp-ci-tools\InnoSetup\ISCC.exe speckle-sharp-ci-tools\sketchup.iss
cd C:\
echo $env:SM_CLIENT_CERT_FILE_B64 > certificate.txt
certutil -decode certificate.txt certificate.p12
- run:
name: "Sync Certs"
command: |
& $env:SSM\smksp_cert_sync.exe
- run:
name: "Build Installer"
command: speckle-sharp-ci-tools\InnoSetup\ISCC.exe speckle-sharp-ci-tools\sketchup.iss /Sbyparam=$p /DSIGN_INSTALLER /DCODE_SIGNING_CERT_FINGERPRINT=%SM_CODE_SIGNING_CERT_SHA1_HASH%
shell: cmd.exe
- persist_to_workspace: - persist_to_workspace:
root: ./ root: ./
paths: paths:
@@ -85,7 +78,7 @@ jobs:
build-connector-mac: build-connector-mac:
macos: macos:
xcode: 13.4.1 xcode: 12.5.1
parameters: parameters:
projname: projname:
type: string type: string
@@ -142,8 +135,8 @@ jobs:
- run: - run:
name: Copy files to installer name: Copy files to installer
command: | command: |
mkdir -p speckle-sharp-ci-tools/Mac/<< parameters.installername >>/.installationFiles/ mkdir -p speckle-sharp-ci-tools/Mac/<< parameters.installername >>/.installationFiles/
cp << parameters.slug >>-mac.zip speckle-sharp-ci-tools/Mac/<<parameters.installername>>/.installationFiles cp << parameters.slug >>-mac.zip speckle-sharp-ci-tools/Mac/<<parameters.installername>>/.installationFiles
# Create installer # Create installer
- run: - run:
name: Exit if External PR name: Exit if External PR
@@ -191,16 +184,10 @@ jobs:
- run: - run:
name: Clone name: Clone
command: git clone git@github.com:specklesystems/speckle-sharp-ci-tools.git speckle-sharp-ci-tools command: git clone git@github.com:specklesystems/speckle-sharp-ci-tools.git speckle-sharp-ci-tools
- run: - persist_to_workspace:
name: Checkout branch root: ./
command: | paths:
cd speckle-sharp-ci-tools - speckle-sharp-ci-tools
if [ -z "$CIRCLE_TAG" ]
then
git checkout ${CIRCLE_BRANCH} || git checkout main
else
git checkout ${CIRCLE_TAG} || git checkout main
fi
- persist_to_workspace: - persist_to_workspace:
root: ./ root: ./
paths: paths:
@@ -251,7 +238,7 @@ workflows:
filters: filters:
tags: tags:
only: /.*/ only: /.*/
context: digicert-keylocker context: innosetup
- build-connector-mac: - build-connector-mac:
slug: sketchup slug: sketchup
+1 -1
View File
@@ -1,3 +1,3 @@
[submodule "_sqlite3"] [submodule "_sqlite3"]
path = _sqlite3 path = _sqlite3
url = https://github.com/specklesystems/sketchup-sqlite3.git url = git@github.com:specklesystems/sketchup-sqlite3.git
+35 -14
View File
@@ -2,14 +2,44 @@
<img src="https://user-images.githubusercontent.com/2679513/131189167-18ea5fe1-c578-47f6-9785-3748178e4312.png" width="150px"/><br/> <img src="https://user-images.githubusercontent.com/2679513/131189167-18ea5fe1-c578-47f6-9785-3748178e4312.png" width="150px"/><br/>
Speckle | SketchUp Speckle | SketchUp
</h1> </h1>
<p align="center"><a href="https://twitter.com/SpeckleSystems"><img src="https://img.shields.io/twitter/follow/SpeckleSystems?style=social" alt="Twitter Follow"></a> <a href="https://speckle.community"><img src="https://img.shields.io/discourse/users?server=https%3A%2F%2Fspeckle.community&amp;style=flat-square&amp;logo=discourse&amp;logoColor=white" alt="Community forum users"></a> <a href="https://speckle.systems"><img src="https://img.shields.io/badge/https://-speckle.systems-royalblue?style=flat-square" alt="website"></a> <a href="https://speckle.guide/dev/"><img src="https://img.shields.io/badge/docs-speckle.guide-orange?style=flat-square&amp;logo=read-the-docs&amp;logoColor=white" alt="docs"></a></p>
> Speckle is the first AEC data hub that connects with your favorite AEC tools. Speckle exists to overcome the challenges of working in a fragmented industry where communication, creative workflows, and the exchange of data are often hindered by siloed software and processes. It is here to make the industry better.
<h3 align="center"> <h3 align="center">
Connector for SketchUp Connector for SketchUp
</h3> </h3>
<p align="center"><b>Speckle</b> is the data infrastructure for the AEC industry.</p><br/>
<p align="center"><a href="https://twitter.com/SpeckleSystems"><img src="https://img.shields.io/twitter/follow/SpeckleSystems?style=social" alt="Twitter Follow"></a> <a href="https://speckle.community"><img src="https://img.shields.io/discourse/users?server=https%3A%2F%2Fspeckle.community&amp;style=flat-square&amp;logo=discourse&amp;logoColor=white" alt="Community forum users"></a> <a href="https://speckle.systems"><img src="https://img.shields.io/badge/https://-speckle.systems-royalblue?style=flat-square" alt="website"></a> <a href="https://speckle.guide/dev/"><img src="https://img.shields.io/badge/docs-speckle.guide-orange?style=flat-square&amp;logo=read-the-docs&amp;logoColor=white" alt="docs"></a></p>
<p align="center"><a href="https://github.com/specklesystems/speckle-blender/"><img src="https://circleci.com/gh/specklesystems/speckle-blender.svg?style=svg&amp;circle-token=76eabd350ea243575cbb258b746ed3f471f7ac29" alt="Speckle-Next"></a> </p>
# About Speckle
What is Speckle? Check our ![YouTube Video Views](https://img.shields.io/youtube/views/B9humiSpHzM?label=Speckle%20in%201%20minute%20video&style=social)
### Features
- **Object-based:** say goodbye to files! Speckle is the first object based platform for the AEC industry
- **Version control:** Speckle is the Git & Hub for geometry and BIM data
- **Collaboration:** share your designs collaborate with others
- **3D Viewer:** see your CAD and BIM models online, share and embed them anywhere
- **Interoperability:** get your CAD and BIM models into other software without exporting or importing
- **Real time:** get real time updates and notifications and changes
- **GraphQL API:** get what you need anywhere you want it
- **Webhooks:** the base for a automation and next-gen pipelines
- **Built for developers:** we are building Speckle with developers in mind and got tools for every stack
- **Built for the AEC industry:** Speckle connectors are plugins for the most common software used in the industry such as Revit, Rhino, Grasshopper, AutoCAD, Civil 3D, Excel, Unreal Engine, Unity, QGIS, Blender and more!
### Try Speckle now!
Give Speckle a try in no time by:
- [![speckle XYZ](https://img.shields.io/badge/https://-speckle.xyz-0069ff?style=flat-square&logo=hackthebox&logoColor=white)](https://speckle.xyz) ⇒ creating an account at our public server
- [![create a droplet](https://img.shields.io/badge/Create%20a%20Droplet-0069ff?style=flat-square&logo=digitalocean&logoColor=white)](https://marketplace.digitalocean.com/apps/speckle-server?refcode=947a2b5d7dc1) ⇒ deploying an instance in 1 click
### Resources
- [![Community forum users](https://img.shields.io/badge/community-forum-green?style=for-the-badge&logo=discourse&logoColor=white)](https://speckle.community) for help, feature requests or just to hang with other speckle enthusiasts, check out our community forum!
- [![website](https://img.shields.io/badge/tutorials-speckle.systems-royalblue?style=for-the-badge&logo=youtube)](https://speckle.systems) our tutorials portal is full of resources to get you started using Speckle
- [![docs](https://img.shields.io/badge/docs-speckle.guide-orange?style=for-the-badge&logo=read-the-docs&logoColor=white)](https://speckle.guide/user/blender.html) reference on almost any end-user and developer functionality
# Repo structure # Repo structure
@@ -37,15 +67,6 @@ This repo is split into three parts:
by solution to place them into source code into `speckle_connector/src/ext`. Building this project should be only by solution to place them into source code into `speckle_connector/src/ext`. Building this project should be only
happen when SketchUp starts to support newer Ruby versions (currently it is `2.7`). happen when SketchUp starts to support newer Ruby versions (currently it is `2.7`).
### Other repos
Make sure to also check and ⭐️ these other Speckle next generation repositories:
- [`speckle-sharp-connectors`](https://github.com/specklesystems/speckle-sharp-connectors): .NET connectors and desktop UI
- [`speckle-sharp-sdk`](https://github.com/specklesystems/speckle-sharp-sdk): our .NET SDK for next gen connectors and development
- [`speckle-powerbi`](https://github.com/specklesystems/speckle-powerbi): PowerBi connector
- and more [connectors & tooling](https://github.com/specklesystems/)!
## Contribution Guide ## Contribution Guide
Before start to contribute, it is better to understand how align with other contributors. It will make easier job Before start to contribute, it is better to understand how align with other contributors. It will make easier job
+1 -1
View File
@@ -24,7 +24,7 @@ module SpeckleConnector
# Run from localhost or from build files # Run from localhost or from build files
DEV_MODE = false DEV_MODE = false
puts("Loading Speckle (Legacy) Connector v#{CONNECTOR_VERSION} from #{DEV_MODE ? 'dev' : 'build'}") puts("Loading Speckle Connector v#{CONNECTOR_VERSION} from #{DEV_MODE ? 'dev' : 'build'}")
unless file_loaded?(__FILE__) unless file_loaded?(__FILE__)
ex = SketchupExtension.new('Speckle SketchUp', File.join(PATH, 'bootstrap')) ex = SketchupExtension.new('Speckle SketchUp', File.join(PATH, 'bootstrap'))
Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

@@ -12,7 +12,7 @@ module SpeckleConnector
# This is the command where we show UI to user. # This is the command where we show UI to user.
class InitializeSpeckle < Command class InitializeSpeckle < Command
def dialog_title def dialog_title
"Speckle (Legacy) #{CONNECTOR_VERSION}" "Speckle #{CONNECTOR_VERSION}"
end end
private private
@@ -30,14 +30,18 @@ module SpeckleConnector
commands[CMD_RESET_WINDOW_LOCATION_SPECKLE] = reset_window_location_command(app) commands[CMD_RESET_WINDOW_LOCATION_SPECKLE] = reset_window_location_command(app)
commands.add_to_menu!(CMD_RESET_WINDOW_LOCATION_SPECKLE, speckle_menu) commands.add_to_menu!(CMD_RESET_WINDOW_LOCATION_SPECKLE, speckle_menu)
# commands[CMD_SEND_TO_SPECKLE] = send_command(app)
# commands.add_to_menu!(CMD_SEND_TO_SPECKLE, speckle_menu)
# commands.add_to_toolbar!(CMD_SEND_TO_SPECKLE, speckle_toolbar)
end end
def self.initialize_speckle_command(app) def self.initialize_speckle_command(app)
cmd = MenuCommandHandler.sketchup_command( cmd = MenuCommandHandler.sketchup_command(
InitializeSpeckle.new(app), 'Initialize Speckle (Legacy)' InitializeSpeckle.new(app), 'Initialize Speckle'
) )
cmd.tooltip = 'Launch Connector' cmd.tooltip = 'Launch Connector'
cmd.status_bar_text = 'Opens the Speckle (Legacy) Connector window' cmd.status_bar_text = 'Opens the Speckle Connector window'
cmd.small_icon = '../../img/s2logo.png' cmd.small_icon = '../../img/s2logo.png'
cmd.large_icon = '../../img/s2logo.png' cmd.large_icon = '../../img/s2logo.png'
cmd cmd
@@ -53,6 +57,18 @@ module SpeckleConnector
cmd.large_icon = '../../img/s2logo.png' cmd.large_icon = '../../img/s2logo.png'
cmd cmd
end end
def self.send_command(app)
cmd = MenuCommandHandler.sketchup_command(
ActionCommand.new(app, Actions::OneClickSend), 'Send to Speckle'
)
cmd.tooltip = 'Send to Speckle'
cmd.status_bar_text = 'Send to Speckle'
cmd.small_icon = '../../img/Sender.png'
cmd.large_icon = '../../img/Sender.png'
cmd.set_validation_proc { MenuCommandHandler.speckle_started(app) }
cmd
end
end end
end end
end end
@@ -14,9 +14,7 @@ module SpeckleConnector
path = ENV.fetch('APPDATA') path = ENV.fetch('APPDATA')
Pathname.new(File.join(path, 'Speckle')).cleanpath.to_s Pathname.new(File.join(path, 'Speckle')).cleanpath.to_s
when OS_MAC when OS_MAC
primary_path = File.join(Dir.home, '.config/Speckle') File.join(Dir.home, '.config/Speckle')
fallback_path = File.join(Dir.home, 'Library/Application Support/Speckle')
Dir.exist?(primary_path) ? primary_path : fallback_path
else else
raise 'Speckle could not determine your Appdata path' raise 'Speckle could not determine your Appdata path'
end end
@@ -15,7 +15,7 @@ module SpeckleConnector
Sketchup::ComponentInstance => INCLUDE_COMPONENT_ENTITY_ATTRIBUTES, Sketchup::ComponentInstance => INCLUDE_COMPONENT_ENTITY_ATTRIBUTES,
Sketchup::Group => INCLUDE_GROUP_ENTITY_ATTRIBUTES, Sketchup::Group => INCLUDE_GROUP_ENTITY_ATTRIBUTES,
Sketchup::Face => INCLUDE_FACE_ENTITY_ATTRIBUTES, Sketchup::Face => INCLUDE_FACE_ENTITY_ATTRIBUTES,
Sketchup::Edge => INCLUDE_EDGE_ENTITY_ATTRIBUTES Sketchup::Face => INCLUDE_EDGE_ENTITY_ATTRIBUTES
}.freeze }.freeze
LEVEL_SHIFT_VALUE = SpeckleObjects::Geometry.length_to_native(1.5, 'm') LEVEL_SHIFT_VALUE = SpeckleObjects::Geometry.length_to_native(1.5, 'm')
@@ -13,14 +13,6 @@ module SpeckleConnector
OBJECTS_BUILTELEMENTS_REVIT_FLOOR = 'Objects.BuiltElements.Floor:Objects.BuiltElements.Revit.RevitFloor' OBJECTS_BUILTELEMENTS_REVIT_FLOOR = 'Objects.BuiltElements.Floor:Objects.BuiltElements.Revit.RevitFloor'
OBJECTS_BUILTELEMENTS_DEFAULT_WALL = 'Objects.BuiltElements.Wall' OBJECTS_BUILTELEMENTS_DEFAULT_WALL = 'Objects.BuiltElements.Wall'
OBJECTS_BUILTELEMENTS_REVIT_WALL = 'Objects.BuiltElements.Wall:Objects.BuiltElements.Revit.RevitWall' OBJECTS_BUILTELEMENTS_REVIT_WALL = 'Objects.BuiltElements.Wall:Objects.BuiltElements.Revit.RevitWall'
OBJECTS_BUILTELEMENTS_DEFAULT_COLUMN = 'Objects.BuiltElements.Column'
OBJECTS_BUILTELEMENTS_REVIT_COLUMN = 'Objects.BuiltElements.Column:Objects.BuiltElements.Revit.RevitColumn'
OBJECTS_BUILTELEMENTS_DEFAULT_BEAM = 'Objects.BuiltElements.Beam'
OBJECTS_BUILTELEMENTS_REVIT_BEAM = 'Objects.BuiltElements.Beam:Objects.BuiltElements.Revit.RevitBeam'
OBJECTS_BUILTELEMENTS_DEFAULT_PIPE = 'Objects.BuiltElements.Pipe'
OBJECTS_BUILTELEMENTS_REVIT_PIPE = 'Objects.BuiltElements.Pipe:Objects.BuiltElements.Revit.RevitPipe'
OBJECTS_BUILTELEMENTS_DEFAULT_DUCT = 'Objects.BuiltElements.Duct'
OBJECTS_BUILTELEMENTS_REVIT_DUCT = 'Objects.BuiltElements.Duct:Objects.BuiltElements.Revit.RevitDuct'
OBJECTS_BUILTELEMENTS_REVIT_DIRECTSHAPE = 'Objects.BuiltElements.Revit.DirectShape' OBJECTS_BUILTELEMENTS_REVIT_DIRECTSHAPE = 'Objects.BuiltElements.Revit.DirectShape'
OBJECTS_BUILTELEMENTS_REVIT_FAMILY_INSTANCE = 'Objects.BuiltElements.Revit.FamilyInstance' OBJECTS_BUILTELEMENTS_REVIT_FAMILY_INSTANCE = 'Objects.BuiltElements.Revit.FamilyInstance'
OBJECTS_BUILTELEMENTS_REVIT_PARAMETER = 'Objects.BuiltElements.Revit.Parameter' OBJECTS_BUILTELEMENTS_REVIT_PARAMETER = 'Objects.BuiltElements.Revit.Parameter'
@@ -75,8 +75,7 @@ module SpeckleConnector
# rubocop:disable Metrics/MethodLength # rubocop:disable Metrics/MethodLength
def from_native_to_speckle(entity, preferences, speckle_state, parent, &convert) def from_native_to_speckle(entity, preferences, speckle_state, parent, &convert)
if entity.is_a?(Sketchup::Edge) if entity.is_a?(Sketchup::Edge)
line = SpeckleObjects::Geometry::Line.from_edge(speckle_state: speckle_state, edge: entity, line = SpeckleObjects::Geometry::Line.from_edge(entity, @units, preferences[:model]).to_h
units: @units, model_preferences: preferences[:model]).to_h
return speckle_state, [line, [entity]] return speckle_state, [line, [entity]]
end end
Binary file not shown.
Binary file not shown.
+24 -89
View File
@@ -2,17 +2,8 @@
require_relative '../speckle_objects/built_elements/revit/revit_floor' require_relative '../speckle_objects/built_elements/revit/revit_floor'
require_relative '../speckle_objects/built_elements/revit/revit_wall' require_relative '../speckle_objects/built_elements/revit/revit_wall'
require_relative '../speckle_objects/built_elements/revit/direct_shape'
require_relative '../speckle_objects/built_elements/revit/revit_column'
require_relative '../speckle_objects/built_elements/revit/revit_beam'
require_relative '../speckle_objects/built_elements/revit/revit_pipe'
require_relative '../speckle_objects/built_elements/revit/revit_duct'
require_relative '../speckle_objects/built_elements/default_floor' require_relative '../speckle_objects/built_elements/default_floor'
require_relative '../speckle_objects/built_elements/default_wall' require_relative '../speckle_objects/built_elements/default_wall'
require_relative '../speckle_objects/built_elements/default_column'
require_relative '../speckle_objects/built_elements/default_beam'
require_relative '../speckle_objects/built_elements/default_duct'
require_relative '../speckle_objects/built_elements/default_pipe'
require_relative '../speckle_objects/other/mapped_block_wrapper' require_relative '../speckle_objects/other/mapped_block_wrapper'
require_relative '../sketchup_model/query/entity' require_relative '../sketchup_model/query/entity'
require_relative '../sketchup_model/reader/mapper_reader' require_relative '../sketchup_model/reader/mapper_reader'
@@ -21,23 +12,18 @@ require_relative '../sketchup_model/dictionary/speckle_schema_dictionary_handler
module SpeckleConnector module SpeckleConnector
# Mapper is a tool to convert SketchUp entities to other applications' native objects. # Mapper is a tool to convert SketchUp entities to other applications' native objects.
module Mapper module Mapper
QUERY = SketchupModel::Query
MAPPER_READER = SketchupModel::Reader::MapperReader
SPECKLE_SCHEMA_DICTIONARY_HANDLER = SketchupModel::Dictionary::SpeckleSchemaDictionaryHandler
DIRECT_SHAPE = SpeckleObjects::BuiltElements::Revit::DirectShape
# Collects mapped entities on selection as flat list. # Collects mapped entities on selection as flat list.
def self.mapped_entities_on_selection(sketchup_model) def self.mapped_entities_on_selection(sketchup_model)
flat_selection_with_path = QUERY::Entity.flat_entities_with_path( flat_selection_with_path = SketchupModel::Query::Entity.flat_entities_with_path(
sketchup_model.selection, sketchup_model.selection,
[Sketchup::Edge, Sketchup::Face, Sketchup::ComponentInstance, Sketchup::Group], [sketchup_model] [Sketchup::Face, Sketchup::ComponentInstance, Sketchup::Group], [sketchup_model]
) )
mapped_selection = [] mapped_selection = []
flat_selection_with_path.each do |entities| flat_selection_with_path.each do |entities|
entity = entities[0] entity = entities[0]
is_entity_mapped = MAPPER_READER.mapped_with_schema?(entity) is_entity_mapped = SketchupModel::Reader::MapperReader.mapped_with_schema?(entity)
if entity.respond_to?(:definition) if entity.respond_to?(:definition)
is_definition_mapped = MAPPER_READER.mapped_with_schema?(entity.definition) is_definition_mapped = SketchupModel::Reader::MapperReader.mapped_with_schema?(entity.definition)
mapped_selection.append(entities) if is_entity_mapped || is_definition_mapped mapped_selection.append(entities) if is_entity_mapped || is_definition_mapped
next next
end end
@@ -46,82 +32,31 @@ module SpeckleConnector
mapped_selection mapped_selection
end end
def self.convert_mapped_entity(speckle_state, entity_with_path, preferences, units, &convert) def self.to_speckle(speckle_state, entity, units, model_preferences, global_transformation: nil, path: nil)
entity = entity_with_path[0] speckle_schema = SketchupModel::Dictionary::SpeckleSchemaDictionaryHandler.speckle_schema_to_speckle(entity)
method = get_method(entity)
return nil if method.nil?
path = entity_with_path[1..-1]
if face_mapping?(entity, method)
global_transformation = QUERY::Entity.global_transformation(entity, path)
face = SpeckleObjects::Geometry::Mesh.from_face(speckle_state: speckle_state, face: entity,
units: units, model_preferences: preferences,
global_transform: global_transformation)
return [face, [entity]]
end
if edge_mapping?(entity, method)
global_transformation = QUERY::Entity.global_transformation(entity, path)
edge = SpeckleObjects::Geometry::Line.from_edge(speckle_state: speckle_state, edge: entity,
units: units, model_preferences: preferences,
global_transformation: global_transformation)
return [edge, [entity]]
end
if method == 'Direct Shape'
direct_shape = DIRECT_SHAPE.from_entity(speckle_state, entity, path, units, preferences)
return [direct_shape, [entity]]
end
if ['New Revit Family', 'Family Instance'].include?(method)
_speckle_state, block_instance = SpeckleObjects::Other::BlockInstance.from_component_instance(
entity, units, preferences, speckle_state, path: path, &convert
)
return [block_instance, [entity]]
end
nil
end
NATIVE_MAPPING_TO_SPECKLE = {
'Default Column' => SpeckleObjects::BuiltElements::DefaultColumn.method(:to_speckle_schema),
'Default Beam' => SpeckleObjects::BuiltElements::DefaultBeam.method(:to_speckle_schema),
'Default Pipe' => SpeckleObjects::BuiltElements::DefaultPipe.method(:to_speckle_schema),
'Default Duct' => SpeckleObjects::BuiltElements::DefaultDuct.method(:to_speckle_schema),
'Column' => SpeckleObjects::BuiltElements::RevitColumn.method(:to_speckle_schema),
'Beam' => SpeckleObjects::BuiltElements::RevitBeam.method(:to_speckle_schema),
'Pipe' => SpeckleObjects::BuiltElements::RevitPipe.method(:to_speckle_schema),
'Duct' => SpeckleObjects::BuiltElements::RevitDuct.method(:to_speckle_schema)
}.freeze
def self.to_speckle(speckle_state, entity, units, global_transformation: nil)
speckle_schema = SPECKLE_SCHEMA_DICTIONARY_HANDLER.speckle_schema_to_speckle(entity)
return speckle_schema if speckle_schema.nil? return speckle_schema if speckle_schema.nil?
to_speckle_schema_method = NATIVE_MAPPING_TO_SPECKLE[speckle_schema['method']] if speckle_schema['method'] == 'Default Floor'
return speckle_schema if to_speckle_schema_method.nil? return SpeckleObjects::BuiltElements::DefaultFloor
.to_speckle_schema(entity, units, global_transformation: global_transformation)
to_speckle_schema_method.call(speckle_state, entity, units, global_transformation: global_transformation)
end
def self.get_method(entity)
method = SPECKLE_SCHEMA_DICTIONARY_HANDLER.get_attribute(entity, 'method')
return method if method
if entity.is_a?(Sketchup::ComponentInstance)
method = SPECKLE_SCHEMA_DICTIONARY_HANDLER.get_attribute(entity.definition, 'method')
end end
method
end
def self.face_mapping?(entity, method) if speckle_schema['method'] == 'Floor'
(method.include?('Floor') || method.include?('Wall')) && entity.is_a?(Sketchup::Face) return SpeckleObjects::BuiltElements::RevitFloor
end .to_speckle_schema(speckle_state, entity, units, global_transformation: global_transformation)
end
def self.edge_mapping?(entity, method) if speckle_schema['method'] == 'Default Wall'
(method.include?('Column') || method.include?('Beam') || method.include?('Pipe') || method.include?('Duct')) && return SpeckleObjects::BuiltElements::DefaultWall
entity.is_a?(Sketchup::Edge) .to_speckle_schema(entity, units, global_transformation: global_transformation)
end
if speckle_schema['method'] == 'Wall'
return SpeckleObjects::BuiltElements::RevitWall
.to_speckle_schema(speckle_state, entity, units, global_transformation: global_transformation)
end
return speckle_schema
end end
end end
end end
@@ -12,9 +12,9 @@ module SpeckleConnector
include Immutable::ImmutableUtils include Immutable::ImmutableUtils
DICT_HANDLER = SketchupModel::Dictionary::SpeckleModelDictionaryHandler DICT_HANDLER = SketchupModel::Dictionary::SpeckleModelDictionaryHandler
# rubocop:disable Layout/LineLength # rubocop:disable Layout/LineLength
DEFAULT_CONFIG = "('configSketchup', '{\"dark_theme\":false, \"diffing\":false, \"register_speckle_entity\":false, \"fe2\":true}');" DEFAULT_CONFIG = "('configSketchup', '{\"dark_theme\":false, \"diffing\":false, \"register_speckle_entity\":false, \"fe2\":false}');"
# rubocop:enable Layout/LineLength # rubocop:enable Layout/LineLength
DEFAULT_PREFERENCES = '{"dark_theme":false, "diffing":false, "register_speckle_entity": false, "fe2": true}' DEFAULT_PREFERENCES = '{"dark_theme":false, "diffing":false, "register_speckle_entity": false, "fe2": false}'
# @param sketchup_model [Sketchup::Model] active model. # @param sketchup_model [Sketchup::Model] active model.
def self.read_preferences(sketchup_model) def self.read_preferences(sketchup_model)
@@ -1,39 +0,0 @@
# frozen_string_literal: true
require_relative '../base'
require_relative '../geometry/line'
require_relative '../../constants/type_constants'
require_relative '../../sketchup_model/dictionary/speckle_schema_dictionary_handler'
module SpeckleConnector
module SpeckleObjects
module BuiltElements
# Default Beam object.
class DefaultBeam < Base
SPECKLE_TYPE = OBJECTS_BUILTELEMENTS_DEFAULT_BEAM
def initialize(base_line:, units:, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: nil
)
self[:baseLine] = base_line
self[:units] = units
end
# @param edge [Sketchup::Edge] edge to get speckle schema for beam.
def self.to_speckle_schema(_speckle_state, edge, units, global_transformation: nil)
base_line = Geometry::Line.to_speckle_schema(edge: edge, units: units)
DefaultBeam.new(
base_line: base_line,
units: units,
application_id: edge.persistent_id
)
end
end
end
end
end
@@ -1,39 +0,0 @@
# frozen_string_literal: true
require_relative '../base'
require_relative '../geometry/line'
require_relative '../../constants/type_constants'
require_relative '../../sketchup_model/dictionary/speckle_schema_dictionary_handler'
module SpeckleConnector
module SpeckleObjects
module BuiltElements
# Default Column object.
class DefaultColumn < Base
SPECKLE_TYPE = OBJECTS_BUILTELEMENTS_DEFAULT_COLUMN
def initialize(base_line:, units:, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: nil
)
self[:baseLine] = base_line
self[:units] = units
end
# @param edge [Sketchup::Edge] edge to get speckle schema for column.
def self.to_speckle_schema(_speckle_state, edge, units, global_transformation: nil)
base_line = Geometry::Line.to_speckle_schema(edge: edge, units: units)
DefaultColumn.new(
base_line: base_line,
units: units,
application_id: edge.persistent_id
)
end
end
end
end
end
@@ -1,39 +0,0 @@
# frozen_string_literal: true
require_relative '../base'
require_relative '../geometry/line'
require_relative '../../constants/type_constants'
require_relative '../../sketchup_model/dictionary/speckle_schema_dictionary_handler'
module SpeckleConnector
module SpeckleObjects
module BuiltElements
# Default Duct object.
class DefaultDuct < Base
SPECKLE_TYPE = OBJECTS_BUILTELEMENTS_DEFAULT_DUCT
def initialize(base_line:, units:, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: nil
)
self[:baseLine] = base_line
self[:units] = units
end
# @param edge [Sketchup::Edge] edge to get speckle schema for duct.
def self.to_speckle_schema(_speckle_state, edge, units, global_transformation: nil)
base_line = Geometry::Line.to_speckle_schema(edge: edge, units: units)
DefaultDuct.new(
base_line: base_line,
units: units,
application_id: edge.persistent_id
)
end
end
end
end
end
@@ -29,7 +29,7 @@ module SpeckleConnector
end end
# @param face [Sketchup::Face] face to get speckle schema for floor. # @param face [Sketchup::Face] face to get speckle schema for floor.
def self.to_speckle_schema(_speckle_state, face, units, global_transformation: nil) def self.to_speckle_schema(face, units, global_transformation: nil)
outline = Geometry::Polyline.from_loop(face.loops.first, units, global_transformation: global_transformation) outline = Geometry::Polyline.from_loop(face.loops.first, units, global_transformation: global_transformation)
voids = [] voids = []
if face.loops.length > 1 if face.loops.length > 1
@@ -1,39 +0,0 @@
# frozen_string_literal: true
require_relative '../base'
require_relative '../geometry/line'
require_relative '../../constants/type_constants'
require_relative '../../sketchup_model/dictionary/speckle_schema_dictionary_handler'
module SpeckleConnector
module SpeckleObjects
module BuiltElements
# Default Pipe object.
class DefaultPipe < Base
SPECKLE_TYPE = OBJECTS_BUILTELEMENTS_DEFAULT_PIPE
def initialize(base_line:, units:, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: nil
)
self[:baseLine] = base_line
self[:units] = units
end
# @param edge [Sketchup::Edge] edge to get speckle schema for pipe.
def self.to_speckle_schema(_speckle_state, edge, units, global_transformation: nil)
base_line = Geometry::Line.to_speckle_schema(edge: edge, units: units)
DefaultPipe.new(
base_line: base_line,
units: units,
application_id: edge.persistent_id
)
end
end
end
end
end
@@ -32,7 +32,7 @@ module SpeckleConnector
end end
# @param face [Sketchup::Face] face to get speckle schema for floor. # @param face [Sketchup::Face] face to get speckle schema for floor.
def self.to_speckle_schema(_speckle_state, face, units, global_transformation: nil) def self.to_speckle_schema(face, units, global_transformation: nil)
base_line = Geometry::Line.base_line_from_face(face, units, global_transformation: global_transformation) base_line = Geometry::Line.base_line_from_face(face, units, global_transformation: global_transformation)
material = face.material || face.back_material material = face.material || face.back_material
@@ -103,14 +103,7 @@ module SpeckleConnector
entity.definition.entities, [Sketchup::Face], path.append(entity) entity.definition.entities, [Sketchup::Face], path.append(entity)
) )
end end
base_geometries = if entity.is_a?(Sketchup::Edge) base_geometries = group_faces_under_mesh_by_material(speckle_state, entities_with_path, units, model_preferences)
[Geometry::Line.from_edge(speckle_state: speckle_state, edge: entity, units: units,
model_preferences: model_preferences,
global_transformation: nil)]
else
group_faces_under_mesh_by_material(speckle_state, entities_with_path, units,
model_preferences)
end
DirectShape.new( DirectShape.new(
name: schema[:name], category: schema[:category], units: units, name: schema[:name], category: schema[:category], units: units,
base_geometries: base_geometries, application_id: entity.persistent_id base_geometries: base_geometries, application_id: entity.persistent_id
@@ -10,6 +10,9 @@ module SpeckleConnector
# Family instance for Revit mappings. # Family instance for Revit mappings.
class FamilyInstance < Base class FamilyInstance < Base
SPECKLE_TYPE = OBJECTS_BUILTELEMENTS_REVIT_FAMILY_INSTANCE SPECKLE_TYPE = OBJECTS_BUILTELEMENTS_REVIT_FAMILY_INSTANCE
READER = SketchupModel::Reader
QUERY = SketchupModel::Query
DICTIONARY = SketchupModel::Dictionary
# rubocop:disable Metrics/ParameterLists # rubocop:disable Metrics/ParameterLists
def initialize(family:, type:, level:, units:, base_point:, rotation:, application_id: nil) def initialize(family:, type:, level:, units:, base_point:, rotation:, application_id: nil)
@@ -1,63 +0,0 @@
# frozen_string_literal: true
require_relative '../../base'
require_relative '../../built_elements/revit/parameter'
require_relative '../../geometry/line'
require_relative '../../../constants/type_constants'
require_relative '../../../sketchup_model/dictionary/speckle_schema_dictionary_handler'
module SpeckleConnector
module SpeckleObjects
module BuiltElements
# Revit base object.
class RevitBeam < Base
SPECKLE_TYPE = OBJECTS_BUILTELEMENTS_REVIT_BEAM
# rubocop:disable Metrics/ParameterLists
def initialize(family:, type:, base_line:, level:, units:, parameters:, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: nil
)
self[:family] = family
self[:type] = type
self[:level] = level
self[:baseLine] = base_line
self[:units] = units
self[:parameters] = parameters
end
# rubocop:enable Metrics/ParameterLists
# @param edge [Sketchup::Edge] edge to get speckle schema for beam.
def self.to_speckle_schema(speckle_state, edge, units, global_transformation: nil)
base_line = Geometry::Line.to_speckle_schema(edge: edge, units: units)
schema = SketchupModel::Dictionary::SpeckleSchemaDictionaryHandler.speckle_schema_to_speckle(edge).to_h
source_exist = !speckle_state.speckle_mapper_state.mapper_source.nil?
level = nil
if source_exist
level = speckle_state.speckle_mapper_state.mapper_source.levels.find { |l| l[:name] == schema['level'] }
parameters = Base.new
offset_parameter = BuiltElements::Revit::Parameter.new(name: 'Height Offset From Level')
level_z = Geometry.length_to_native(level[:elevation], level[:units])
min_z = [edge.start.position, edge.end.position].map(&:z).min
offset_parameter['value'] = Geometry.length_to_speckle(min_z - level_z, units)
offset_parameter['units'] = units
parameters['Height Offset From Level'] = offset_parameter
end
RevitBeam.new(
family: schema['family'],
type: schema['family_type'],
base_line: base_line,
level: level,
units: units,
parameters: parameters,
application_id: edge.persistent_id
)
end
end
end
end
end
@@ -1,63 +0,0 @@
# frozen_string_literal: true
require_relative '../../base'
require_relative '../../built_elements/revit/parameter'
require_relative '../../geometry/line'
require_relative '../../../constants/type_constants'
require_relative '../../../sketchup_model/dictionary/speckle_schema_dictionary_handler'
module SpeckleConnector
module SpeckleObjects
module BuiltElements
# Revit column object.
class RevitColumn < Base
SPECKLE_TYPE = OBJECTS_BUILTELEMENTS_REVIT_COLUMN
# rubocop:disable Metrics/ParameterLists
def initialize(family:, type:, base_line:, level:, units:, parameters:, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: nil
)
self[:family] = family
self[:type] = type
self[:level] = level
self[:baseLine] = base_line
self[:units] = units
self[:parameters] = parameters
end
# rubocop:enable Metrics/ParameterLists
# @param edge [Sketchup::Edge] edge to get speckle schema for column.
def self.to_speckle_schema(speckle_state, edge, units, global_transformation: nil)
base_line = Geometry::Line.to_speckle_schema(edge: edge, units: units)
schema = SketchupModel::Dictionary::SpeckleSchemaDictionaryHandler.speckle_schema_to_speckle(edge).to_h
source_exist = !speckle_state.speckle_mapper_state.mapper_source.nil?
level = nil
if source_exist
level = speckle_state.speckle_mapper_state.mapper_source.levels.find { |l| l[:name] == schema['level'] }
parameters = Base.new
offset_parameter = BuiltElements::Revit::Parameter.new(name: 'Height Offset From Level')
level_z = Geometry.length_to_native(level[:elevation], level[:units])
min_z = [edge.start.position, edge.end.position].map(&:z).min
offset_parameter['value'] = Geometry.length_to_speckle(min_z - level_z, units)
offset_parameter['units'] = units
parameters['Height Offset From Level'] = offset_parameter
end
RevitColumn.new(
family: schema['family'],
type: schema['family_type'],
base_line: base_line,
level: level,
units: units,
parameters: parameters,
application_id: edge.persistent_id
)
end
end
end
end
end
@@ -1,67 +0,0 @@
# frozen_string_literal: true
require_relative '../../base'
require_relative '../../built_elements/revit/parameter'
require_relative '../../geometry/line'
require_relative '../../../constants/type_constants'
require_relative '../../../sketchup_model/dictionary/speckle_schema_dictionary_handler'
module SpeckleConnector
module SpeckleObjects
module BuiltElements
# Revit duct object.
class RevitDuct < Base
SPECKLE_TYPE = OBJECTS_BUILTELEMENTS_REVIT_DUCT
# rubocop:disable Metrics/ParameterLists
def initialize(family:, type:, height:, width:, base_line:, level:, units:, parameters:, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: nil
)
self[:family] = family
self[:type] = type
self[:height] = height
self[:width] = width
self[:level] = level
self[:baseLine] = base_line
self[:units] = units
self[:parameters] = parameters
end
# rubocop:enable Metrics/ParameterLists
# @param edge [Sketchup::Edge] edge to get speckle schema for duct.
def self.to_speckle_schema(speckle_state, edge, units, global_transformation: nil)
base_line = Geometry::Line.to_speckle_schema(edge: edge, units: units)
schema = SketchupModel::Dictionary::SpeckleSchemaDictionaryHandler.speckle_schema_to_speckle(edge).to_h
source_exist = !speckle_state.speckle_mapper_state.mapper_source.nil?
level = nil
if source_exist
level = speckle_state.speckle_mapper_state.mapper_source.levels.find { |l| l[:name] == schema['level'] }
parameters = Base.new
offset_parameter = BuiltElements::Revit::Parameter.new(name: 'Height Offset From Level')
level_z = Geometry.length_to_native(level[:elevation], level[:units])
min_z = [edge.start.position, edge.end.position].map(&:z).min
offset_parameter['value'] = Geometry.length_to_speckle(min_z - level_z, units)
offset_parameter['units'] = units
parameters['Height Offset From Level'] = offset_parameter
end
RevitDuct.new(
family: schema['family'],
type: schema['family_type'],
height: schema['height'],
width: schema['width'],
base_line: base_line,
level: level,
units: units,
parameters: parameters,
application_id: edge.persistent_id
)
end
end
end
end
end
@@ -1,65 +0,0 @@
# frozen_string_literal: true
require_relative '../../base'
require_relative '../../built_elements/revit/parameter'
require_relative '../../geometry/line'
require_relative '../../../constants/type_constants'
require_relative '../../../sketchup_model/dictionary/speckle_schema_dictionary_handler'
module SpeckleConnector
module SpeckleObjects
module BuiltElements
# Revit pipe object.
class RevitPipe < Base
SPECKLE_TYPE = OBJECTS_BUILTELEMENTS_REVIT_PIPE
# rubocop:disable Metrics/ParameterLists
def initialize(family:, type:, diameter:, base_line:, level:, units:, parameters:, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
application_id: application_id,
id: nil
)
self[:family] = family
self[:type] = type
self[:diameter] = diameter
self[:level] = level
self[:baseLine] = base_line
self[:units] = units
self[:parameters] = parameters
end
# rubocop:enable Metrics/ParameterLists
# @param edge [Sketchup::Edge] edge to get speckle schema for pipe.
def self.to_speckle_schema(speckle_state, edge, units, global_transformation: nil)
base_line = Geometry::Line.to_speckle_schema(edge: edge, units: units)
schema = SketchupModel::Dictionary::SpeckleSchemaDictionaryHandler.speckle_schema_to_speckle(edge).to_h
source_exist = !speckle_state.speckle_mapper_state.mapper_source.nil?
level = nil
if source_exist
level = speckle_state.speckle_mapper_state.mapper_source.levels.find { |l| l[:name] == schema['level'] }
parameters = Base.new
offset_parameter = BuiltElements::Revit::Parameter.new(name: 'Height Offset From Level')
level_z = Geometry.length_to_native(level[:elevation], level[:units])
min_z = [edge.start.position, edge.end.position].map(&:z).min
offset_parameter['value'] = Geometry.length_to_speckle(min_z - level_z, units)
offset_parameter['units'] = units
parameters['Height Offset From Level'] = offset_parameter
end
RevitPipe.new(
family: schema['family'],
type: schema['family_type'],
diameter: schema['diameter'],
base_line: base_line,
level: level,
units: units,
parameters: parameters,
application_id: edge.persistent_id
)
end
end
end
end
end
@@ -34,33 +34,17 @@ module SpeckleConnector
self[:domain] = domain self[:domain] = domain
self[:units] = units self[:units] = units
self[:layer] = layer unless layer.nil? self[:layer] = layer unless layer.nil?
self['@SpeckleSchema'] = speckle_schema if speckle_schema.any? self[:SpeckleSchema] = speckle_schema if speckle_schema.any?
self[:sketchup_attributes] = sketchup_attributes if sketchup_attributes.any? self[:sketchup_attributes] = sketchup_attributes if sketchup_attributes.any?
end end
# rubocop:enable Metrics/ParameterLists # rubocop:enable Metrics/ParameterLists
def self.to_speckle_schema(edge:, units:)
start_pt = Geometry::Point.from_vertex(edge.start.position, units)
end_pt = Geometry::Point.from_vertex(edge.end.position, units)
domain = Primitive::Interval.from_numeric(0, Float(edge.length), units)
Line.new(
start_pt: start_pt,
end_pt: end_pt,
domain: domain,
units: units,
layer: SketchupModel::Query::Layer.entity_path(edge),
sketchup_attributes: {},
speckle_schema: {},
application_id: edge.persistent_id.to_s
)
end
# @param edge [Sketchup::Edge] edge to convert line. # @param edge [Sketchup::Edge] edge to convert line.
def self.from_edge(speckle_state:, edge:, units:, model_preferences:, global_transformation: nil) def self.from_edge(edge, units, model_preferences, global_transformation: nil)
dictionaries = SketchupModel::Dictionary::BaseDictionaryHandler dictionaries = SketchupModel::Dictionary::BaseDictionaryHandler
.attribute_dictionaries_to_speckle(edge, model_preferences) .attribute_dictionaries_to_speckle(edge, model_preferences)
att = dictionaries.any? ? { dictionaries: dictionaries } : {} att = dictionaries.any? ? { dictionaries: dictionaries } : {}
speckle_schema = Mapper.to_speckle(speckle_state, edge, units, global_transformation: global_transformation) speckle_schema = SketchupModel::Dictionary::SpeckleSchemaDictionaryHandler.speckle_schema_to_speckle(edge)
start_pt = Geometry::Point.from_vertex(edge.start.position, units) start_pt = Geometry::Point.from_vertex(edge.start.position, units)
end_pt = Geometry::Point.from_vertex(edge.end.position, units) end_pt = Geometry::Point.from_vertex(edge.end.position, units)
domain = Primitive::Interval.from_numeric(0, Float(edge.length), units) domain = Primitive::Interval.from_numeric(0, Float(edge.length), units)
@@ -154,7 +154,7 @@ module SpeckleConnector
has_any_soften_edge = face.edges.any?(&:soft?) has_any_soften_edge = face.edges.any?(&:soft?)
att = dictionaries.any? ? { is_soften: has_any_soften_edge, dictionaries: dictionaries } att = dictionaries.any? ? { is_soften: has_any_soften_edge, dictionaries: dictionaries }
: { is_soften: has_any_soften_edge } : { is_soften: has_any_soften_edge }
speckle_schema = Mapper.to_speckle(speckle_state, face, units, global_transformation: global_transform) speckle_schema = Mapper.to_speckle(speckle_state, face, units, model_preferences, global_transformation: global_transform)
material = face.material || face.back_material || parent_material material = face.material || face.back_material || parent_material
speckle_mesh = Mesh.new( speckle_mesh = Mesh.new(
units: units, units: units,
@@ -84,7 +84,7 @@ module SpeckleConnector
speckle_state = new_speckle_state speckle_state = new_speckle_state
dictionaries = SketchupModel::Dictionary::BaseDictionaryHandler dictionaries = SketchupModel::Dictionary::BaseDictionaryHandler
.attribute_dictionaries_to_speckle(component_instance, preferences[:model]) .attribute_dictionaries_to_speckle(component_instance, preferences)
att = dictionaries.any? ? { dictionaries: dictionaries } : {} att = dictionaries.any? ? { dictionaries: dictionaries } : {}
speckle_schema = SketchupModel::Dictionary::SpeckleSchemaDictionaryHandler speckle_schema = SketchupModel::Dictionary::SpeckleSchemaDictionaryHandler
.speckle_schema_to_speckle(component_instance) .speckle_schema_to_speckle(component_instance)
@@ -19,7 +19,7 @@ module SpeckleConnector
id: nil id: nil
) )
self[:units] = units self[:units] = units
self[:matrix] = value self[:value] = value
end end
def self.from_transformation(transformation, units) def self.from_transformation(transformation, units)
@@ -81,9 +81,40 @@ module SpeckleConnector
def self.collect_mapped_entities(speckle_state, sketchup_model, units, preferences, &convert) def self.collect_mapped_entities(speckle_state, sketchup_model, units, preferences, &convert)
mapped_entities = Mapper.mapped_entities_on_selection(sketchup_model) mapped_entities = Mapper.mapped_entities_on_selection(sketchup_model)
mapped_entities.collect do |entity_with_path| mapped_entities.collect do |entity_with_path|
Mapper.convert_mapped_entity(speckle_state, entity_with_path, preferences, units, &convert) convert_mapped_entity(speckle_state, entity_with_path, preferences, units, &convert)
end end
end end
def self.convert_mapped_entity(speckle_state, entity_with_path, preferences, units, &convert)
entity = entity_with_path[0]
path = entity_with_path[1..-1]
method = SPECKLE_SCHEMA_DICTIONARY_HANDLER.get_attribute(entity, 'method')
if entity.is_a?(Sketchup::ComponentInstance) && method.nil?
method = SPECKLE_SCHEMA_DICTIONARY_HANDLER.get_attribute(entity.definition, 'method')
end
if !method.nil? && (method.include?('Floor') || method.include?('Wall')) && entity.is_a?(Sketchup::Face)
global_transformation = QUERY::Entity.global_transformation(entity, path)
floor = SpeckleObjects::Geometry::Mesh.from_face(speckle_state: speckle_state, face: entity,
units: units, model_preferences: preferences,
global_transform: global_transformation)
return [floor, [entity]]
end
if method == 'Direct Shape'
direct_shape = DIRECT_SHAPE.from_entity(speckle_state, entity, path, units, preferences)
return [direct_shape, [entity]]
end
if ['New Revit Family', 'Family Instance'].include?(method)
_speckle_state, block_instance = SpeckleObjects::Other::BlockInstance.from_component_instance(
entity, units, preferences, speckle_state, path: path, &convert
)
return [block_instance, [entity]]
end
nil
end
end end
end end
end end
+1 -2
View File
@@ -81,9 +81,8 @@ module SpeckleConnector
dialog.set_can_close do dialog.set_can_close do
true true
end end
# File.exist?(@htm_file) ? dialog.set_file(@htm_file) : dialog.set_url('http://localhost:8081') File.exist?(@htm_file) ? dialog.set_file(@htm_file) : dialog.set_url('http://localhost:8081')
# dialog.set_url('http://localhost:8081') # uncomment this line if you want to use your local version of ui # dialog.set_url('http://localhost:8081') # uncomment this line if you want to use your local version of ui
dialog.set_url('https://development--speckle-sketchup-dui2.netlify.app/')
add_exec_callback(dialog) add_exec_callback(dialog)
dialog dialog
end end
+1 -1
View File
@@ -5,7 +5,7 @@ module SpeckleConnector
# An interface to Sketchup user interface. This object controls the menu `Extensions->Speckle` in Sketchup's menu, # 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. # the Speckle toolbar and sending message to the user via Sketchup.
class SketchupUi class SketchupUi
MENU_TITLE = 'Speckle (Legacy)' MENU_TITLE = 'Speckle'
BEFORE_NEVER_SHOWN = -1 BEFORE_NEVER_SHOWN = -1
# @return [Sketchup::Menu] the menu of the Speckle # @return [Sketchup::Menu] the menu of the Speckle
+1 -1
View File
@@ -1,3 +1,3 @@
VUE_APP_DEV_TOKEN= VUE_APP_DEV_TOKEN=
VUE_APP_SPECKLE_NAME=SpeckleSketchup VUE_APP_SPECKLE_NAME=SpeckleSketchup
VUE_APP_DEFAULT_SERVER=https://latest.speckle.systems VUE_APP_DEFAULT_SERVER=https://latest.speckle.dev
+25 -23
View File
@@ -1,7 +1,6 @@
<template> <template>
<v-app> <v-app>
<v-main> <v-main>
<legacy-dialog/>
<v-app-bar app flat height="50"> <v-app-bar app flat height="50">
<v-img <v-img
class="mx-auto px-0" class="mx-auto px-0"
@@ -60,7 +59,7 @@
<b>{{ user.email }}</b> <b>{{ user.email }}</b>
</div> </div>
<div class="caption"> <div class="caption">
<b>{{ activeAccount().serverInfo.url }}</b> <b>{{ serverInfo.canonicalUrl }}</b>
</div> </div>
</v-card-text> </v-card-text>
<v-card-text v-if="accounts()"> <v-card-text v-if="accounts()">
@@ -105,12 +104,12 @@
/> />
</v-container> </v-container>
<create-stream-dialog <create-stream-dialog
v-if="accounts() && accounts().length !== 0" v-if="accounts().length !== 0"
:is-f-e2-terms="preferences && preferences.user && preferences.user.fe2" :is-f-e2-terms="preferences && preferences.user && preferences.user.fe2"
:account-id="activeAccount().userInfo.id" :account-id="activeAccount().userInfo.id"
:server-url="activeAccount().serverInfo.url" :server-url="activeAccount().serverInfo.url"
/> />
<v-container v-if="accounts() && accounts().length !== 0" fluid> <v-container v-if="accounts().length !== 0" fluid>
<router-view :stream-search-query="streamSearchQuery"/> <router-view :stream-search-query="streamSearchQuery"/>
</v-container> </v-container>
<v-container v-else> <v-container v-else>
@@ -136,7 +135,6 @@ import userQuery from './graphql/user.gql'
import serverInfoQuery from './graphql/serverInfo.gql' import serverInfoQuery from './graphql/serverInfo.gql'
import { onLogin } from './vue-apollo' import { onLogin } from './vue-apollo'
import Login from "@/views/Login"; import Login from "@/views/Login";
import LegacyDialog from './components/dialogs/LegacyDialog.vue';
global.collectPreferences = function (preferences) { global.collectPreferences = function (preferences) {
bus.$emit('update-preferences', preferences) bus.$emit('update-preferences', preferences)
@@ -151,16 +149,18 @@ global.collectVersions = function (versions) {
global.loadAccounts = function (accounts) { global.loadAccounts = function (accounts) {
console.log('>>> SpeckleSketchup: Loading accounts', accounts) console.log('>>> SpeckleSketchup: Loading accounts', accounts)
localStorage.setItem('localAccounts', JSON.stringify(accounts)) localStorage.setItem('localAccounts', JSON.stringify(accounts))
let selectedAccountId = localStorage.getItem('selectedAccountId') let uuid = localStorage.getItem('uuid')
if (accounts.length !== 0){ if (accounts.length !== 0){
if (selectedAccountId) { if (uuid) {
var account = accounts.find((acct) => acct['id'] === selectedAccountId) var account = accounts.find((acct) => acct['userInfo']['id'] === uuid)
if (account){ if (account){
global.setSelectedAccount(account) global.setSelectedAccount(account)
return }else{
global.setSelectedAccount(accounts.find((acct) => acct['isDefault']))
} }
} else {
global.setSelectedAccount(accounts.find((acct) => acct['isDefault']))
} }
global.setSelectedAccount(accounts.find((acct) => acct['isDefault']))
} }
} }
@@ -168,7 +168,7 @@ global.setSelectedAccount = function (account) {
localStorage.setItem('selectedAccount', JSON.stringify(account)) localStorage.setItem('selectedAccount', JSON.stringify(account))
localStorage.setItem('serverUrl', account['serverInfo']['url']) localStorage.setItem('serverUrl', account['serverInfo']['url'])
localStorage.setItem('SpeckleSketchup.AuthToken', account['token']) localStorage.setItem('SpeckleSketchup.AuthToken', account['token'])
localStorage.setItem('selectedAccountId', account['id']) localStorage.setItem('uuid', account['userInfo']['id'])
localStorage.setItem('frontend2', account['serverInfo']['frontend2']) localStorage.setItem('frontend2', account['serverInfo']['frontend2'])
bus.$emit('selected-account-reloaded') bus.$emit('selected-account-reloaded')
} }
@@ -180,8 +180,7 @@ export default {
CreateStreamDialog: () => import('@/components/dialogs/CreateStreamDialog'), CreateStreamDialog: () => import('@/components/dialogs/CreateStreamDialog'),
SettingsDialog: () => import('@/components/dialogs/SettingsDialog'), SettingsDialog: () => import('@/components/dialogs/SettingsDialog'),
GlobalToast: () => import('@/components/GlobalToast'), GlobalToast: () => import('@/components/GlobalToast'),
Mapper: () => import('@/components/Mapper'), Mapper: () => import('@/components/Mapper')
LegacyDialog: () => import('@/components/dialogs/LegacyDialog')
}, },
props: { props: {
size: { size: {
@@ -216,14 +215,6 @@ export default {
query: serverInfoQuery query: serverInfoQuery
} }
}, },
beforeMount() {
// Collect accounts from 'Accounts.db' by ruby sqlite3
sketchup.exec({name: "init_local_accounts", data: {}})
// Collect preferences to render UI according to it
sketchup.exec({name: "collect_preferences", data: {}})
// Collect versions to inform mixpanel
sketchup.exec({name: "collect_versions", data: {}})
},
mounted() { mounted() {
bus.$on('selected-account-reloaded', async () => { bus.$on('selected-account-reloaded', async () => {
await onLogin(this.$apollo.provider.defaultClient) await onLogin(this.$apollo.provider.defaultClient)
@@ -244,13 +235,22 @@ export default {
this.branchText = this.preferences.user.fe2 ? 'Model' : 'Branch' this.branchText = this.preferences.user.fe2 ? 'Model' : 'Branch'
this.$vuetify.theme.dark = this.preferences.user.dark_theme this.$vuetify.theme.dark = this.preferences.user.dark_theme
}) })
// Collect versions to inform mixpanel
sketchup.exec({name: "collect_versions", data: {}})
// Collect preferences to render UI according to it
sketchup.exec({name: "collect_preferences", data: {}})
// Collect accounts from 'Accounts.db' by ruby sqlite3
sketchup.exec({name: "init_local_accounts", data: {}})
}, },
methods: { methods: {
accounts() { accounts() {
return JSON.parse(localStorage.getItem('localAccounts')) return JSON.parse(localStorage.getItem('localAccounts'))
}, },
activeAccount() { activeAccount(){
return JSON.parse(localStorage.getItem('selectedAccount')) return this.accounts().find((account) => account['isDefault'])
}, },
switchAccount(account) { switchAccount(account) {
this.$mixpanel.track('Connector Action', { name: 'Account Select' }) this.$mixpanel.track('Connector Action', { name: 'Account Select' })
@@ -261,6 +261,8 @@ export default {
// // timeout to wait a bit for potential sketchup.exec in the mean time calls // // timeout to wait a bit for potential sketchup.exec in the mean time calls
// location.reload() // location.reload()
// }, 200); // }, 200);
this.$apollo.queries.user.refetch()
this.$apollo.queries.serverInfo.refetch()
}, },
requestRefresh() { requestRefresh() {
sketchup.exec({name: 'reload_accounts', data: {}}) sketchup.exec({name: 'reload_accounts', data: {}})
+1 -2
View File
@@ -145,8 +145,7 @@ export default {
prefetch: true, prefetch: true,
variables() { variables() {
return { return {
id: this.sourceStreamId, id: this.sourceStreamId
limit: 100
} }
}, },
skip() { skip() {
+91 -84
View File
@@ -1,10 +1,6 @@
<template> <template>
<v-card <v-card v-if="stream" :class="`mb-3 rounded-lg grey ${$vuetify.theme.dark ? 'darken-4' : 'lighten-4'}`"
v-if="stream" @mouseenter="hover = true" @mouseleave="hover = false">
:class="`mb-3 rounded-lg grey ${$vuetify.theme.dark ? 'darken-4' : 'lighten-4'}`"
@mouseenter="hover = true"
@mouseleave="hover = false"
>
<v-toolbar flat height="70" :color="getColor(invalid)"> <v-toolbar flat height="70" :color="getColor(invalid)">
<v-btn v-tooptip="''" icon small outlined class="delta-btn" v-if="invalid" @click="activateDiffing"> <v-btn v-tooptip="''" icon small outlined class="delta-btn" v-if="invalid" @click="activateDiffing">
<v-icon v-if="!diffing" class="toggleUpDown" :class='{ "rotate": diffing }' small>mdi-eye-off-outline</v-icon> <v-icon v-if="!diffing" class="toggleUpDown" :class='{ "rotate": diffing }' small>mdi-eye-off-outline</v-icon>
@@ -12,12 +8,8 @@
</v-btn> </v-btn>
<v-toolbar-title class="ml-0" style="position: relative; left: -10px"> <v-toolbar-title class="ml-0" style="position: relative; left: -10px">
<!-- Uncomment when pinning is in place and add style="position: relative; left: -10px" to the element above :) --> <!-- Uncomment when pinning is in place and add style="position: relative; left: -10px" to the element above :) -->
<v-btn <v-btn v-tooltip="`Pin this ${streamText.toLowerCase()} - it will be saved to this file.`" icon x-small
v-tooltip="`Pin this ${streamText.toLowerCase()} - it will be saved to this file.`" @click="toggleSavedStream">
icon
x-small
@click="toggleSavedStream"
>
<v-icon v-if="saved" x-small>mdi-pin</v-icon> <v-icon v-if="saved" x-small>mdi-pin</v-icon>
<v-icon v-else x-small>mdi-pin-outline</v-icon> <v-icon v-else x-small>mdi-pin-outline</v-icon>
</v-btn> </v-btn>
@@ -29,24 +21,12 @@
<v-btn v-tooltip="'View online'" icon small class="mr-3" @click="openInWeb"> <v-btn v-tooltip="'View online'" icon small class="mr-3" @click="openInWeb">
<v-icon small>mdi-open-in-new</v-icon> <v-icon small>mdi-open-in-new</v-icon>
</v-btn> </v-btn>
<v-btn <v-btn v-tooltip="'Send'" icon class="mr-3 elevation-2" :loading="loadingSend" @click="send">
v-tooltip="'Send'"
icon
class="mr-3 elevation-2"
:loading="loadingSend"
@click="send"
>
<!-- <v-icon>mdi-upload</v-icon> --> <!-- <v-icon>mdi-upload</v-icon> -->
<v-img v-if="$vuetify.theme.dark" src="@/assets/SenderWhite.png" max-width="30" /> <v-img v-if="$vuetify.theme.dark" src="@/assets/SenderWhite.png" max-width="30" />
<v-img v-else src="@/assets/Sender.png" max-width="30" /> <v-img v-else src="@/assets/Sender.png" max-width="30" />
</v-btn> </v-btn>
<v-btn <v-btn v-tooltip="'Receive'" icon class="elevation-2" :loading="loadingReceive" @click="receive">
v-tooltip="'Receive'"
icon
class="elevation-2"
:loading="loadingReceive"
@click="receive"
>
<!-- <v-icon>mdi-download</v-icon> --> <!-- <v-icon>mdi-download</v-icon> -->
<v-img v-if="$vuetify.theme.dark" src="@/assets/ReceiverWhite.png" max-width="30" /> <v-img v-if="$vuetify.theme.dark" src="@/assets/ReceiverWhite.png" max-width="30" />
<v-img v-else src="@/assets/Receiver.png" max-width="30" /> <v-img v-else src="@/assets/Receiver.png" max-width="30" />
@@ -66,11 +46,8 @@
<template #activator="{ on, attrs }"> <template #activator="{ on, attrs }">
<v-slide-x-transition> <v-slide-x-transition>
<div v-show="hover"> <div v-show="hover">
<create-branch-dialog <create-branch-dialog :is-f-e2="preferences && preferences.user && preferences.user.fe2"
:is-f-e2="preferences && preferences.user && preferences.user.fe2" :stream-name="stream.name" :stream-id="streamId" />
:stream-name="stream.name"
:stream-id="streamId"
/>
</div> </div>
</v-slide-x-transition> </v-slide-x-transition>
<v-chip v-if="stream.branches" small v-bind="attrs" class="mr-1" v-on="on"> <v-chip v-if="stream.branches" small v-bind="attrs" class="mr-1" v-on="on">
@@ -80,12 +57,8 @@
</template> </template>
<!-- Branch list --> <!-- Branch list -->
<v-list dense> <v-list dense>
<v-list-item <v-list-item v-for="(branch, index) in stream.branches.items" :key="index" link
v-for="(branch, index) in stream.branches.items" @click="switchBranch(branch.name)">
:key="index"
link
@click="switchBranch(branch.name)"
>
<v-list-item-title class="text-caption font-weight-regular"> <v-list-item-title class="text-caption font-weight-regular">
<v-icon v-if="branch.name === branchName" small class="mr-1 float-left"> <v-icon v-if="branch.name === branchName" small class="mr-1 float-left">
mdi-check mdi-check
@@ -100,22 +73,14 @@
<template #activator="{ on, attrs }"> <template #activator="{ on, attrs }">
<v-chip v-if="stream && stream.commits" small v-bind="attrs" v-on="on"> <v-chip v-if="stream && stream.commits" small v-bind="attrs" v-on="on">
<v-icon small class="mr-1 float-left">mdi-source-commit</v-icon> <v-icon small class="mr-1 float-left">mdi-source-commit</v-icon>
{{ selectedBranch.commits.items.length ? commitId : 'no commits' }} {{ selectedBranch.commits.items.length ? commitId : 'no commits' }}
</v-chip> </v-chip>
</template> </template>
<v-list v-if="selectedBranch && selectedBranch.commits" dense> <v-list v-if="selectedBranch && selectedBranch.commits" dense>
<v-list-item <v-list-item v-for="(commit, index) in selectedBranch.commits.items" :key="index" link
v-for="(commit, index) in selectedBranch.commits.items" @click="switchCommit(commit.id)">
:key="index"
link
@click="switchCommit(commit.id)"
>
<v-list-item-title class="text-caption font-weight-regular"> <v-list-item-title class="text-caption font-weight-regular">
<v-icon <v-icon v-if="(commitId == 'latest' && index == 0) || commit.id == commitId" small class="mr-1 float-left">
v-if="(commitId == 'latest' && index == 0) || commit.id == commitId"
small
class="mr-1 float-left"
>
mdi-check mdi-check
</v-icon> </v-icon>
<v-icon v-else small class="mr-1 float-left">mdi-source-commit</v-icon> <v-icon v-else small class="mr-1 float-left">mdi-source-commit</v-icon>
@@ -131,24 +96,14 @@
<div class="flex-grow-1 px-4"> <div class="flex-grow-1 px-4">
<v-slide-y-transition> <v-slide-y-transition>
<div v-show="hover"> <div v-show="hover">
<v-text-field <v-text-field v-model="commitMessage" xxxclass="small-text-field" hide-details dense flat
v-model="commitMessage" :placeholder="`Write your ${commitText.toLowerCase()} message here`" />
xxxclass="small-text-field"
hide-details
dense
flat
:placeholder="`Write your ${commitText.toLowerCase()} message here`"
/>
</div> </div>
</v-slide-y-transition> </v-slide-y-transition>
</div> </div>
</v-card-text> </v-card-text>
<v-progress-linear <v-progress-linear v-if="(loadingSend || loadingReceive) && loadingStage" key="progress-bar" height="14"
v-if="(loadingSend || loadingReceive) && loadingStage" indeterminate>
key="progress-bar"
height="14"
indeterminate
>
<div class="text-caption"> <div class="text-caption">
{{ loadingStage }} {{ loadingStage }}
</div> </div>
@@ -164,8 +119,9 @@
import gql from 'graphql-tag' import gql from 'graphql-tag'
import { bus } from '../main' import { bus } from '../main'
import streamQuery from '../graphql/stream.gql' import streamQuery from '../graphql/stream.gql'
import projectQuery from '../graphql/project.gql'
import ObjectLoader from '@speckle/objectloader' import ObjectLoader from '@speckle/objectloader'
import {HostApplications} from '@/utils/hostApplications' import { HostApplications } from '@/utils/hostApplications'
global.convertedFromSketchup = function (streamId, batches, commitId, totalChildrenCount) { global.convertedFromSketchup = function (streamId, batches, commitId, totalChildrenCount) {
bus.$emit(`sketchup-objects-${streamId}`, batches, commitId, totalChildrenCount) bus.$emit(`sketchup-objects-${streamId}`, batches, commitId, totalChildrenCount)
@@ -212,7 +168,8 @@ export default {
streamText: '', streamText: '',
branchText: '', branchText: '',
commitText: '', commitText: '',
preferences: {} preferences: {},
filterBranchIds: []
} }
}, },
apollo: { apollo: {
@@ -221,8 +178,19 @@ export default {
query: streamQuery, query: streamQuery,
variables() { variables() {
return { return {
id: this.streamId, id: this.streamId
limit: 100 }
}
},
project: {
prefetch: true,
query: projectQuery,
variables() {
return {
projectId: this.streamId,
filter: {
ids: this.filterBranchIds
}
} }
} }
}, },
@@ -303,7 +271,39 @@ export default {
this.commitText = pref.user.fe2 ? 'Version' : 'Commit' this.commitText = pref.user.fe2 ? 'Version' : 'Commit'
}) })
// Collect preferences to render UI according to it // Collect preferences to render UI according to it
sketchup.exec({name: "collect_preferences", data: {}}) sketchup.exec({ name: "collect_preferences", data: {} })
bus.$on(`set-stream-branch-commit-${this.streamId}`, async (branchId, commitId) => {
console.log(branchId, "branchId");
let res = await this.$apollo.query({
query: gql`
query Project($projectId: String!, $filter: ProjectModelsFilter) {
project(id: $projectId) {
id
name
models (filter: $filter) {
items {
id
name
versions {
items {
id
}
}
}
}
}
}
`,
variables: {
projectId: this.streamId,
filter: {
ids: [branchId]
}
}
})
console.log(res.data);
})
bus.$on(`deactivate-diffing-${this.streamId}`, () => { bus.$on(`deactivate-diffing-${this.streamId}`, () => {
this.diffing = false this.diffing = false
@@ -348,11 +348,11 @@ export default {
this.$mixpanel.track('Send', { method: 'OneClick' }) this.$mixpanel.track('Send', { method: 'OneClick' })
}) })
if (this.saved) sketchup.exec({name: "notify_connected", data: {stream_id: this.streamId}}) if (this.saved) sketchup.exec({ name: "notify_connected", data: { stream_id: this.streamId } })
}, },
methods: { methods: {
getColor(invalid){ getColor(invalid) {
if(invalid){ if (invalid) {
return "#ffdfdf" return "#ffdfdf"
} else { } else {
return "" return ""
@@ -376,22 +376,22 @@ export default {
this.$mixpanel.track('Connector Action', { name: 'Commit Switch' }) this.$mixpanel.track('Connector Action', { name: 'Commit Switch' })
this.commitId = commitId this.commitId = commitId
}, },
activateDiffing(){ activateDiffing() {
if (this.diffing){ if (this.diffing) {
this.diffing = false this.diffing = false
sketchup.exec({name: "deactivate_diffing", data: {}}) sketchup.exec({ name: "deactivate_diffing", data: {} })
return return
} }
this.diffing = true this.diffing = true
bus.$emit("deactivate-diffing-except", (this.streamId)) bus.$emit("deactivate-diffing-except", (this.streamId))
sketchup.exec({name: "activate_diffing", data: {stream_id: this.streamId}}) sketchup.exec({ name: "activate_diffing", data: { stream_id: this.streamId } })
}, },
toggleSavedStream() { toggleSavedStream() {
if (this.saved) { if (this.saved) {
sketchup.exec({name: "remove_stream", data: {stream_id: this.streamId}}) sketchup.exec({ name: "remove_stream", data: { stream_id: this.streamId } })
this.$mixpanel.track('Connector Action', { name: 'Stream Remove' }) this.$mixpanel.track('Connector Action', { name: 'Stream Remove' })
} else { } else {
sketchup.exec({name: "save_stream", data: {stream_id: this.streamId}}) sketchup.exec({ name: "save_stream", data: { stream_id: this.streamId } })
this.$mixpanel.track('Connector Action', { name: 'Stream Save' }) this.$mixpanel.track('Connector Action', { name: 'Stream Save' })
} }
}, },
@@ -402,7 +402,7 @@ export default {
const isMultiplayer = this.selectedCommit.authorId !== selectedAccount['userInfo']['id'] const isMultiplayer = this.selectedCommit.authorId !== selectedAccount['userInfo']['id']
const sourceApp = this.selectedCommit.sourceApplication const sourceApp = this.selectedCommit.sourceApplication
const sourceAppSlug = HostApplications.GetHostAppFromString(sourceApp).slug const sourceAppSlug = HostApplications.GetHostAppFromString(sourceApp).slug
this.$mixpanel.track('Receive', { isMultiplayer: isMultiplayer, sourceHostApp: sourceAppSlug, sourceHostAppVersion: sourceApp}) this.$mixpanel.track('Receive', { isMultiplayer: isMultiplayer, sourceHostApp: sourceAppSlug, sourceHostAppVersion: sourceApp })
const refId = this.selectedCommit?.referencedObject const refId = this.selectedCommit?.referencedObject
if (!refId) { if (!refId) {
this.loadingReceive = false this.loadingReceive = false
@@ -419,14 +419,16 @@ export default {
let rootObj = await loader.getAndConstructObject(this.updateLoadingStage) let rootObj = await loader.getAndConstructObject(this.updateLoadingStage)
sketchup.exec({name:"receive_objects" , data: { sketchup.exec({
name: "receive_objects", data: {
base: rootObj, base: rootObj,
stream_name: this.stream.name, stream_name: this.stream.name,
stream_id: this.streamId, stream_id: this.streamId,
branch_name: this.selectedCommit.branchName, branch_name: this.selectedCommit.branchName,
branch_id: this.selectedCommit.id, branch_id: this.selectedCommit.id,
source_app: this.selectedCommit.sourceApplication source_app: this.selectedCommit.sourceApplication
}}) }
})
await this.$apollo.mutate({ await this.$apollo.mutate({
mutation: gql` mutation: gql`
@@ -452,7 +454,7 @@ export default {
this.loadingStage = 'converting' this.loadingStage = 'converting'
this.loadingSend = true this.loadingSend = true
this.$mixpanel.track('Send') this.$mixpanel.track('Send')
sketchup.exec({name:"send_selection" , data: {stream_id: this.streamId}}) sketchup.exec({ name: "send_selection", data: { stream_id: this.streamId } })
console.log('>>> SpeckleSketchUp: Objects requested from SketchUp') console.log('>>> SpeckleSketchUp: Objects requested from SketchUp')
await this.sleep(2000) await this.sleep(2000)
}, },
@@ -482,7 +484,7 @@ export default {
} }
const t1 = Date.now() const t1 = Date.now()
const elapsedTime = (t1-t0) / 1000 const elapsedTime = (t1 - t0) / 1000
console.log(`Upload time: ${elapsedTime} second`) console.log(`Upload time: ${elapsedTime} second`)
let commit = { let commit = {
@@ -557,6 +559,7 @@ export default {
.fade-leave-active { .fade-leave-active {
transition: opacity 0.2s ease-in; transition: opacity 0.2s ease-in;
} }
.fade-enter, .fade-enter,
.fade-leave-to { .fade-leave-to {
opacity: 0; opacity: 0;
@@ -567,27 +570,31 @@ export default {
max-height: 1200px; max-height: 1200px;
overflow: hidden; overflow: hidden;
} }
.expand-leave-active { .expand-leave-active {
transition: all 0.3s ease; transition: all 0.3s ease;
max-height: 1200px; max-height: 1200px;
overflow: hidden; overflow: hidden;
} }
.expand-enter, .expand-enter,
.expand-leave-to { .expand-leave-to {
max-height: 0; max-height: 0;
opacity: 0; opacity: 0;
} }
.v-text-field >>> input { .v-text-field>>>input {
font-size: 0.9em; font-size: 0.9em;
} }
.v-text-field >>> label {
.v-text-field>>>label {
font-size: 0.9em; font-size: 0.9em;
} }
.btn-fix:focus::before { .btn-fix:focus::before {
opacity: 0 !important; opacity: 0 !important;
} }
.btn-fix:hover::before { .btn-fix:hover::before {
opacity: 0.08 !important; opacity: 0.08 !important;
} }
@@ -205,14 +205,7 @@ export default {
}, },
async getStream(){ async getStream(){
try { try {
const streamWrapper = new StreamWrapper(this.createStreamByIdText, this.accountId, this.serverUrl) const streamWrapper = new StreamWrapper(this.createStreamByIdText, this.accountId, this.serverUrl, localStorage.getItem('frontend2') === 'true')
const match = streamWrapper.matchUrl(this.createStreamByIdText)
if (match.groups.additionalModels !== undefined){
this.$eventHub.$emit('error', {
text: 'Multi-model URLs are not supported!\nTry to select just one single model in the web app and paste that in.',
})
return
}
let res = await this.$apollo.query({ let res = await this.$apollo.query({
query: gql` query: gql`
query Stream($id: String!){ query Stream($id: String!){
@@ -257,7 +250,9 @@ export default {
this.$eventHub.$emit('notification', { this.$eventHub.$emit('notification', {
text: 'Stream Added by URL!\n', text: 'Stream Added by URL!\n',
}) })
bus.$emit('stream-added-by-id-or-url', stream.id) console.log(streamWrapper);
console.log(streamWrapper.branchName.slice(0, -1), "stream-added-by-id-or-url");
await bus.$emit('stream-added-by-id-or-url', stream.id, streamWrapper.branchName.slice(0, -1), streamWrapper.commitId)
this.$mixpanel.track('Connector Action', { name: 'Stream Add From URL' }) this.$mixpanel.track('Connector Action', { name: 'Stream Add From URL' })
} }
catch (e){ catch (e){
@@ -1,56 +0,0 @@
<template>
<v-dialog v-model="dialog" max-width="400">
<v-card>
<v-card-title class="headline">Legacy Version</v-card-title>
<v-card-text>
Warning: This is a legacy connector.
<br /><br />
<a
href="https://app.speckle.systems/connectors"
target="_blank"
style="color: #1976D2; text-decoration: none; font-weight: 500;"
>
Download next-gen SketchUp connector
</a>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="grey" text @click="dialog = false">Dismiss</v-btn>
<v-btn color="primary" @click="downloadLatest">Download</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</template>
<script>
export default {
data() {
return {
dialog: true
}
},
methods: {
async downloadLatest() {
const response = await fetch(
`https://releases.speckle.dev/manager2/feeds/sketchup-v3.json`,
{
method: 'GET'
}
)
if (!response.ok) {
throw new Error('Failed to fetch versions')
}
const data = await response.json()
const sortedVersions = data.Versions.sort(function (a, b) {
return new Date(b.Date).getTime() - new Date(a.Date).getTime()
})
const latestAvailableVersion = sortedVersions[0]
latestAvailableVersion.value = sortedVersions[0]
window.open(latestAvailableVersion.value?.Url)
}
}
}
</script>
+17
View File
@@ -0,0 +1,17 @@
query Project($projectId: String!, $filter: ProjectModelsFilter) {
project(id: $projectId) {
id
name
models (filter: $filter) {
items {
id
name
versions {
items {
id
}
}
}
}
}
}
+2 -2
View File
@@ -1,4 +1,4 @@
query Stream($id: String!, $limit: Int!) { query Stream($id: String!) {
stream(id: $id) { stream(id: $id) {
id id
name name
@@ -27,7 +27,7 @@ query Stream($id: String!, $limit: Int!) {
referencedObject referencedObject
} }
} }
branches (limit: $limit) { branches {
totalCount totalCount
items { items {
id id
+55
View File
@@ -0,0 +1,55 @@
query Streams($cursor: String) {
streams(cursor: $cursor) {
totalCount
cursor
items {
id
name
description
role
isPublic
createdAt
updatedAt
collaborators {
id
name
company
avatar
role
}
commits(limit: 1) {
totalCount
items {
id
createdAt
message
authorId
branchName
authorName
authorAvatar
referencedObject
}
}
branches {
totalCount
items {
id
name
commits(limit: 10) {
totalCount
items {
id
createdAt
message
authorId
branchName
authorName
authorAvatar
referencedObject
}
}
}
}
}
}
}
+1 -1
View File
@@ -1,5 +1,5 @@
query { query {
user:activeUser { user {
id id
email email
name name
+3 -1
View File
@@ -1,11 +1,13 @@
query User($id: String!) { query User($id: String!) {
user:otherUser(id: $id) { user(id: $id) {
id id
email
name name
bio bio
company company
avatar avatar
verified verified
profiles
role role
} }
} }
+2 -12
View File
@@ -1,8 +1,8 @@
require('url') require('url')
export class StreamWrapper { export class StreamWrapper {
constructor(streamIdOrUrl, accountId, serverUrl) { constructor(streamIdOrUrl, accountId, serverUrl, isFE2) {
this.isFE2 = this.checkIsFE2(streamIdOrUrl) this.isFE2 = isFE2
this.streamsKey = this.isFE2 ? 'projects/': 'streams/' this.streamsKey = this.isFE2 ? 'projects/': 'streams/'
this.branchesKey = this.isFE2 ? 'models/': 'branches/' this.branchesKey = this.isFE2 ? 'models/': 'branches/'
this.commitsKey = this.isFE2 ? 'versions/': 'commits/' this.commitsKey = this.isFE2 ? 'versions/': 'commits/'
@@ -17,16 +17,6 @@ export class StreamWrapper {
} }
} }
matchUrl(streamUrl){
const fe2UrlRegex = /\/projects\/(?<projectId>[\w\d]+)(?:\/models\/(?<model>[\w\d]+(?:@[\w\d]+)?)(?:,(?<additionalModels>[\w\d]+(?:@[\w\d]+)?))*)?/
return fe2UrlRegex.exec(streamUrl);
}
checkIsFE2(streamUrl){
const match = this.matchUrl(streamUrl)
return match !== null;
}
streamWrapperFromUrl(streamUrl){ streamWrapperFromUrl(streamUrl){
this.url = new URL(streamUrl) this.url = new URL(streamUrl)
this.segments = this.url.pathname.split('/').map((segment) => segment + '/') this.segments = this.url.pathname.split('/').map((segment) => segment + '/')
+3 -1
View File
@@ -120,7 +120,7 @@ export default {
bus.$on('set-saved-streams', (streamIds) => { bus.$on('set-saved-streams', (streamIds) => {
this.savedStreams = streamIds this.savedStreams = streamIds
}) })
bus.$on('stream-added-by-id-or-url', (streamId) => { bus.$on('stream-added-by-id-or-url', async(streamId, branchId, commitId) => {
if (!this.savedStreams){ if (!this.savedStreams){
this.savedStreams = [] this.savedStreams = []
this.savedStreams.push(streamId) this.savedStreams.push(streamId)
@@ -128,9 +128,11 @@ export default {
} else { } else {
if (!this.savedStreams.includes(streamId)){ if (!this.savedStreams.includes(streamId)){
this.savedStreams.push(streamId) this.savedStreams.push(streamId)
sketchup.exec({name: "save_stream", data: {stream_id: streamId}}) sketchup.exec({name: "save_stream", data: {stream_id: streamId}})
} }
} }
await bus.$emit(`set-stream-branch-commit-${streamId}`, branchId, commitId)
}) })
sketchup.exec({name: "load_saved_streams", data: {}}) sketchup.exec({name: "load_saved_streams", data: {}})
console.log('LAUNCHED') console.log('LAUNCHED')
+3 -3
View File
@@ -12,7 +12,7 @@ if (process.env.NODE_ENV === 'development') {
localStorage.setItem(AUTH_TOKEN, process.env.VUE_APP_DEV_TOKEN) localStorage.setItem(AUTH_TOKEN, process.env.VUE_APP_DEV_TOKEN)
localStorage.setItem('serverUrl', process.env.VUE_APP_DEFAULT_SERVER) localStorage.setItem('serverUrl', process.env.VUE_APP_DEFAULT_SERVER)
} else if (!localStorage.getItem('serverUrl')) { } else if (!localStorage.getItem('serverUrl')) {
localStorage.setItem('serverUrl', 'https://app.speckle.systems') localStorage.setItem('serverUrl', 'https://speckle.xyz')
} }
const authLink = setContext((_, { headers }) => { const authLink = setContext((_, { headers }) => {
@@ -34,7 +34,7 @@ const defaultOptions = {
return ( return (
(localStorage.getItem('serverUrl').includes('http') (localStorage.getItem('serverUrl').includes('http')
? localStorage.getItem('serverUrl') ? localStorage.getItem('serverUrl')
: 'https://app.speckle.systems') + '/graphql' : 'https://speckle.xyz') + '/graphql'
) )
}, },
@@ -43,7 +43,7 @@ const defaultOptions = {
wsEndpoint: ( wsEndpoint: (
(localStorage.getItem('serverUrl').includes('http') (localStorage.getItem('serverUrl').includes('http')
? localStorage.getItem('serverUrl') ? localStorage.getItem('serverUrl')
: 'https://app.speckle.systems') + '/graphql' : 'https://speckle.xyz') + '/graphql'
).replace('http', 'ws'), ).replace('http', 'ws'),
// LocalStorage token // LocalStorage token