Compare commits
40 Commits
2.17.0-rc
...
development
| Author | SHA1 | Date | |
|---|---|---|---|
| e1308bfa21 | |||
| ed1d1f5b44 | |||
| aff871baaa | |||
| 0608e7048d | |||
| 0875e55c1d | |||
| 3508bcc42e | |||
| e59bfb2e12 | |||
| 3bb4039c78 | |||
| bd49e19c9e | |||
| 73bcd75b78 | |||
| a0578fa35d | |||
| 7de08d9f24 | |||
| d047f5e6d2 | |||
| 71071f817c | |||
| c7c864b8c0 | |||
| 67d4862f6b | |||
| 6a16327c30 | |||
| 060b1b8f41 | |||
| da2e228293 | |||
| ab7397bf55 | |||
| f79547f781 | |||
| 2152f1c90e | |||
| 503fb4d246 | |||
| 2befefa752 | |||
| 85e64c5076 | |||
| 60523dc994 | |||
| 6d780bf350 | |||
| eec02a1f84 | |||
| ace2fe6fe3 | |||
| 188794af8d | |||
| 92a941a944 | |||
| 0e1ddf2b11 | |||
| b57fa010d1 | |||
| f816452b78 | |||
| 120083bb31 | |||
| a5bb5c4686 | |||
| e5e2729f0a | |||
| ba8b902f48 | |||
| 2d67815ae6 | |||
| ec0c9066d2 |
+48
-35
@@ -26,21 +26,17 @@ jobs:
|
||||
build-connector: # Reusable job for basic connectors
|
||||
executor:
|
||||
name: win/default # comes with python 3.7.3
|
||||
shell: cmd.exe
|
||||
shell: powershell.exe
|
||||
parameters:
|
||||
slug:
|
||||
type: string
|
||||
default: ""
|
||||
environment:
|
||||
SSM: 'C:\Program Files\DigiCert\DigiCert One Signing Manager Tools'
|
||||
steps:
|
||||
- checkout
|
||||
- attach_workspace:
|
||||
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:
|
||||
name: Set Environment Variable
|
||||
shell: powershell.exe
|
||||
@@ -52,25 +48,36 @@ jobs:
|
||||
python patch_version.py $semver
|
||||
environment:
|
||||
WORKFLOW_NUM: << pipeline.number >>
|
||||
- run:
|
||||
name: Build Installer
|
||||
command: speckle-sharp-ci-tools\InnoSetup\ISCC.exe speckle-sharp-ci-tools\sketchup.iss /Sbyparam=$p
|
||||
shell: cmd.exe #does not work in powershell
|
||||
|
||||
#- run:
|
||||
# name: Patch
|
||||
# shell: powershell.exe
|
||||
# command:
|
||||
# | # If no tag, use 0.0.0.1 and don't make any YML (for testing only!)
|
||||
# $tag = if([string]::IsNullOrEmpty($env:CIRCLE_TAG)) { "0.0.0" } else { $env:CIRCLE_TAG }
|
||||
# $semver = if($tag.Contains('/')) {$tag.Split("/")[1] } else { $tag }
|
||||
# $ver = if($semver.Contains('-')) {$semver.Split("-")[0] } else { $semver }
|
||||
# $channel = if($semver.Contains('-')) {$semver.Split("-")[1] } else { "latest" }
|
||||
# $version = "$($ver).$($env:CIRCLE_BUILD_NUM)"
|
||||
# New-Item -Force "speckle-sharp-ci-tools/Installers/sketchup/$channel.yml" -ItemType File -Value "version: $semver"
|
||||
# echo $version
|
||||
# python patch_version.py $semver
|
||||
# speckle-sharp-ci-tools\InnoSetup\ISCC.exe speckle-sharp-ci-tools\sketchup.iss
|
||||
- unless: # Build installers unsigned on non-tagged builds
|
||||
condition: << pipeline.git.tag >>
|
||||
steps:
|
||||
- run:
|
||||
name: Build Installer
|
||||
command: speckle-sharp-ci-tools\InnoSetup\ISCC.exe speckle-sharp-ci-tools\sketchup.iss /Sbyparam=$p
|
||||
shell: cmd.exe # does not work in powershell
|
||||
- when: # Setup certificates and build installers signed for tagged builds
|
||||
condition: << pipeline.git.tag >>
|
||||
steps:
|
||||
- run:
|
||||
name: "Digicert Signing Manager Setup"
|
||||
command: |
|
||||
cd C:\
|
||||
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
|
||||
msiexec.exe /i smtools-windows-x64.msi /quiet /qn | Wait-Process
|
||||
- run:
|
||||
name: "Create Auth & OV Signing Cert"
|
||||
command: |
|
||||
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:
|
||||
root: ./
|
||||
paths:
|
||||
@@ -78,7 +85,7 @@ jobs:
|
||||
|
||||
build-connector-mac:
|
||||
macos:
|
||||
xcode: 12.5.1
|
||||
xcode: 13.4.1
|
||||
parameters:
|
||||
projname:
|
||||
type: string
|
||||
@@ -135,8 +142,8 @@ jobs:
|
||||
- run:
|
||||
name: Copy files to installer
|
||||
command: |
|
||||
mkdir -p speckle-sharp-ci-tools/Mac/<< parameters.installername >>/.installationFiles/
|
||||
cp << parameters.slug >>-mac.zip 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
|
||||
# Create installer
|
||||
- run:
|
||||
name: Exit if External PR
|
||||
@@ -168,7 +175,7 @@ jobs:
|
||||
root: ./
|
||||
paths:
|
||||
- speckle-sharp-ci-tools/Installers
|
||||
|
||||
|
||||
get-ci-tools: # Clones our ci tools and persists them to the workspace
|
||||
docker:
|
||||
- image: cimg/base:2021.01
|
||||
@@ -184,10 +191,16 @@ jobs:
|
||||
- run:
|
||||
name: Clone
|
||||
command: git clone git@github.com:specklesystems/speckle-sharp-ci-tools.git speckle-sharp-ci-tools
|
||||
- persist_to_workspace:
|
||||
root: ./
|
||||
paths:
|
||||
- speckle-sharp-ci-tools
|
||||
- run:
|
||||
name: Checkout branch
|
||||
command: |
|
||||
cd 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:
|
||||
root: ./
|
||||
paths:
|
||||
@@ -238,7 +251,7 @@ workflows:
|
||||
filters:
|
||||
tags:
|
||||
only: /.*/
|
||||
context: innosetup
|
||||
context: digicert-keylocker
|
||||
|
||||
- build-connector-mac:
|
||||
slug: sketchup
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
[submodule "_sqlite3"]
|
||||
path = _sqlite3
|
||||
url = git@github.com:specklesystems/sketchup-sqlite3.git
|
||||
url = https://github.com/specklesystems/sketchup-sqlite3.git
|
||||
|
||||
@@ -2,44 +2,14 @@
|
||||
<img src="https://user-images.githubusercontent.com/2679513/131189167-18ea5fe1-c578-47f6-9785-3748178e4312.png" width="150px"/><br/>
|
||||
Speckle | SketchUp
|
||||
</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&style=flat-square&logo=discourse&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&logo=read-the-docs&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">
|
||||
Connector for SketchUp
|
||||
</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&style=flat-square&logo=discourse&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&logo=read-the-docs&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&circle-token=76eabd350ea243575cbb258b746ed3f471f7ac29" alt="Speckle-Next"></a> </p>
|
||||
|
||||
# About Speckle
|
||||
|
||||
What is Speckle? Check our 
|
||||
|
||||
### 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:
|
||||
|
||||
- [](https://speckle.xyz) ⇒ creating an account at our public server
|
||||
- [](https://marketplace.digitalocean.com/apps/speckle-server?refcode=947a2b5d7dc1) ⇒ deploying an instance in 1 click
|
||||
|
||||
### Resources
|
||||
|
||||
- [](https://speckle.community) for help, feature requests or just to hang with other speckle enthusiasts, check out our community forum!
|
||||
- [](https://speckle.systems) our tutorials portal is full of resources to get you started using Speckle
|
||||
- [](https://speckle.guide/user/blender.html) reference on almost any end-user and developer functionality
|
||||
|
||||
|
||||
# Repo structure
|
||||
|
||||
@@ -66,6 +36,15 @@ This repo is split into three parts:
|
||||
After building `sqlite3.sln` file, compiled `sqlite3.so` (for Windows) and `sqlite3.bundle` (for OSX) dynamic library files are created
|
||||
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`).
|
||||
|
||||
### 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
|
||||
|
||||
@@ -194,4 +173,4 @@ To track your code quality locally,
|
||||
2. To check overall state of repository by RubyCritic, run below
|
||||
```ruby
|
||||
rake rubycritic
|
||||
```
|
||||
```
|
||||
|
||||
@@ -24,7 +24,7 @@ module SpeckleConnector
|
||||
|
||||
# Run from localhost or from build files
|
||||
DEV_MODE = false
|
||||
puts("Loading Speckle Connector v#{CONNECTOR_VERSION} from #{DEV_MODE ? 'dev' : 'build'}")
|
||||
puts("Loading Speckle (Legacy) Connector v#{CONNECTOR_VERSION} from #{DEV_MODE ? 'dev' : 'build'}")
|
||||
|
||||
unless file_loaded?(__FILE__)
|
||||
ex = SketchupExtension.new('Speckle SketchUp', File.join(PATH, 'bootstrap'))
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 26 KiB |
@@ -0,0 +1,22 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative 'action'
|
||||
require_relative '../mapper/category/revit_category'
|
||||
require_relative '../mapper/category/revit_family_category'
|
||||
|
||||
module SpeckleConnector
|
||||
module Actions
|
||||
# Collects mapper selection info.
|
||||
class MapperInitialized < 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, _data)
|
||||
init_parameters = {
|
||||
categories: Mapper::Category::RevitCategory.to_a,
|
||||
familyCategories: Mapper::Category::RevitFamilyCategory.to_a
|
||||
}.freeze
|
||||
state.with_mapper_init_queue(init_parameters)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
require_relative 'action'
|
||||
require_relative '../mapper/category/revit_category'
|
||||
require_relative '../mapper/category/revit_family_category'
|
||||
require_relative '../sketchup_model/reader/mapper_reader'
|
||||
require_relative '../sketchup_model/reader/speckle_entities_reader'
|
||||
require_relative '../sketchup_model/dictionary/speckle_entity_dictionary_handler'
|
||||
@@ -35,6 +36,7 @@ module SpeckleConnector
|
||||
end
|
||||
|
||||
def get_mapping_info(state, selection)
|
||||
source_exist = !state.speckle_state.speckle_mapper_state.mapper_source.nil?
|
||||
selection = filter_out_levels(selection)
|
||||
grouped_by_type = group_by_type(selection)
|
||||
|
||||
@@ -45,10 +47,23 @@ module SpeckleConnector
|
||||
|
||||
# Return Direct Shape itself if multiple kinds of element are selected like Edge and Face.
|
||||
# OR single type is equal to only direct shape supports.
|
||||
return multiple_supported_selection_info(selection) if supported_entity_count > 1
|
||||
|
||||
# FIXME: Distinguish selection info according to selection elegantly!!!
|
||||
if grouped_by_type.keys.first == Sketchup::ComponentInstance
|
||||
return component_selection_info(selection, source_exist)
|
||||
end
|
||||
|
||||
return group_selection_info(selection) if grouped_by_type.keys.first == Sketchup::Group
|
||||
|
||||
if supported_entity_count > 1 ||
|
||||
(supported_entity_count == 1 &&
|
||||
MAPPER_DIRECT_SHAPE_SUPPORTED_ENTITY_TYPES.include?(grouped_by_type.keys.first))
|
||||
return direct_shape_selection_info(selection)
|
||||
if source_exist
|
||||
return direct_shape_selection_info_with_source(selection, [])
|
||||
else
|
||||
return direct_shape_selection_info(selection, source_exist)
|
||||
end
|
||||
end
|
||||
|
||||
# Only single type selections remained after this point.
|
||||
@@ -73,29 +88,54 @@ module SpeckleConnector
|
||||
|
||||
EMPTY_SELECTION = {
|
||||
selection: [],
|
||||
mappingMethods: [],
|
||||
categories: []
|
||||
mappingMethods: []
|
||||
}.freeze
|
||||
|
||||
def direct_shape_selection_info(selection)
|
||||
def multiple_supported_selection_info(selection)
|
||||
{
|
||||
selection: SketchupModel::Reader::MapperReader.entities_schema_details(selection),
|
||||
mappingMethods: ['Direct Shape'],
|
||||
categories: Mapper::Category::RevitCategory.to_a
|
||||
mappingMethods: ['Direct Shape']
|
||||
}.freeze
|
||||
end
|
||||
|
||||
def component_selection_info(selection, source_exist)
|
||||
if source_exist
|
||||
{
|
||||
selection: SketchupModel::Reader::MapperReader.entities_schema_details(selection),
|
||||
mappingMethods: ['Direct Shape', 'New Revit Family', 'Family Instance']
|
||||
}.freeze
|
||||
else
|
||||
{
|
||||
selection: SketchupModel::Reader::MapperReader.entities_schema_details(selection),
|
||||
mappingMethods: ['Direct Shape', 'New Revit Family']
|
||||
}.freeze
|
||||
end
|
||||
end
|
||||
|
||||
def group_selection_info(selection)
|
||||
{
|
||||
selection: SketchupModel::Reader::MapperReader.entities_schema_details(selection),
|
||||
mappingMethods: ['Direct Shape']
|
||||
}.freeze
|
||||
end
|
||||
|
||||
def direct_shape_selection_info(selection, source_exist)
|
||||
methods = ['Direct Shape', 'New Revit Family']
|
||||
methods.append('Family Instance') if source_exist
|
||||
{
|
||||
selection: SketchupModel::Reader::MapperReader.entities_schema_details(selection),
|
||||
mappingMethods: methods
|
||||
}.freeze
|
||||
end
|
||||
|
||||
def direct_shape_selection_info_with_default(selection, methods)
|
||||
{
|
||||
selection: SketchupModel::Reader::MapperReader.entities_schema_details(selection),
|
||||
mappingMethods: ['Direct Shape'] + methods,
|
||||
categories: Mapper::Category::RevitCategory.to_a
|
||||
mappingMethods: ['Direct Shape'] + methods
|
||||
}.freeze
|
||||
end
|
||||
|
||||
def direct_shape_selection_info_with_source(state, filtered_selection, methods)
|
||||
types = state.speckle_state.speckle_mapper_state.mapper_source.types
|
||||
levels = state.speckle_state.speckle_mapper_state.mapper_source.levels
|
||||
def direct_shape_selection_info_with_source(filtered_selection, methods)
|
||||
instances = @selection.grep(Sketchup::ComponentInstance)
|
||||
selected_level = instances.find do |i|
|
||||
DICTIONARY::SpeckleEntityDictionaryHandler
|
||||
@@ -109,8 +149,6 @@ module SpeckleConnector
|
||||
selection: READER::MapperReader.entities_schema_details(filtered_selection),
|
||||
mappingMethods: ['Direct Shape'] + methods,
|
||||
categories: Mapper::Category::RevitCategory.to_a,
|
||||
types: types,
|
||||
levels: levels,
|
||||
selectedLevelName: selected_level_name
|
||||
}.freeze
|
||||
end
|
||||
@@ -119,13 +157,13 @@ module SpeckleConnector
|
||||
def face_selection_info(state, faces)
|
||||
source_exist = !state.speckle_state.speckle_mapper_state.mapper_source.nil?
|
||||
grouped_by_verticality = faces.group_by { |face| face.normal.perpendicular?(VECTOR_Z) }
|
||||
return direct_shape_selection_info(faces) if grouped_by_verticality.length == 2
|
||||
return direct_shape_selection_info(faces, source_exist) if grouped_by_verticality.length == 2
|
||||
|
||||
if source_exist
|
||||
if grouped_by_verticality.keys.first
|
||||
direct_shape_selection_info_with_source(state, faces, ['Wall'])
|
||||
direct_shape_selection_info_with_source(faces, ['Wall'])
|
||||
else
|
||||
direct_shape_selection_info_with_source(state, faces, ['Floor'])
|
||||
direct_shape_selection_info_with_source(faces, ['Floor'])
|
||||
end
|
||||
else
|
||||
if grouped_by_verticality.keys.first
|
||||
@@ -141,7 +179,7 @@ module SpeckleConnector
|
||||
|
||||
if source_exist
|
||||
methods = ['Column', 'Beam', 'Pipe', 'Duct']
|
||||
direct_shape_selection_info_with_source(state, edges, methods)
|
||||
direct_shape_selection_info_with_source(edges, methods)
|
||||
else
|
||||
default_methods = ['Default Column', 'Default Beam', 'Default Pipe', 'Default Duct']
|
||||
direct_shape_selection_info_with_default(edges, default_methods)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative 'action'
|
||||
require_relative '../constants/type_constants'
|
||||
require_relative '../mapper/mapper_source'
|
||||
require_relative '../speckle_objects/built_elements/revit/revit_element_type'
|
||||
|
||||
@@ -20,13 +21,15 @@ module SpeckleConnector
|
||||
def update_state(state)
|
||||
levels = convert_levels(state, @base['@Levels'])
|
||||
types = convert_types(@base['@Types'])
|
||||
family_instances = convert_family_instance_types(@base['@Types'])
|
||||
mapper_source = Mapper::MapperSource.new(@stream_id, @commit_id, levels, types)
|
||||
new_speckle_state = state.speckle_state.with_mapper_source(mapper_source)
|
||||
state = state.with_speckle_state(new_speckle_state)
|
||||
|
||||
state.with_add_queue('mapperSourceUpdated', @stream_id, [
|
||||
{ is_string: false, val: levels.to_json },
|
||||
{ is_string: false, val: types.to_json }
|
||||
{ is_string: false, val: types.to_json },
|
||||
{ is_string: false, val: family_instances.to_json }
|
||||
])
|
||||
end
|
||||
|
||||
@@ -43,6 +46,27 @@ module SpeckleConnector
|
||||
end.compact.to_h
|
||||
end
|
||||
|
||||
def convert_family_instance_types(types)
|
||||
family_instance_types = {}
|
||||
types.each do |type, type_elements|
|
||||
next if type_elements.nil? || !type_elements.is_a?(Array) || type == '__closure'
|
||||
|
||||
# skip type if there is no any revit symbol element type
|
||||
symbol_element_types = type_elements.select do |t|
|
||||
t['speckle_type'] == OBJECTS_BUILTELEMENTS_REVIT_REVITSYMBOLELEMENTTYPE &&
|
||||
t['placementType'] == 'OneLevelBased'
|
||||
end
|
||||
next if symbol_element_types.empty?
|
||||
|
||||
elements = type_elements.map do |type_element|
|
||||
SpeckleObjects::BuiltElements::Revit::RevitElementType.to_native(type_element)
|
||||
end
|
||||
elements = elements.group_by { |e| e[:family] }
|
||||
family_instance_types.merge!(elements)
|
||||
end
|
||||
family_instance_types
|
||||
end
|
||||
|
||||
def convert_levels(state, levels)
|
||||
levels.collect do |level|
|
||||
SpeckleObjects::BuiltElements::Level.to_native(state, level, @stream_id)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
require_relative 'action'
|
||||
require_relative '../convertors/units'
|
||||
require_relative '../convertors/to_native'
|
||||
require_relative '../convertors/clean_up'
|
||||
|
||||
module SpeckleConnector
|
||||
module Actions
|
||||
@@ -26,7 +27,12 @@ module SpeckleConnector
|
||||
converter = Converters::ToNative.new(state, @stream_id, @stream_name, @branch_name, @source_app)
|
||||
# Have side effects on the sketchup model. It effects directly on the entities by adding new objects.
|
||||
start_time = Time.now.to_f
|
||||
state.sketchup_state.sketchup_model.start_operation('Receive Speckle Objects', true)
|
||||
state = converter.receive_commit_object(@base)
|
||||
if state.user_state.model_preferences[:merge_coplanar_faces]
|
||||
Converters::CleanUp.merge_coplanar_faces(converter.converted_faces)
|
||||
end
|
||||
state.sketchup_state.sketchup_model.commit_operation
|
||||
elapsed_time = (Time.now.to_f - start_time).round(3)
|
||||
puts "==== Converting to Native executed in #{elapsed_time} sec ===="
|
||||
puts "==== Source application is #{@source_app}. ===="
|
||||
|
||||
@@ -12,7 +12,7 @@ module SpeckleConnector
|
||||
# This is the command where we show UI to user.
|
||||
class InitializeSpeckle < Command
|
||||
def dialog_title
|
||||
"Speckle #{CONNECTOR_VERSION}"
|
||||
"Speckle (Legacy) #{CONNECTOR_VERSION}"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative 'command'
|
||||
require_relative '../states/initial_state'
|
||||
require_relative '../ui/vue_view'
|
||||
require_relative '../actions/initialize_speckle'
|
||||
require_relative '../observers/factory'
|
||||
|
||||
module SpeckleConnector
|
||||
module Commands
|
||||
# Command to reset Speckle UI window location onto center of SketchUp window.
|
||||
class ResetWindowLocation < Command
|
||||
|
||||
private
|
||||
|
||||
def _run
|
||||
app = self.app
|
||||
vue_view = app.ui_controller.user_interfaces[Ui::SPECKLE_UI_ID]
|
||||
if vue_view
|
||||
vue_view.dialog.reset_dialog_location
|
||||
else
|
||||
puts "Speckle UI didn't initialized!"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -3,6 +3,7 @@
|
||||
require_relative 'menu_command_handler'
|
||||
require_relative 'action_command'
|
||||
require_relative 'initialize_speckle'
|
||||
require_relative 'reset_window_location'
|
||||
require_relative '../actions/one_click_send'
|
||||
|
||||
module SpeckleConnector
|
||||
@@ -10,6 +11,7 @@ module SpeckleConnector
|
||||
# Speckle menu commands that adds them to Sketchup menu and toolbar.
|
||||
class SpeckleMenuCommands
|
||||
CMD_INITIALIZE_SPECKLE = :initialize_speckle
|
||||
CMD_RESET_WINDOW_LOCATION_SPECKLE = :reset_window_location_speckle
|
||||
CMD_SEND_TO_SPECKLE = :send_to_speckle
|
||||
CMD_RECEIVE_FROM_SPECKLE = :receive_from_speckle
|
||||
|
||||
@@ -26,31 +28,29 @@ module SpeckleConnector
|
||||
commands.add_to_menu!(CMD_INITIALIZE_SPECKLE, speckle_menu)
|
||||
commands.add_to_toolbar!(CMD_INITIALIZE_SPECKLE, speckle_toolbar)
|
||||
|
||||
# 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)
|
||||
commands[CMD_RESET_WINDOW_LOCATION_SPECKLE] = reset_window_location_command(app)
|
||||
commands.add_to_menu!(CMD_RESET_WINDOW_LOCATION_SPECKLE, speckle_menu)
|
||||
end
|
||||
|
||||
def self.initialize_speckle_command(app)
|
||||
cmd = MenuCommandHandler.sketchup_command(
|
||||
InitializeSpeckle.new(app), 'Initialize Speckle'
|
||||
InitializeSpeckle.new(app), 'Initialize Speckle (Legacy)'
|
||||
)
|
||||
cmd.tooltip = 'Launch Connector'
|
||||
cmd.status_bar_text = 'Opens the Speckle Connector window'
|
||||
cmd.status_bar_text = 'Opens the Speckle (Legacy) Connector window'
|
||||
cmd.small_icon = '../../img/s2logo.png'
|
||||
cmd.large_icon = '../../img/s2logo.png'
|
||||
cmd
|
||||
end
|
||||
|
||||
def self.send_command(app)
|
||||
def self.reset_window_location_command(app)
|
||||
cmd = MenuCommandHandler.sketchup_command(
|
||||
ActionCommand.new(app, Actions::OneClickSend), 'Send to Speckle'
|
||||
ResetWindowLocation.new(app), 'Reset Window Location'
|
||||
)
|
||||
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.tooltip = 'Bring Speckle window onto center of SketchUp window'
|
||||
cmd.status_bar_text = 'Bring Speckle window onto center of SketchUp window'
|
||||
cmd.small_icon = '../../img/s2logo.png'
|
||||
cmd.large_icon = '../../img/s2logo.png'
|
||||
cmd
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,7 +14,9 @@ module SpeckleConnector
|
||||
path = ENV.fetch('APPDATA')
|
||||
Pathname.new(File.join(path, 'Speckle')).cleanpath.to_s
|
||||
when OS_MAC
|
||||
File.join(Dir.home, '.config/Speckle')
|
||||
primary_path = 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
|
||||
raise 'Speckle could not determine your Appdata path'
|
||||
end
|
||||
|
||||
@@ -15,7 +15,7 @@ module SpeckleConnector
|
||||
Sketchup::ComponentInstance => INCLUDE_COMPONENT_ENTITY_ATTRIBUTES,
|
||||
Sketchup::Group => INCLUDE_GROUP_ENTITY_ATTRIBUTES,
|
||||
Sketchup::Face => INCLUDE_FACE_ENTITY_ATTRIBUTES,
|
||||
Sketchup::Face => INCLUDE_EDGE_ENTITY_ATTRIBUTES
|
||||
Sketchup::Edge => INCLUDE_EDGE_ENTITY_ATTRIBUTES
|
||||
}.freeze
|
||||
|
||||
LEVEL_SHIFT_VALUE = SpeckleObjects::Geometry.length_to_native(1.5, 'm')
|
||||
|
||||
@@ -4,6 +4,7 @@ module SpeckleConnector
|
||||
BASE_OBJECT = 'Base'
|
||||
|
||||
OBJECTS_GIS_POLYGONELEMENT = 'Objects.GIS.PolygonElement'
|
||||
OBJECTS_GIS_LINEELEMENT = 'Objects.GIS.LineElement'
|
||||
|
||||
OBJECTS_BUILTELEMENTS_VIEW3D = 'Objects.BuiltElements.View:Objects.BuiltElements.View3D'
|
||||
OBJECTS_BUILTELEMENTS_NETWORK = 'Objects.BuiltElements.Network'
|
||||
@@ -12,9 +13,19 @@ module SpeckleConnector
|
||||
OBJECTS_BUILTELEMENTS_REVIT_FLOOR = 'Objects.BuiltElements.Floor:Objects.BuiltElements.Revit.RevitFloor'
|
||||
OBJECTS_BUILTELEMENTS_DEFAULT_WALL = 'Objects.BuiltElements.Wall'
|
||||
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_FAMILY_INSTANCE = 'Objects.BuiltElements.Revit.FamilyInstance'
|
||||
OBJECTS_BUILTELEMENTS_REVIT_PARAMETER = 'Objects.BuiltElements.Revit.Parameter'
|
||||
OBJECTS_BUILTELEMENTS_REVIT_REVITELEMENTTYPE = 'Objects.BuiltElements.Revit.RevitElementType'
|
||||
OBJECTS_BUILTELEMENTS_REVIT_REVITSYMBOLELEMENTTYPE = 'Objects.BuiltElements.Revit.RevitElementType:Objects.BuiltElements.Revit.RevitSymbolElementType'
|
||||
|
||||
OBJECTS_GEOMETRY_LINE = 'Objects.Geometry.Line'
|
||||
OBJECTS_GEOMETRY_POLYLINE = 'Objects.Geometry.Polyline'
|
||||
@@ -33,4 +44,6 @@ module SpeckleConnector
|
||||
OBJECTS_OTHER_DISPLAYSTYLE = 'Objects.Other.DisplayStyle'
|
||||
|
||||
SPECKLE_CORE_MODELS_COLLECTION = 'Speckle.Core.Models.Collection'
|
||||
SPECKLE_CORE_MODELS_COLLECTION_RASTER_LAYER = 'Speckle.Core.Models.Collection:Objects.GIS.RasterLayer'
|
||||
SPECKLE_CORE_MODELS_COLLECTION_VECTOR_LAYER = 'Speckle.Core.Models.Collection:Objects.GIS.VectorLayer'
|
||||
end
|
||||
|
||||
@@ -11,9 +11,10 @@ module SpeckleConnector
|
||||
# @param entities [Sketchup::Entities] entities to remove edges between that make entities coplanar.
|
||||
# @note Merging coplanar faces idea originated from [CleanUp](https://github.com/thomthom/cleanup) plugin
|
||||
# which is developed by [Thomas Thomassen](https://github.com/thomthom).
|
||||
def self.merge_coplanar_faces(entities)
|
||||
def self.merge_coplanar_entities(entities)
|
||||
edges = []
|
||||
faces = entities.collect { |entity| entity if entity.is_a? Sketchup::Face }.compact
|
||||
faces = merged_faces(faces)
|
||||
faces.each { |face| face.edges.each { |edge| edges << edge } }
|
||||
edges.uniq!
|
||||
edges.each { |edge| remove_edge_have_coplanar_faces(edge, faces, false) }
|
||||
@@ -22,6 +23,22 @@ module SpeckleConnector
|
||||
merged_faces(faces)
|
||||
end
|
||||
|
||||
def self.merge_coplanar_faces(faces)
|
||||
edges = []
|
||||
faces = faces.reject(&:deleted?)
|
||||
|
||||
faces.each { |face| face.edges.each { |edge| edges << edge } }
|
||||
|
||||
edges.uniq!
|
||||
|
||||
edges.each { |edge| remove_edge_have_coplanar_faces(edge) }
|
||||
|
||||
# Remove remaining orphan edges
|
||||
# edges.reject(&:deleted?).select { |edge| edge.faces.empty? }.each(&:erase!)
|
||||
|
||||
merged_faces(faces)
|
||||
end
|
||||
|
||||
def self.merged_faces(faces)
|
||||
faces.reject(&:deleted?)
|
||||
end
|
||||
@@ -35,43 +52,34 @@ module SpeckleConnector
|
||||
# - Whether UV texture map is aligned between faces or not.
|
||||
# - Finally, if faces are coplanar by correcting these checks, then removes edge from Sketchup.active_model.
|
||||
# @param edge [Sketchup::Edge] edge to check.
|
||||
# @param faces [Array<Sketchup::Face>] scoped faces to check 'edge.faces' both (first and second)
|
||||
# belongs to this faces or not. If any of this faces does not involve this scoped faces, then do not delete.
|
||||
# @param ignore_materials [Boolean] whether ignore materials or not.
|
||||
# Returns true if the given edge separating two coplanar faces.
|
||||
# Return false otherwise.
|
||||
# rubocop:disable Metrics/AbcSize
|
||||
def self.remove_edge_have_coplanar_faces(edge, faces, ignore_materials)
|
||||
def self.remove_edge_have_coplanar_faces(edge)
|
||||
return false unless edge.valid? && edge.is_a?(Sketchup::Edge)
|
||||
return false unless edge.faces.size == 2
|
||||
|
||||
# Check scoped faces have this edges
|
||||
if edge.faces.size == 2
|
||||
is_first = faces.include?(edge.faces[0])
|
||||
is_second = faces.include?(edge.faces[1])
|
||||
return false unless is_first && is_second
|
||||
end
|
||||
|
||||
face_1, face_2 = edge.faces
|
||||
|
||||
return false if face_duplicate?(face_1, face_2)
|
||||
# Check for troublesome faces which might lead to missing geometry if merged.
|
||||
return false unless edge_safe_to_merge?(edge)
|
||||
begin
|
||||
return false unless face_1.normal.samedirection?(face_2.normal)
|
||||
|
||||
return false if face_duplicate?(face_1, face_2)
|
||||
# Check for troublesome faces which might lead to missing geometry if merged.
|
||||
return false unless edge_safe_to_merge?(edge)
|
||||
|
||||
# Check materials match.
|
||||
unless ignore_materials
|
||||
return false unless (face_1.material == face_2.material) && (face_1.back_material == face_2.back_material)
|
||||
|
||||
# Verify UV mapping match.
|
||||
return false if !face_1.material.nil? && !continuous_uv?(face_1, face_2, edge) && face_1.material.texture.nil?
|
||||
end
|
||||
# Check faces are coplanar or not.
|
||||
return false unless faces_coplanar?(face_1, face_2)
|
||||
# Check faces are coplanar or not.
|
||||
return false unless faces_coplanar?(face_1, face_2)
|
||||
|
||||
edge.erase!
|
||||
true
|
||||
edge.erase!
|
||||
true
|
||||
rescue StandardError => e
|
||||
puts "Failed to merge coplanar faces by removing edge with error: #{e}"
|
||||
false
|
||||
end
|
||||
end
|
||||
# rubocop:enable Metrics/AbcSize
|
||||
|
||||
# Determines if two faces are overlapped.
|
||||
def self.face_duplicate?(face_1, face_2, overlapping: false)
|
||||
|
||||
@@ -4,6 +4,7 @@ require_relative 'converter'
|
||||
require_relative '../constants/type_constants'
|
||||
require_relative '../speckle_entities/speckle_entity'
|
||||
require_relative '../speckle_objects/gis/polygon_element'
|
||||
require_relative '../speckle_objects/gis/line_element'
|
||||
require_relative '../speckle_objects/other/transform'
|
||||
require_relative '../speckle_objects/other/render_material'
|
||||
require_relative '../speckle_objects/other/block_definition'
|
||||
@@ -19,6 +20,7 @@ require_relative '../speckle_objects/geometry/mesh'
|
||||
require_relative '../speckle_objects/built_elements/view3d'
|
||||
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 '../sketchup_model/dictionary/speckle_entity_dictionary_handler'
|
||||
|
||||
module SpeckleConnector
|
||||
@@ -32,11 +34,14 @@ module SpeckleConnector
|
||||
# @return [String] source application of received object that will be converted to native
|
||||
attr_reader :source_app
|
||||
|
||||
attr_reader :converted_faces
|
||||
|
||||
def initialize(state, stream_id, stream_name, branch_name, source_app)
|
||||
super(state, stream_id)
|
||||
@stream_name = stream_name
|
||||
@branch_name = branch_name
|
||||
@source_app = source_app.downcase
|
||||
@converted_faces = []
|
||||
end
|
||||
|
||||
# Module aliases
|
||||
@@ -61,7 +66,9 @@ module SpeckleConnector
|
||||
DISPLAY_VALUE = OTHER::DisplayValue
|
||||
VIEW3D = BUILTELEMENTS::View3d
|
||||
POLYGON_ELEMENT = GIS::PolygonElement
|
||||
LINE_ELEMENT = GIS::LineElement
|
||||
COLLECTION = SpeckleObjects::Speckle::Core::Models::Collection
|
||||
GIS_LAYER_COLLECTION = SpeckleObjects::Speckle::Core::Models::GisLayerCollection
|
||||
|
||||
BASE_OBJECT_PROPS = %w[applicationId id speckle_type totalChildrenCount].freeze
|
||||
CONVERTABLE_SPECKLE_TYPES = %w[
|
||||
@@ -81,7 +88,10 @@ module SpeckleConnector
|
||||
Objects.BuiltElements.Wall:Objects.BuiltElements.Revit.RevitWall
|
||||
Objects.BuiltElements.Network
|
||||
Objects.GIS.PolygonElement
|
||||
Objects.GIS.LineElement
|
||||
Speckle.Core.Models.Collection
|
||||
Speckle.Core.Models.Collection:Objects.GIS.RasterLayer
|
||||
Speckle.Core.Models.Collection:Objects.GIS.VectorLayer
|
||||
].freeze
|
||||
|
||||
def from_revit
|
||||
@@ -300,7 +310,10 @@ module SpeckleConnector
|
||||
OBJECTS_BUILTELEMENTS_REVIT_DIRECTSHAPE => BUILTELEMENTS::Revit::DirectShape.method(:to_native),
|
||||
OBJECTS_BUILTELEMENTS_NETWORK => BUILTELEMENTS::Network.method(:to_native),
|
||||
OBJECTS_GIS_POLYGONELEMENT => POLYGON_ELEMENT.method(:to_native),
|
||||
SPECKLE_CORE_MODELS_COLLECTION => COLLECTION.method(:to_native)
|
||||
OBJECTS_GIS_LINEELEMENT => LINE_ELEMENT.method(:to_native),
|
||||
SPECKLE_CORE_MODELS_COLLECTION => COLLECTION.method(:to_native),
|
||||
SPECKLE_CORE_MODELS_COLLECTION_RASTER_LAYER => GIS_LAYER_COLLECTION.method(:to_native),
|
||||
SPECKLE_CORE_MODELS_COLLECTION_VECTOR_LAYER => GIS_LAYER_COLLECTION.method(:to_native)
|
||||
}.freeze
|
||||
|
||||
# @param state [States::State] state of the speckle application
|
||||
@@ -312,6 +325,8 @@ module SpeckleConnector
|
||||
# Call 'to_native' method by passing this method itself to handle nested 'to_native' conversions.
|
||||
# It returns updated state and converted entities.
|
||||
state, converted_entities = to_native_method.call(state, obj, layer, entities, &convert_to_native)
|
||||
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)
|
||||
|
||||
@@ -64,23 +64,19 @@ module SpeckleConnector
|
||||
def convert(entity, preferences, speckle_state, parent = :base)
|
||||
convert = method(:convert)
|
||||
|
||||
unless SketchupModel::Reader::MapperReader.mapped_with_schema?(entity)
|
||||
unless SketchupModel::Reader::MapperReader.mapped_with_schema?(entity) &&
|
||||
!entity.is_a?(Sketchup::ComponentDefinition)
|
||||
return from_native_to_speckle(entity, preferences, speckle_state, parent, &convert)
|
||||
end
|
||||
|
||||
return speckle_state, nil
|
||||
end
|
||||
|
||||
def from_mapped_to_speckle(entity, path, preferences)
|
||||
direct_shape = SpeckleObjects::BuiltElements::Revit::DirectShape
|
||||
.from_entity(speckle_state, entity, path, @units, preferences)
|
||||
return [direct_shape, [entity]]
|
||||
end
|
||||
|
||||
# rubocop:disable Metrics/MethodLength
|
||||
def from_native_to_speckle(entity, preferences, speckle_state, parent, &convert)
|
||||
if entity.is_a?(Sketchup::Edge)
|
||||
line = SpeckleObjects::Geometry::Line.from_edge(entity, @units, preferences[:model]).to_h
|
||||
line = SpeckleObjects::Geometry::Line.from_edge(speckle_state: speckle_state, edge: entity,
|
||||
units: @units, model_preferences: preferences[:model]).to_h
|
||||
return speckle_state, [line, [entity]]
|
||||
end
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -118,7 +118,8 @@ module SpeckleConnector
|
||||
VibrationManagement: 106,
|
||||
Walls: 107,
|
||||
StructConnectionWelds: 108,
|
||||
Windows: 109
|
||||
Windows: 109,
|
||||
Railings: 110
|
||||
}.freeze
|
||||
end
|
||||
# rubocop:enable Metrics/MethodLength
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module SpeckleConnector
|
||||
module Mapper
|
||||
module Category
|
||||
# Revit categories for families.
|
||||
class RevitFamilyCategory < Hash
|
||||
class << self
|
||||
# rubocop:disable Metrics/MethodLength
|
||||
def dictionary
|
||||
{
|
||||
AudioVisualDevices: 9,
|
||||
CableTrayFitting: 16,
|
||||
Casework: 19,
|
||||
Columns: 21,
|
||||
CommunicationDevices: 22,
|
||||
ConduitFitting: 23,
|
||||
DataDevices: 30,
|
||||
Doors: 32,
|
||||
DuctAccessory: 33,
|
||||
ElectricalEquipment: 38,
|
||||
ElectricalFixtures: 39,
|
||||
Entourage: 40,
|
||||
FireAlarmDevices: 42,
|
||||
FireProtection: 43,
|
||||
FoodServiceEquipment: 45,
|
||||
Furniture: 46,
|
||||
FurnitureSystems: 47,
|
||||
GenericAnnotation: 48,
|
||||
GenericModel: 49,
|
||||
Hardscape: 51,
|
||||
LightingDevices: 52,
|
||||
LightingFixtures: 53,
|
||||
Lines: 54,
|
||||
Mass: 55,
|
||||
MechanicalEquipment: 56,
|
||||
MedicalEquipment: 57,
|
||||
NurseCallDevices: 58,
|
||||
Parking: 59,
|
||||
PipeAccessory: 68,
|
||||
PipeFitting: 69,
|
||||
Planting: 74,
|
||||
PlumbingFixtures: 76,
|
||||
Roads: 80,
|
||||
SecurityDevices: 82,
|
||||
Signage: 84,
|
||||
Site: 85,
|
||||
SpecialityEquipment: 86,
|
||||
Sprinklers: 87,
|
||||
StructuralFramingSystem: 89,
|
||||
StructuralColumns: 90,
|
||||
StructConnections: 91,
|
||||
StructuralFoundation: 93,
|
||||
StructuralFraming: 94,
|
||||
StructuralStiffener: 97,
|
||||
TemporaryStructure: 100,
|
||||
VerticalCirculation: 103,
|
||||
Windows: 109,
|
||||
Railings: 110
|
||||
}.freeze
|
||||
end
|
||||
# rubocop:enable Metrics/MethodLength
|
||||
|
||||
def reverse_dictionary
|
||||
dictionary.collect { |k, v| [v, k] }.to_h
|
||||
end
|
||||
|
||||
def to_a
|
||||
dictionary.collect { |k, v| { key: k, value: v } }.to_a
|
||||
end
|
||||
|
||||
def reverse_to_a
|
||||
dictionary.collect { |k, v| { key: v, value: k } }.to_a
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -2,8 +2,18 @@
|
||||
|
||||
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/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_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 '../sketchup_model/query/entity'
|
||||
require_relative '../sketchup_model/reader/mapper_reader'
|
||||
require_relative '../sketchup_model/dictionary/speckle_schema_dictionary_handler'
|
||||
@@ -11,18 +21,23 @@ require_relative '../sketchup_model/dictionary/speckle_schema_dictionary_handler
|
||||
module SpeckleConnector
|
||||
# Mapper is a tool to convert SketchUp entities to other applications' native objects.
|
||||
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.
|
||||
def self.mapped_entities_on_selection(sketchup_model)
|
||||
flat_selection_with_path = SketchupModel::Query::Entity.flat_entities_with_path(
|
||||
flat_selection_with_path = QUERY::Entity.flat_entities_with_path(
|
||||
sketchup_model.selection,
|
||||
[Sketchup::Face, Sketchup::ComponentInstance, Sketchup::Group], [sketchup_model]
|
||||
[Sketchup::Edge, Sketchup::Face, Sketchup::ComponentInstance, Sketchup::Group], [sketchup_model]
|
||||
)
|
||||
mapped_selection = []
|
||||
flat_selection_with_path.each do |entities|
|
||||
entity = entities[0]
|
||||
is_entity_mapped = SketchupModel::Reader::MapperReader.mapped_with_schema?(entity)
|
||||
is_entity_mapped = MAPPER_READER.mapped_with_schema?(entity)
|
||||
if entity.respond_to?(:definition)
|
||||
is_definition_mapped = SketchupModel::Reader::MapperReader.mapped_with_schema?(entity.definition)
|
||||
is_definition_mapped = MAPPER_READER.mapped_with_schema?(entity.definition)
|
||||
mapped_selection.append(entities) if is_entity_mapped || is_definition_mapped
|
||||
next
|
||||
end
|
||||
@@ -31,31 +46,82 @@ module SpeckleConnector
|
||||
mapped_selection
|
||||
end
|
||||
|
||||
def self.convert_mapped_entity(speckle_state, entity_with_path, preferences, units, &convert)
|
||||
entity = entity_with_path[0]
|
||||
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 = SketchupModel::Dictionary::SpeckleSchemaDictionaryHandler.speckle_schema_to_speckle(entity)
|
||||
speckle_schema = SPECKLE_SCHEMA_DICTIONARY_HANDLER.speckle_schema_to_speckle(entity)
|
||||
return speckle_schema if speckle_schema.nil?
|
||||
|
||||
if speckle_schema['method'] == 'Default Floor'
|
||||
return SpeckleObjects::BuiltElements::DefaultFloor
|
||||
.to_speckle_schema(entity, units, global_transformation: global_transformation)
|
||||
end
|
||||
to_speckle_schema_method = NATIVE_MAPPING_TO_SPECKLE[speckle_schema['method']]
|
||||
return speckle_schema if to_speckle_schema_method.nil?
|
||||
|
||||
if speckle_schema['method'] == 'Floor'
|
||||
return SpeckleObjects::BuiltElements::RevitFloor
|
||||
.to_speckle_schema(speckle_state, entity, units, global_transformation: global_transformation)
|
||||
end
|
||||
to_speckle_schema_method.call(speckle_state, entity, units, global_transformation: global_transformation)
|
||||
end
|
||||
|
||||
if speckle_schema['method'] == 'Default Wall'
|
||||
return SpeckleObjects::BuiltElements::DefaultWall
|
||||
.to_speckle_schema(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 speckle_schema['method'] == 'Wall'
|
||||
return SpeckleObjects::BuiltElements::RevitWall
|
||||
.to_speckle_schema(speckle_state, entity, units, global_transformation: global_transformation)
|
||||
if entity.is_a?(Sketchup::ComponentInstance)
|
||||
method = SPECKLE_SCHEMA_DICTIONARY_HANDLER.get_attribute(entity.definition, 'method')
|
||||
end
|
||||
method
|
||||
end
|
||||
|
||||
return speckle_schema
|
||||
def self.face_mapping?(entity, method)
|
||||
(method.include?('Floor') || method.include?('Wall')) && entity.is_a?(Sketchup::Face)
|
||||
end
|
||||
|
||||
def self.edge_mapping?(entity, method)
|
||||
(method.include?('Column') || method.include?('Beam') || method.include?('Pipe') || method.include?('Duct')) &&
|
||||
entity.is_a?(Sketchup::Edge)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,9 +12,9 @@ module SpeckleConnector
|
||||
include Immutable::ImmutableUtils
|
||||
DICT_HANDLER = SketchupModel::Dictionary::SpeckleModelDictionaryHandler
|
||||
# rubocop:disable Layout/LineLength
|
||||
DEFAULT_CONFIG = "('configSketchup', '{\"dark_theme\":false, \"diffing\":false, \"register_speckle_entity\":false}, \"fe2\":false');"
|
||||
DEFAULT_CONFIG = "('configSketchup', '{\"dark_theme\":false, \"diffing\":false, \"register_speckle_entity\":false, \"fe2\":true}');"
|
||||
# rubocop:enable Layout/LineLength
|
||||
DEFAULT_PREFERENCES = '{"dark_theme":false, "diffing":false, "register_speckle_entity": false, "fe2": false}'
|
||||
DEFAULT_PREFERENCES = '{"dark_theme":false, "diffing":false, "register_speckle_entity": false, "fe2": true}'
|
||||
|
||||
# @param sketchup_model [Sketchup::Model] active model.
|
||||
def self.read_preferences(sketchup_model)
|
||||
@@ -34,12 +34,16 @@ module SpeckleConnector
|
||||
def self.data_complete?(row_data)
|
||||
return false if row_data.empty?
|
||||
|
||||
data = JSON.parse(row_data.first.first)
|
||||
if data['dark_theme'].nil? || data['fe2'].nil? || data['diffing'].nil? || data['register_speckle_entity'].nil?
|
||||
return false
|
||||
end
|
||||
begin
|
||||
data = JSON.parse(row_data.first.first)
|
||||
if data['dark_theme'].nil? || data['fe2'].nil? || data['diffing'].nil? || data['register_speckle_entity'].nil?
|
||||
return false
|
||||
end
|
||||
|
||||
true
|
||||
true
|
||||
rescue StandardError
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
# Validates current preferences. If there are incomplete data then this method resets it with default preferences.
|
||||
|
||||
@@ -136,6 +136,15 @@ module SpeckleConnector
|
||||
next if (entity.is_a?(Sketchup::Face) || entity.is_a?(Sketchup::Edge)) &&
|
||||
!state.user_state.user_preferences[:register_speckle_entity]
|
||||
|
||||
if entity.is_a?(Sketchup::ComponentDefinition)
|
||||
definition = speckle_object['definition'] || speckle_object['@block_definition'] ||
|
||||
speckle_object['block_definition']
|
||||
if definition
|
||||
speckle_id = definition['id']
|
||||
speckle_type = definition['speckle_type']
|
||||
end
|
||||
end
|
||||
|
||||
ent = SpeckleEntity.new(entity, speckle_id, application_id, speckle_type, children, [stream_id])
|
||||
ent.write_initial_base_data
|
||||
speckle_state = speckle_state.with_speckle_entity(ent)
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
# 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
|
||||
@@ -0,0 +1,39 @@
|
||||
# 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
|
||||
@@ -0,0 +1,39 @@
|
||||
# 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
|
||||
|
||||
# @param face [Sketchup::Face] face to get speckle schema for floor.
|
||||
def self.to_speckle_schema(face, units, global_transformation: nil)
|
||||
def self.to_speckle_schema(_speckle_state, face, units, global_transformation: nil)
|
||||
outline = Geometry::Polyline.from_loop(face.loops.first, units, global_transformation: global_transformation)
|
||||
voids = []
|
||||
if face.loops.length > 1
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
# 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
|
||||
|
||||
# @param face [Sketchup::Face] face to get speckle schema for floor.
|
||||
def self.to_speckle_schema(face, units, global_transformation: nil)
|
||||
def self.to_speckle_schema(_speckle_state, face, units, global_transformation: nil)
|
||||
base_line = Geometry::Line.base_line_from_face(face, units, global_transformation: global_transformation)
|
||||
|
||||
material = face.material || face.back_material
|
||||
|
||||
@@ -89,7 +89,7 @@ module SpeckleConnector
|
||||
mapped_selection
|
||||
end
|
||||
|
||||
def self.from_entity(speckle_state, entity, path, units, preferences)
|
||||
def self.from_entity(speckle_state, entity, path, units, model_preferences)
|
||||
schema = DICTIONARY::SpeckleSchemaDictionaryHandler.attribute_dictionary(entity)
|
||||
if schema.nil? && entity.respond_to?(:definition)
|
||||
schema = DICTIONARY::SpeckleSchemaDictionaryHandler.attribute_dictionary(entity.definition)
|
||||
@@ -103,7 +103,14 @@ module SpeckleConnector
|
||||
entity.definition.entities, [Sketchup::Face], path.append(entity)
|
||||
)
|
||||
end
|
||||
base_geometries = group_faces_under_mesh_by_material(speckle_state, entities_with_path, units, preferences)
|
||||
base_geometries = if entity.is_a?(Sketchup::Edge)
|
||||
[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(
|
||||
name: schema[:name], category: schema[:category], units: units,
|
||||
base_geometries: base_geometries, application_id: entity.persistent_id
|
||||
@@ -111,13 +118,13 @@ module SpeckleConnector
|
||||
end
|
||||
|
||||
# rubocop:disable Metrics/MethodLength
|
||||
def self.group_faces_under_mesh_by_material(speckle_state, faces_with_path, units, preferences)
|
||||
def self.group_faces_under_mesh_by_material(speckle_state, faces_with_path, units, model_preferences)
|
||||
mesh_groups = {}
|
||||
faces_with_path.each do |face_with_path|
|
||||
face = face_with_path[0]
|
||||
entity_path = face_with_path[1..-1]
|
||||
parent_material = QUERY::Entity.parent_material(entity_path)
|
||||
mesh_group_id = Geometry::Mesh.get_mesh_group_id(face, preferences[:model], parent_material)
|
||||
mesh_group_id = Geometry::Mesh.get_mesh_group_id(face, model_preferences, parent_material)
|
||||
|
||||
if mesh_groups.key?(mesh_group_id)
|
||||
mesh_group = mesh_groups[mesh_group_id]
|
||||
@@ -126,7 +133,7 @@ module SpeckleConnector
|
||||
else
|
||||
mesh = Geometry::Mesh.from_face(
|
||||
speckle_state: speckle_state,
|
||||
face: face, units: units, model_preferences: preferences[:model],
|
||||
face: face, units: units, model_preferences: model_preferences,
|
||||
global_transform: QUERY::Entity.global_transformation(face, entity_path),
|
||||
parent_material: parent_material
|
||||
)
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative '../../base'
|
||||
require_relative '../../../constants/type_constants'
|
||||
|
||||
module SpeckleConnector
|
||||
module SpeckleObjects
|
||||
module BuiltElements
|
||||
module Revit
|
||||
# Family instance for Revit mappings.
|
||||
class FamilyInstance < Base
|
||||
SPECKLE_TYPE = OBJECTS_BUILTELEMENTS_REVIT_FAMILY_INSTANCE
|
||||
|
||||
# rubocop:disable Metrics/ParameterLists
|
||||
def initialize(family:, type:, level:, units:, base_point:, rotation:, 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[:units] = units
|
||||
self[:basePoint] = base_point
|
||||
self[:rotation] = rotation
|
||||
end
|
||||
# rubocop:enable Metrics/ParameterLists
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,63 @@
|
||||
# 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
|
||||
@@ -0,0 +1,63 @@
|
||||
# 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
|
||||
@@ -0,0 +1,67 @@
|
||||
# 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
|
||||
@@ -0,0 +1,65 @@
|
||||
# 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
|
||||
@@ -11,6 +11,10 @@ module SpeckleConnector
|
||||
end
|
||||
|
||||
def self.length_to_native(length, units)
|
||||
if units == 'none'
|
||||
units = SpeckleConnector::Converters::
|
||||
SKETCHUP_UNITS[Sketchup.active_model.options['UnitsOptions']['LengthUnit']]
|
||||
end
|
||||
length.__send__(SpeckleConnector::Converters::SKETCHUP_UNIT_STRINGS[units])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -34,17 +34,33 @@ module SpeckleConnector
|
||||
self[:domain] = domain
|
||||
self[:units] = units
|
||||
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?
|
||||
end
|
||||
# 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.
|
||||
def self.from_edge(edge, units, model_preferences, global_transformation: nil)
|
||||
def self.from_edge(speckle_state:, edge:, units:, model_preferences:, global_transformation: nil)
|
||||
dictionaries = SketchupModel::Dictionary::BaseDictionaryHandler
|
||||
.attribute_dictionaries_to_speckle(edge, model_preferences)
|
||||
att = dictionaries.any? ? { dictionaries: dictionaries } : {}
|
||||
speckle_schema = SketchupModel::Dictionary::SpeckleSchemaDictionaryHandler.speckle_schema_to_speckle(edge)
|
||||
speckle_schema = Mapper.to_speckle(speckle_state, edge, units, global_transformation: global_transformation)
|
||||
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)
|
||||
|
||||
@@ -121,9 +121,9 @@ module SpeckleConnector
|
||||
mesh_layer_name = SketchupModel::Query::Layer.entity_layer_from_path(mesh['layer'])
|
||||
mesh_layer = state.sketchup_state.sketchup_model.layers.to_a.find { |l| l.display_name == mesh_layer_name }
|
||||
# Merge only added faces in this scope
|
||||
if model_preferences[:merge_coplanar_faces]
|
||||
added_faces = Converters::CleanUp.merge_coplanar_faces(added_faces)
|
||||
end
|
||||
# if model_preferences[:merge_coplanar_faces]
|
||||
# added_faces = Converters::CleanUp.merge_coplanar_faces(added_faces)
|
||||
# end
|
||||
added_faces.each do |face|
|
||||
face.layer = mesh_layer unless mesh_layer.nil?
|
||||
# Smooth edges if they already soft
|
||||
|
||||
@@ -0,0 +1,207 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module SpeckleConnector
|
||||
module SpeckleObjects
|
||||
module Geometry
|
||||
module Units
|
||||
MILLIMETERS = 'mm'
|
||||
CENTIMETERS = 'cm'
|
||||
METERS = 'm'
|
||||
KILOMETERS = 'km'
|
||||
INCHES = 'in'
|
||||
FEET = 'ft'
|
||||
YARDS = 'yd'
|
||||
MILES = 'mi'
|
||||
NONE = 'none'
|
||||
|
||||
# USInches = "us_in" the smelliest ones, can add later if people scream "USA #1"
|
||||
USFEET = 'us_ft' # it happened, absolutely gross
|
||||
|
||||
SUPPORTED_UNITS = [MILLIMETERS, CENTIMETERS, METERS, KILOMETERS,
|
||||
INCHES, FEET, USFEET, YARDS, MILES, NONE].freeze
|
||||
|
||||
CONVERSION_TABLE = {
|
||||
MILLIMETERS => {
|
||||
CENTIMETERS => 0.1,
|
||||
METERS => 0.001,
|
||||
KILOMETERS => 1e-6,
|
||||
INCHES => 0.0393701,
|
||||
FEET => 0.00328084,
|
||||
USFEET => 0.0032808333,
|
||||
YARDS => 0.00109361,
|
||||
MILES => 6.21371e-7
|
||||
},
|
||||
CENTIMETERS => {
|
||||
MILLIMETERS => 10,
|
||||
METERS => 0.01,
|
||||
KILOMETERS => 1e-5,
|
||||
INCHES => 0.393701,
|
||||
FEET => 0.0328084,
|
||||
USFEET => 0.0328083333,
|
||||
YARDS => 0.0109361,
|
||||
MILES => 6.21371e-6
|
||||
},
|
||||
METERS => {
|
||||
MILLIMETERS => 1000,
|
||||
CENTIMETERS => 100,
|
||||
KILOMETERS => 0.001,
|
||||
INCHES => 39.3701,
|
||||
FEET => 3.28084,
|
||||
USFEET => 3.28083333,
|
||||
YARDS => 1.09361,
|
||||
MILES => 0.000621371
|
||||
},
|
||||
KILOMETERS => {
|
||||
MILLIMETERS => 1e6,
|
||||
CENTIMETERS => 100000,
|
||||
METERS => 1000,
|
||||
INCHES => 39370.1,
|
||||
FEET => 3280.84,
|
||||
USFEET => 3280.83333,
|
||||
YARDS => 1093.61,
|
||||
MILES => 0.621371
|
||||
},
|
||||
INCHES => {
|
||||
MILLIMETERS => 25.4,
|
||||
CENTIMETERS => 2.54,
|
||||
METERS => 0.0254,
|
||||
KILOMETERS => 2.54e-5,
|
||||
FEET => 0.0833333,
|
||||
USFEET => 0.0833331667,
|
||||
YARDS => 0.027777694,
|
||||
MILES => 1.57828e-5
|
||||
},
|
||||
FEET => {
|
||||
MILLIMETERS => 304.8,
|
||||
CENTIMETERS => 30.48,
|
||||
METERS => 0.3048,
|
||||
KILOMETERS => 0.0003048,
|
||||
INCHES => 12,
|
||||
USFEET => 0.999998,
|
||||
YARDS => 0.333332328,
|
||||
MILES => 0.000189394
|
||||
},
|
||||
USFEET => {
|
||||
MILLIMETERS => 120000.0 / 3937.0,
|
||||
CENTIMETERS => 12000.0 / 3937.0,
|
||||
METERS => 1200.0 / 3937.0,
|
||||
KILOMETERS => 1.2 / 3937.0,
|
||||
INCHES => 12.000024,
|
||||
FEET => 1.000002,
|
||||
YARDS => 1.000002 / 3.0,
|
||||
MILES => 1.000002 / 5280.0
|
||||
},
|
||||
YARDS => {
|
||||
MILLIMETERS => 914.4,
|
||||
CENTIMETERS => 91.44,
|
||||
METERS => 0.9144,
|
||||
KILOMETERS => 0.0009144,
|
||||
INCHES => 36,
|
||||
FEET => 3,
|
||||
USFEET => 2.999994,
|
||||
MILES => 1.0 / 1760.0
|
||||
},
|
||||
MILES => {
|
||||
MILLIMETERS => 1.609e6,
|
||||
CENTIMETERS => 160934,
|
||||
METERS => 1609.34,
|
||||
KILOMETERS => 1.60934,
|
||||
INCHES => 63360,
|
||||
FEET => 5280,
|
||||
USFEET => 5279.98944002112,
|
||||
YARDS => 1759.99469184
|
||||
},
|
||||
NONE => { NONE => 1 }
|
||||
}.freeze
|
||||
|
||||
def self.unit_supported?(unit)
|
||||
SUPPORTED_UNITS.include?(unit)
|
||||
end
|
||||
|
||||
# USYards = "us_yd" the smelliest ones, can add later if people scream "USA #1"
|
||||
# USMiles = "us_mi" the smelliest ones, can add later if people scream "USA #1"
|
||||
|
||||
def self.get_conversion_factor(from, to)
|
||||
from = get_units_from_string(from)
|
||||
to = get_units_from_string(to)
|
||||
CONVERSION_TABLE[from][to] || 1
|
||||
end
|
||||
|
||||
def self.get_units_from_string(unit)
|
||||
return nil if unit.nil?
|
||||
|
||||
case unit.downcase
|
||||
when 'mm', 'mil', 'millimeter', 'millimeters', 'millimetres'
|
||||
MILLIMETERS
|
||||
when 'cm', 'centimetre', 'centimeter', 'centimetres', 'centimeters'
|
||||
CENTIMETERS
|
||||
when 'm', 'meter', 'metre', 'meters', 'metres'
|
||||
METERS
|
||||
when 'inches', 'inch', 'in'
|
||||
INCHES
|
||||
when 'feet', 'foot', 'ft'
|
||||
FEET
|
||||
when 'ussurveyfeet'
|
||||
USFEET
|
||||
when 'yard', 'yards', 'yd'
|
||||
YARDS
|
||||
when 'miles', 'mile', 'mi'
|
||||
MILES
|
||||
when 'kilometers', 'kilometer', 'km'
|
||||
KILOMETERS
|
||||
when 'none'
|
||||
NONE
|
||||
else
|
||||
raise "Cannot understand what unit #{unit} is."
|
||||
end
|
||||
end
|
||||
|
||||
def self.get_encoding_from_unit(unit)
|
||||
case unit
|
||||
when MILLIMETERS
|
||||
1
|
||||
when CENTIMETERS
|
||||
2
|
||||
when METERS
|
||||
3
|
||||
when KILOMETERS
|
||||
4
|
||||
when INCHES
|
||||
5
|
||||
when FEET
|
||||
6
|
||||
when YARDS
|
||||
7
|
||||
when MILES
|
||||
8
|
||||
else
|
||||
0
|
||||
end
|
||||
end
|
||||
|
||||
def self.get_unit_from_encoding(unit)
|
||||
case unit
|
||||
when 1
|
||||
MILLIMETERS
|
||||
when 2
|
||||
CENTIMETERS
|
||||
when 3
|
||||
METERS
|
||||
when 4
|
||||
KILOMETERS
|
||||
when 5
|
||||
INCHES
|
||||
when 6
|
||||
FEET
|
||||
when 7
|
||||
YARDS
|
||||
when 8
|
||||
MILES
|
||||
else
|
||||
NONE
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,68 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative 'utils'
|
||||
require_relative '../base'
|
||||
require_relative '../other/transform'
|
||||
require_relative '../other/block_definition'
|
||||
require_relative '../other/block_instance'
|
||||
require_relative '../../constants/type_constants'
|
||||
require_relative '../../sketchup_model/dictionary/dictionary_handler'
|
||||
|
||||
module SpeckleConnector
|
||||
module SpeckleObjects
|
||||
module GIS
|
||||
# Line element in GIS tools.
|
||||
class LineElement < Base
|
||||
SPECKLE_TYPE = OBJECTS_GIS_LINEELEMENT
|
||||
|
||||
# Handles polygon element differently from display value.
|
||||
def self.to_native(state, obj, layer, entities, &convert_to_native)
|
||||
attributes = GIS.get_qgis_attributes(obj)
|
||||
obj = collect_definition_geometries(obj)
|
||||
obj['name'] = GIS.get_definition_name(obj, attributes)
|
||||
|
||||
state, _definitions = Other::BlockDefinition.to_native(
|
||||
state, obj, layer, entities, &convert_to_native
|
||||
)
|
||||
|
||||
definition = state.sketchup_state.sketchup_model
|
||||
.definitions[Other::BlockDefinition.get_definition_name(obj)]
|
||||
|
||||
Other::BlockInstance.find_and_erase_existing_instance(definition, obj['id'], obj['applicationId'])
|
||||
t_arr = obj['transform']
|
||||
transform = t_arr.nil? ? Geom::Transformation.new : Other::Transform.to_native(t_arr, obj['units'])
|
||||
instance = entities.add_instance(definition, transform)
|
||||
instance.name = obj['name'] unless obj['name'].nil?
|
||||
SketchupModel::Dictionary::DictionaryHandler.set_hash(instance, attributes, 'qgis')
|
||||
SketchupModel::Dictionary::DictionaryHandler.set_hash(definition, attributes, 'qgis')
|
||||
# Align instance axes that created from display value. (without any transform)
|
||||
Other::BlockInstance.align_instance_axes(instance)
|
||||
return state, [instance, definition]
|
||||
end
|
||||
|
||||
def self.collect_definition_geometries(obj)
|
||||
geometries = []
|
||||
|
||||
# FIXME: This type check needed because of QGIS. It can send geometries both way, object or array..
|
||||
# This is something need to be fixed by QGIS.
|
||||
if obj['geometry'].is_a?(Array)
|
||||
obj['geometry'].each do |geometry|
|
||||
geometries << geometry
|
||||
end
|
||||
else
|
||||
geometries += obj['geometry']
|
||||
end
|
||||
|
||||
geometries.each do |geo|
|
||||
if geo['speckle_type'] && geo['speckle_type'] == OBJECTS_GEOMETRY_MESH
|
||||
geo['sketchup_attributes'] = { 'is_soften' => false }
|
||||
end
|
||||
end
|
||||
|
||||
obj['geometry'] = geometries
|
||||
obj
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,5 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative 'utils'
|
||||
require_relative '../base'
|
||||
require_relative '../other/transform'
|
||||
require_relative '../other/block_definition'
|
||||
@@ -14,26 +15,11 @@ module SpeckleConnector
|
||||
class PolygonElement < Base
|
||||
SPECKLE_TYPE = OBJECTS_GIS_POLYGONELEMENT
|
||||
|
||||
def self.get_definition_name(obj, attributes)
|
||||
return obj['name'] unless obj['name'].nil?
|
||||
|
||||
return attributes['name'] unless attributes['name'].nil?
|
||||
|
||||
return "def::#{obj['id']}"
|
||||
end
|
||||
|
||||
def self.get_qgis_attributes(obj)
|
||||
attributes = obj['attributes'].to_h
|
||||
speckle_properties = %w[id speckle_type totalChildrenCount units applicationId]
|
||||
speckle_properties.each { |key| attributes.delete(key) }
|
||||
attributes
|
||||
end
|
||||
|
||||
# Handles polygon element differently from display value.
|
||||
def self.to_native(state, obj, layer, entities, &convert_to_native)
|
||||
attributes = get_qgis_attributes(obj)
|
||||
attributes = GIS.get_qgis_attributes(obj)
|
||||
obj = collect_definition_geometries(obj)
|
||||
obj['name'] = get_definition_name(obj, attributes)
|
||||
obj['name'] = GIS.get_definition_name(obj, attributes)
|
||||
|
||||
state, _definitions = Other::BlockDefinition.to_native(
|
||||
state, obj, layer, entities, &convert_to_native
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative '../base'
|
||||
require_relative '../other/transform'
|
||||
require_relative '../other/block_definition'
|
||||
require_relative '../other/block_instance'
|
||||
require_relative '../../constants/type_constants'
|
||||
require_relative '../../sketchup_model/dictionary/dictionary_handler'
|
||||
|
||||
module SpeckleConnector
|
||||
module SpeckleObjects
|
||||
module GIS
|
||||
def self.get_definition_name(obj, attributes)
|
||||
return obj['name'] unless obj['name'].nil?
|
||||
|
||||
return attributes['name'] unless attributes['name'].nil?
|
||||
|
||||
return "def::#{obj['id']}"
|
||||
end
|
||||
|
||||
def self.get_qgis_attributes(obj)
|
||||
attributes = obj['attributes'].to_h
|
||||
speckle_properties = %w[id speckle_type totalChildrenCount units applicationId]
|
||||
speckle_properties.each { |key| attributes.delete(key) }
|
||||
attributes
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -5,6 +5,8 @@ require_relative 'transform'
|
||||
require_relative 'block_definition'
|
||||
require_relative '../base'
|
||||
require_relative '../geometry/bounding_box'
|
||||
require_relative '../other/mapped_block_wrapper'
|
||||
require_relative '../built_elements/revit/family_instance'
|
||||
require_relative '../../sketchup_model/dictionary/base_dictionary_handler'
|
||||
require_relative '../../sketchup_model/dictionary/speckle_schema_dictionary_handler'
|
||||
require_relative '../../sketchup_model/query/layer'
|
||||
@@ -40,7 +42,7 @@ module SpeckleConnector
|
||||
self[:renderMaterial] = render_material
|
||||
self[:transform] = transform
|
||||
self[:sketchup_attributes] = sketchup_attributes if sketchup_attributes.any?
|
||||
self[:SpeckleSchema] = speckle_schema if speckle_schema.any?
|
||||
self[:speckle_schema] = speckle_schema if speckle_schema.any?
|
||||
# FIXME: Since blockDefinition sends with @ as detached, block basePlane renders on viewer.
|
||||
self['@@definition'] = block_definition
|
||||
end
|
||||
@@ -72,7 +74,7 @@ module SpeckleConnector
|
||||
|
||||
# @param component_instance [Sketchup::ComponentInstance] component instance to convert Speckle BlockInstance
|
||||
# rubocop:disable Metrics/MethodLength
|
||||
def self.from_component_instance(component_instance, units, preferences, speckle_state, &convert)
|
||||
def self.from_component_instance(component_instance, units, preferences, speckle_state, path: nil, &convert)
|
||||
new_speckle_state, block_definition = convert.call(
|
||||
component_instance.definition,
|
||||
preferences,
|
||||
@@ -87,6 +89,15 @@ module SpeckleConnector
|
||||
speckle_schema = SketchupModel::Dictionary::SpeckleSchemaDictionaryHandler
|
||||
.speckle_schema_to_speckle(component_instance)
|
||||
|
||||
if speckle_schema.empty?
|
||||
speckle_schema = SketchupModel::Dictionary::SpeckleSchemaDictionaryHandler
|
||||
.speckle_schema_to_speckle(component_instance.definition)
|
||||
end
|
||||
|
||||
# transform into global if any path provided
|
||||
transformation = component_instance.transformation
|
||||
transformation = SketchupModel::Query::Entity.global_transformation(component_instance, path) if path
|
||||
|
||||
block_instance = BlockInstance.new(
|
||||
units: units,
|
||||
is_sketchup_group: false,
|
||||
@@ -96,13 +107,45 @@ module SpeckleConnector
|
||||
else
|
||||
RenderMaterial.from_material(component_instance.material)
|
||||
end,
|
||||
transform: Other::Transform.from_transformation(component_instance.transformation, units),
|
||||
transform: Other::Transform.from_transformation(transformation, units),
|
||||
block_definition: block_definition,
|
||||
layer: SketchupModel::Query::Layer.entity_path(component_instance),
|
||||
sketchup_attributes: att,
|
||||
speckle_schema: speckle_schema,
|
||||
application_id: component_instance.persistent_id.to_s
|
||||
)
|
||||
|
||||
if speckle_schema
|
||||
case speckle_schema['method']
|
||||
when 'New Revit Family'
|
||||
# duplicate already converted one to attach without speckle schema into mapped block wrapper
|
||||
copy_block_instance = block_instance.clone(freeze: true)
|
||||
block_instance['@SpeckleSchema'] = SpeckleObjects::Other::MappedBlockWrapper.new(
|
||||
category: speckle_schema['category'],
|
||||
units: units,
|
||||
instance: copy_block_instance,
|
||||
application_id: component_instance.persistent_id.to_s
|
||||
)
|
||||
when 'Family Instance'
|
||||
level = speckle_state.speckle_mapper_state.mapper_source
|
||||
.levels.find { |l| l[:name] == speckle_schema['level'] }
|
||||
family = speckle_schema['family']
|
||||
type = speckle_schema['family_type']
|
||||
block_instance['@SpeckleSchema'] = SpeckleObjects::BuiltElements::Revit::FamilyInstance.new(
|
||||
family: family,
|
||||
type: type,
|
||||
level: level,
|
||||
units: units,
|
||||
base_point: SpeckleObjects::Geometry::Point.from_vertex(
|
||||
component_instance.definition.insertion_point.transform(transformation),
|
||||
units
|
||||
),
|
||||
rotation: calculate_rotation(transformation.to_a),
|
||||
application_id: component_instance.persistent_id.to_s
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
return speckle_state, block_instance
|
||||
end
|
||||
# rubocop:enable Metrics/MethodLength
|
||||
@@ -228,6 +271,26 @@ module SpeckleConnector
|
||||
instance_transform = instance.transformation
|
||||
instance.transform!(instance_transform * transform.inverse * instance_transform.inverse)
|
||||
end
|
||||
|
||||
def self.calculate_rotation(matrix)
|
||||
# Ensure the matrix is a flat array with 16 elements
|
||||
unless matrix.is_a?(Array) && matrix.size == 16
|
||||
raise ArgumentError, 'Matrix must be an array with 16 elements'
|
||||
end
|
||||
|
||||
# Extract the elements of the 2x2 rotation sub-matrix
|
||||
cos_theta = matrix[0] # First column, first row
|
||||
sin_theta = matrix[1] # Second column, first row
|
||||
|
||||
# Calculate the rotation angle in radians
|
||||
theta = Math.atan2(sin_theta, cos_theta)
|
||||
|
||||
# Ensure the angle is between -π and π
|
||||
theta -= 2 * Math::PI while theta > Math::PI
|
||||
theta += 2 * Math::PI while theta < -Math::PI
|
||||
|
||||
theta
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative '../base'
|
||||
|
||||
module SpeckleConnector
|
||||
module SpeckleObjects
|
||||
module Other
|
||||
# MappedBlockWrapper object definition for Speckle.
|
||||
class MappedBlockWrapper < Base
|
||||
SPECKLE_TYPE = 'Objects.Other.MappedBlockWrapper'
|
||||
def initialize(category:, units:, instance:, application_id: nil)
|
||||
super(
|
||||
speckle_type: SPECKLE_TYPE,
|
||||
total_children_count: 0,
|
||||
application_id: application_id,
|
||||
id: nil
|
||||
)
|
||||
self[:category] = category
|
||||
self[:units] = units
|
||||
self[:instance] = instance
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -19,7 +19,7 @@ module SpeckleConnector
|
||||
id: nil
|
||||
)
|
||||
self[:units] = units
|
||||
self[:value] = value
|
||||
self[:matrix] = value
|
||||
end
|
||||
|
||||
def self.from_transformation(transformation, units)
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative 'collection'
|
||||
|
||||
module SpeckleConnector
|
||||
module SpeckleObjects
|
||||
module Speckle
|
||||
module Core
|
||||
module Models
|
||||
# VectorLayerCollection object that collect GIS vector elements under it's elements.
|
||||
class GisLayerCollection < Collection
|
||||
# @param state [States::State] state of the Speckle application.
|
||||
def self.to_native(state, vector_layer_collection, layer_or_folder, entities, &convert_to_native)
|
||||
elements = vector_layer_collection['elements']
|
||||
|
||||
elements.each do |element|
|
||||
new_state, _converted_entities = convert_to_native.call(state, element, layer_or_folder, entities)
|
||||
state = new_state
|
||||
end
|
||||
|
||||
return state, []
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -27,6 +27,27 @@ module SpeckleConnector
|
||||
self[:active_layer] = active_layer
|
||||
end
|
||||
|
||||
def self.to_native(state, model_collection, layer, entities, &convert_to_native)
|
||||
elements = model_collection['elements']
|
||||
views = model_collection['@Views']
|
||||
if views
|
||||
views.each do |view|
|
||||
new_state, _converted_entities = convert_to_native.call(state, view, layer, entities)
|
||||
state = new_state
|
||||
end
|
||||
end
|
||||
|
||||
elements.each do |element|
|
||||
new_state, _converted_entities = convert_to_native.call(state, element, layer, entities)
|
||||
state = new_state
|
||||
end
|
||||
|
||||
active_layer = model_collection['active_layer']
|
||||
state.sketchup_state.sketchup_model.active_layer = active_layer unless active_layer.nil?
|
||||
|
||||
return state, []
|
||||
end
|
||||
|
||||
def self.from_sketchup_model(sketchup_model, speckle_state, units, preferences, &convert)
|
||||
model_collection = ModelCollection.new(
|
||||
name: 'Sketchup Model', active_layer: sketchup_model.active_layer.display_name,
|
||||
@@ -60,48 +81,9 @@ module SpeckleConnector
|
||||
def self.collect_mapped_entities(speckle_state, sketchup_model, units, preferences, &convert)
|
||||
mapped_entities = Mapper.mapped_entities_on_selection(sketchup_model)
|
||||
mapped_entities.collect do |entity_with_path|
|
||||
convert_mapped_entity(speckle_state, entity_with_path, preferences, units)
|
||||
Mapper.convert_mapped_entity(speckle_state, entity_with_path, preferences, units, &convert)
|
||||
end
|
||||
end
|
||||
|
||||
def self.to_native(state, model_collection, layer, entities, &convert_to_native)
|
||||
elements = model_collection['elements']
|
||||
views = model_collection['@Views']
|
||||
if views
|
||||
views.each do |view|
|
||||
new_state, _converted_entities = convert_to_native.call(state, view, layer, entities)
|
||||
state = new_state
|
||||
end
|
||||
end
|
||||
|
||||
elements.each do |element|
|
||||
new_state, _converted_entities = convert_to_native.call(state, element, layer, entities)
|
||||
state = new_state
|
||||
end
|
||||
|
||||
active_layer = model_collection['active_layer']
|
||||
state.sketchup_state.sketchup_model.active_layer = active_layer unless active_layer.nil?
|
||||
|
||||
return state, []
|
||||
end
|
||||
|
||||
def self.convert_mapped_entity(speckle_state, entity_with_path, preferences, units)
|
||||
entity = entity_with_path[0]
|
||||
path = entity_with_path[1..-1]
|
||||
|
||||
method = SPECKLE_SCHEMA_DICTIONARY_HANDLER.get_attribute(entity, 'method')
|
||||
|
||||
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
|
||||
|
||||
direct_shape = DIRECT_SHAPE.from_entity(speckle_state, entity, path, units, preferences)
|
||||
return [direct_shape, [entity]]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -75,6 +75,12 @@ module SpeckleConnector
|
||||
with(:@message_queue => new_queue)
|
||||
end
|
||||
|
||||
def with_mapper_init_queue(init_parameters)
|
||||
new_queue = message_queue.merge({ "mapperInitialized":
|
||||
"mapperInitialized(#{JSON.generate(init_parameters)})" })
|
||||
with(:@message_queue => new_queue)
|
||||
end
|
||||
|
||||
def with_mapper_deselection_queue
|
||||
new_queue = message_queue.merge({ "entitiesDeselected": 'entitiesDeselected()' })
|
||||
with(:@message_queue => new_queue)
|
||||
|
||||
@@ -50,6 +50,11 @@ module SpeckleConnector
|
||||
with(:@speckle_state => new_speckle_state)
|
||||
end
|
||||
|
||||
def with_mapper_init_queue(init_parameters)
|
||||
new_speckle_state = speckle_state.with_mapper_init_queue(init_parameters)
|
||||
with(:@speckle_state => new_speckle_state)
|
||||
end
|
||||
|
||||
def with_empty_stream_queue
|
||||
new_speckle_state = speckle_state.with(:@stream_queue => {})
|
||||
with(:@speckle_state => new_speckle_state)
|
||||
|
||||
@@ -57,6 +57,10 @@ module SpeckleConnector
|
||||
html_dialog.execute_script(data)
|
||||
end
|
||||
|
||||
def reset_dialog_location
|
||||
html_dialog.center
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# @return [UI::HtmlDialog] the Sketchup interface to dialog
|
||||
@@ -77,8 +81,9 @@ module SpeckleConnector
|
||||
dialog.set_can_close do
|
||||
true
|
||||
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('https://development--speckle-sketchup-dui2.netlify.app/')
|
||||
add_exec_callback(dialog)
|
||||
dialog
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@ module SpeckleConnector
|
||||
# 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'
|
||||
MENU_TITLE = 'Speckle (Legacy)'
|
||||
BEFORE_NEVER_SHOWN = -1
|
||||
|
||||
# @return [Sketchup::Menu] the menu of the Speckle
|
||||
|
||||
@@ -18,6 +18,7 @@ require_relative '../commands/apply_mappings'
|
||||
require_relative '../commands/clear_mappings'
|
||||
require_relative '../commands/mapper_source_updated'
|
||||
|
||||
require_relative '../actions/mapper_initialized'
|
||||
require_relative '../actions/reload_accounts'
|
||||
require_relative '../actions/load_saved_streams'
|
||||
require_relative '../actions/init_local_accounts'
|
||||
@@ -93,7 +94,8 @@ module SpeckleConnector
|
||||
select_mappings_from_table: Commands::ActionCommand.new(@app, Actions::SelectMappingsFromTable),
|
||||
show_all_entities: Commands::ActionCommand.new(@app, Actions::ShowAllEntities),
|
||||
mapper_source_updated: Commands::MapperSourceUpdated.new(@app),
|
||||
clear_mapper_source: Commands::ActionCommand.new(@app, Actions::ClearMapperSource)
|
||||
clear_mapper_source: Commands::ActionCommand.new(@app, Actions::ClearMapperSource),
|
||||
mapper_initialized: Commands::ActionCommand.new(@app, Actions::MapperInitialized)
|
||||
}.freeze
|
||||
end
|
||||
# rubocop:enable Metrics/MethodLength
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
VUE_APP_DEV_TOKEN=
|
||||
VUE_APP_SPECKLE_NAME=SpeckleSketchup
|
||||
VUE_APP_DEFAULT_SERVER=https://latest.speckle.dev
|
||||
VUE_APP_DEFAULT_SERVER=https://latest.speckle.systems
|
||||
+47
-27
@@ -1,6 +1,7 @@
|
||||
<template>
|
||||
<v-app>
|
||||
<v-main>
|
||||
<legacy-dialog/>
|
||||
<v-app-bar app flat height="50">
|
||||
<v-img
|
||||
class="mx-auto px-0"
|
||||
@@ -48,21 +49,25 @@
|
||||
<v-img v-if="user.avatar" :src="user.avatar" />
|
||||
<v-img v-else :src="`https://robohash.org/` + user.id + `.png?size=40x40`" />
|
||||
</v-avatar>
|
||||
<div>
|
||||
<b>{{ user.name }}</b>
|
||||
</div>
|
||||
<div class="caption">
|
||||
{{ user.company }}
|
||||
<br />
|
||||
{{ user.bio ? 'Bio: ' + user.bio : '' }}
|
||||
</div>
|
||||
<div>
|
||||
<b>{{ user.name }}</b>
|
||||
<br />
|
||||
<b>{{ user.email }}</b>
|
||||
</div>
|
||||
<div class="caption">
|
||||
<b>{{ activeAccount().serverInfo.url }}</b>
|
||||
</div>
|
||||
</v-card-text>
|
||||
<v-card-text v-if="accounts()">
|
||||
<v-divider class="my-3" />
|
||||
|
||||
<div v-for="account in accounts()" :key="account.id">
|
||||
<v-btn
|
||||
v-if="account.userInfo.id != user.id"
|
||||
v-if="account.id != activeAccount().id"
|
||||
rounded
|
||||
large
|
||||
class="my-1 elevation-0"
|
||||
@@ -100,13 +105,13 @@
|
||||
/>
|
||||
</v-container>
|
||||
<create-stream-dialog
|
||||
v-if="accounts().length !== 0"
|
||||
:is-f-e2="preferences && preferences.user && preferences.user.fe2"
|
||||
v-if="accounts() && accounts().length !== 0"
|
||||
:is-f-e2-terms="preferences && preferences.user && preferences.user.fe2"
|
||||
:account-id="activeAccount().userInfo.id"
|
||||
:server-url="activeAccount().serverInfo.url"
|
||||
/>
|
||||
<v-container v-if="accounts().length !== 0" fluid>
|
||||
<router-view :stream-search-query="streamSearchQuery" />
|
||||
<v-container v-if="accounts() && accounts().length !== 0" fluid>
|
||||
<router-view :stream-search-query="streamSearchQuery"/>
|
||||
</v-container>
|
||||
<v-container v-else>
|
||||
<login/>
|
||||
@@ -128,8 +133,10 @@
|
||||
/*global sketchup*/
|
||||
import { bus } from './main'
|
||||
import userQuery from './graphql/user.gql'
|
||||
import serverInfoQuery from './graphql/serverInfo.gql'
|
||||
import { onLogin } from './vue-apollo'
|
||||
import Login from "@/views/Login";
|
||||
import LegacyDialog from './components/dialogs/LegacyDialog.vue';
|
||||
|
||||
global.collectPreferences = function (preferences) {
|
||||
bus.$emit('update-preferences', preferences)
|
||||
@@ -144,13 +151,16 @@ global.collectVersions = function (versions) {
|
||||
global.loadAccounts = function (accounts) {
|
||||
console.log('>>> SpeckleSketchup: Loading accounts', accounts)
|
||||
localStorage.setItem('localAccounts', JSON.stringify(accounts))
|
||||
let uuid = localStorage.getItem('uuid')
|
||||
let selectedAccountId = localStorage.getItem('selectedAccountId')
|
||||
if (accounts.length !== 0){
|
||||
if (uuid) {
|
||||
global.setSelectedAccount(accounts.find((acct) => acct['userInfo']['id'] === uuid))
|
||||
} else {
|
||||
global.setSelectedAccount(accounts.find((acct) => acct['isDefault']))
|
||||
if (selectedAccountId) {
|
||||
var account = accounts.find((acct) => acct['id'] === selectedAccountId)
|
||||
if (account){
|
||||
global.setSelectedAccount(account)
|
||||
return
|
||||
}
|
||||
}
|
||||
global.setSelectedAccount(accounts.find((acct) => acct['isDefault']))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,7 +168,8 @@ global.setSelectedAccount = function (account) {
|
||||
localStorage.setItem('selectedAccount', JSON.stringify(account))
|
||||
localStorage.setItem('serverUrl', account['serverInfo']['url'])
|
||||
localStorage.setItem('SpeckleSketchup.AuthToken', account['token'])
|
||||
localStorage.setItem('uuid', account['userInfo']['id'])
|
||||
localStorage.setItem('selectedAccountId', account['id'])
|
||||
localStorage.setItem('frontend2', account['serverInfo']['frontend2'])
|
||||
bus.$emit('selected-account-reloaded')
|
||||
}
|
||||
|
||||
@@ -169,7 +180,8 @@ export default {
|
||||
CreateStreamDialog: () => import('@/components/dialogs/CreateStreamDialog'),
|
||||
SettingsDialog: () => import('@/components/dialogs/SettingsDialog'),
|
||||
GlobalToast: () => import('@/components/GlobalToast'),
|
||||
Mapper: () => import('@/components/Mapper')
|
||||
Mapper: () => import('@/components/Mapper'),
|
||||
LegacyDialog: () => import('@/components/dialogs/LegacyDialog')
|
||||
},
|
||||
props: {
|
||||
size: {
|
||||
@@ -199,8 +211,19 @@ export default {
|
||||
apollo: {
|
||||
user: {
|
||||
query: userQuery
|
||||
},
|
||||
serverInfo: {
|
||||
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() {
|
||||
bus.$on('selected-account-reloaded', async () => {
|
||||
await onLogin(this.$apollo.provider.defaultClient)
|
||||
@@ -221,26 +244,23 @@ export default {
|
||||
this.branchText = this.preferences.user.fe2 ? 'Model' : 'Branch'
|
||||
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: {
|
||||
accounts() {
|
||||
return JSON.parse(localStorage.getItem('localAccounts'))
|
||||
},
|
||||
activeAccount(){
|
||||
return this.accounts().find((account) => account['isDefault'])
|
||||
activeAccount() {
|
||||
return JSON.parse(localStorage.getItem('selectedAccount'))
|
||||
},
|
||||
switchAccount(account) {
|
||||
this.$mixpanel.track('Connector Action', { name: 'Account Select' })
|
||||
global.setSelectedAccount(account)
|
||||
|
||||
// Force pushes to reload page to create ApolloClient from scratch
|
||||
// setTimeout(() => {
|
||||
// // timeout to wait a bit for potential sketchup.exec in the mean time calls
|
||||
// location.reload()
|
||||
// }, 200);
|
||||
},
|
||||
requestRefresh() {
|
||||
sketchup.exec({name: 'reload_accounts', data: {}})
|
||||
|
||||
@@ -171,7 +171,7 @@
|
||||
class="pt-0"
|
||||
label="Family"
|
||||
:disabled="!entitySelected"
|
||||
:items="families"
|
||||
:items="inputFamilies"
|
||||
density="compact"
|
||||
clearable
|
||||
@change="onSelectedFamilyChange"
|
||||
@@ -208,7 +208,7 @@
|
||||
v-model="selectedCategory"
|
||||
class="pt-0"
|
||||
label="Category"
|
||||
:items="availableCategories"
|
||||
:items="selectedMethod === 'New Revit Family' ? familyCategories : categories"
|
||||
item-value="value"
|
||||
item-text="key"
|
||||
:disabled="!entitySelected"
|
||||
@@ -282,14 +282,19 @@ import {groupBy} from "@/utils/groupBy";
|
||||
import MappingSource from "@/components/MapperSource.vue";
|
||||
import {sourceMap} from "@vue/cli-service/lib/config/terserOptions";
|
||||
|
||||
global.mapperSourceUpdated = function (streamId, levels, types) {
|
||||
global.mapperSourceUpdated = function (streamId, levels, types, familyInstances) {
|
||||
console.log(`Mapper source updated for ${streamId}.`)
|
||||
bus.$emit('mapper-source-updated', JSON.stringify(levels), JSON.stringify(types), JSON.stringify(familyInstances))
|
||||
}
|
||||
|
||||
global.entitySelected = function (selectionParameters) {
|
||||
bus.$emit('entities-selected', JSON.stringify(selectionParameters))
|
||||
}
|
||||
|
||||
global.mapperInitialized = function (initParameters) {
|
||||
bus.$emit('mapper-initialized', JSON.stringify(initParameters))
|
||||
}
|
||||
|
||||
global.entitiesDeselected = function () {
|
||||
bus.$emit('entities-deselected')
|
||||
}
|
||||
@@ -343,7 +348,7 @@ export default {
|
||||
entitySelected: false,
|
||||
selectedEntityCount: 0,
|
||||
selectedEntities: [],
|
||||
allFamilyTypes: {},
|
||||
|
||||
familyTypes: [],
|
||||
lastSelectedEntity: null,
|
||||
|
||||
@@ -355,10 +360,17 @@ export default {
|
||||
name: "",
|
||||
|
||||
availableMethods: [],
|
||||
availableCategories: [],
|
||||
families: [],
|
||||
allTypes: {},
|
||||
categories: [],
|
||||
familyCategories: [],
|
||||
|
||||
inputCategories: [],
|
||||
inputFamilies: [],
|
||||
inputFamilyTypes: {},
|
||||
|
||||
// comes from source
|
||||
types: {},
|
||||
levels: [],
|
||||
familyInstanceTypes: {}, // comes from source as filtered
|
||||
|
||||
mappedEntityCount: 0,
|
||||
mappedEntities: [],
|
||||
@@ -531,6 +543,14 @@ export default {
|
||||
this.categorySelectionActive = true
|
||||
this.nameSelectionActive = true
|
||||
}
|
||||
else if (this.selectedMethod === 'New Revit Family'){
|
||||
this.categorySelectionActive = true
|
||||
}
|
||||
else if (this.selectedMethod === 'Family Instance'){
|
||||
this.typeSelectionActive = true
|
||||
this.familySelectionActive = true
|
||||
this.levelSelectionActive = true
|
||||
}
|
||||
else if (nativeDefaultMethods.includes(this.selectedMethod)){
|
||||
this.typeSelectionActive = false
|
||||
this.familySelectionActive = false
|
||||
@@ -545,52 +565,63 @@ export default {
|
||||
}
|
||||
},
|
||||
getTypesFromSelectedFamily(){
|
||||
this.familyTypes = this.allFamilyTypes[this.selectedFamily]
|
||||
this.selectedFamilyType = this.familyTypes[0].type
|
||||
if (this.selectedFamily === null || this.selectedFamily === undefined){
|
||||
this.selectedFamily = this.families[0]
|
||||
}
|
||||
if (this.familyTypes === null ||this.familyTypes === undefined){
|
||||
this.familyTypes = this.allFamilyTypes[this.selectedFamily]
|
||||
}
|
||||
if (this.selectedFamilyType === null || this.selectedFamilyType === undefined){
|
||||
this.selectedFamilyType = this.familyTypes[0].type
|
||||
// There is no sense to set selected family type if method is not selected
|
||||
if (this.selectedMethod){
|
||||
if (this.sourceState !== 'Not Set'){
|
||||
this.familyTypes = this.inputFamilyTypes[this.selectedFamily]
|
||||
this.selectedFamilyType = this.familyTypes[0].type
|
||||
if (this.selectedFamilyType === null || this.selectedFamilyType === undefined){
|
||||
this.selectedFamilyType = this.familyTypes[0].type
|
||||
}
|
||||
}
|
||||
if (this.selectedFamily === null || this.selectedFamily === undefined){
|
||||
this.selectedFamily = this.inputFamilies[0]
|
||||
}
|
||||
if (this.familyTypes === null ||this.familyTypes === undefined){
|
||||
this.familyTypes = this.inputFamilyTypes[this.selectedFamily]
|
||||
}
|
||||
}
|
||||
},
|
||||
getFamiliesFromSelectedMethod(){
|
||||
switch (this.selectedMethod) {
|
||||
case 'Floor':
|
||||
this.families = Object.keys(this.allTypes['Floors']);
|
||||
this.allFamilyTypes = this.allTypes['Floors']
|
||||
this.inputFamilies = Object.keys(this.types['Floors']);
|
||||
this.inputFamilyTypes = this.types['Floors']
|
||||
break;
|
||||
case 'Wall':
|
||||
this.families = Object.keys(this.allTypes['Walls']);
|
||||
this.allFamilyTypes = this.allTypes['Walls']
|
||||
this.inputFamilies = Object.keys(this.types['Walls']);
|
||||
this.inputFamilyTypes = this.types['Walls']
|
||||
break;
|
||||
case 'Column':
|
||||
this.families = Object.keys(this.allTypes['Columns']);
|
||||
this.allFamilyTypes = this.allTypes['Columns']
|
||||
this.inputFamilies = Object.keys(this.types['Columns']);
|
||||
this.inputFamilyTypes = this.types['Columns']
|
||||
break;
|
||||
case 'Beam':
|
||||
this.families = Object.keys(this.allTypes['Beams']);
|
||||
this.allFamilyTypes = this.allTypes['Beams']
|
||||
this.inputFamilies = Object.keys(this.types['Beams']);
|
||||
this.inputFamilyTypes = this.types['Beams']
|
||||
break;
|
||||
case 'Pipe':
|
||||
this.families = Object.keys(this.allTypes['Piping System']);
|
||||
this.allFamilyTypes = this.allTypes['Piping System']
|
||||
this.inputFamilies = Object.keys(this.types['Piping System']);
|
||||
this.inputFamilyTypes = this.types['Piping System']
|
||||
break;
|
||||
case 'Duct':
|
||||
this.families = Object.keys(this.allTypes['Duct System']);
|
||||
this.allFamilyTypes = this.allTypes['Duct System']
|
||||
this.inputFamilies = Object.keys(this.types['Duct System']);
|
||||
this.inputFamilyTypes = this.types['Duct System']
|
||||
break;
|
||||
case 'Family Instance':
|
||||
this.inputFamilies = Object.keys(this.familyInstanceTypes);
|
||||
this.inputFamilyTypes = this.familyInstanceTypes
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (this.selectedFamily === null || this.selectedFamily === undefined){
|
||||
this.selectedFamily = this.families[0]
|
||||
}
|
||||
if (this.selectedLevel === null || this.selectedLevel === undefined){
|
||||
this.selectedLevel = this.levels[0].name
|
||||
if (this.selectedMethod){
|
||||
if (this.selectedFamily === null || this.selectedFamily === undefined){
|
||||
this.selectedFamily = this.inputFamilies[0]
|
||||
}
|
||||
if (this.selectedLevel === null || this.selectedLevel === undefined){
|
||||
this.selectedLevel = this.levels[0].name
|
||||
}
|
||||
}
|
||||
},
|
||||
hideOptionalMappingInputs(){
|
||||
@@ -608,7 +639,6 @@ export default {
|
||||
},
|
||||
clearInputs(){
|
||||
this.availableMethods = []
|
||||
this.availableCategories = []
|
||||
this.selectedEntities = []
|
||||
this.selectionTableData = []
|
||||
this.selectedEntityCount = 0
|
||||
@@ -620,8 +650,6 @@ export default {
|
||||
this.selectedLevel = null
|
||||
this.selectedFamily = null
|
||||
this.selectedFamilyType = null
|
||||
this.allTypes = null
|
||||
this.familyTypes = null
|
||||
},
|
||||
getSelectionTableData(){
|
||||
let groupByClass = groupBy('entityType')
|
||||
@@ -683,6 +711,12 @@ export default {
|
||||
}
|
||||
this.selectedMethod = this.lastSelectedEntity['definition']['schema']['method']
|
||||
this.selectedCategory = this.lastSelectedEntity['definition']['schema']['category']
|
||||
this.selectedFamily = this.lastSelectedEntity['definition']['schema']['family']
|
||||
this.getFamiliesFromSelectedMethod()
|
||||
this.getTypesFromSelectedFamily()
|
||||
this.selectedFamilyType = this.lastSelectedEntity['definition']['schema']['family_type']
|
||||
this.selectedLevel = this.lastSelectedEntity['definition']['schema']['level']
|
||||
this.updateMappingInputs()
|
||||
}
|
||||
}
|
||||
// Otherwise set entity mappings.
|
||||
@@ -694,7 +728,6 @@ export default {
|
||||
}else{
|
||||
this.name = this.lastSelectedEntity['entityName']
|
||||
}
|
||||
console.log("entity not mapped")
|
||||
this.updateMappingInputs()
|
||||
this.getFamiliesFromSelectedMethod()
|
||||
this.getTypesFromSelectedFamily()
|
||||
@@ -706,7 +739,6 @@ export default {
|
||||
this.name = this.lastSelectedEntity['schema']['name']
|
||||
}
|
||||
this.selectedMethod = this.lastSelectedEntity['schema']['method']
|
||||
console.log("entity is mapped")
|
||||
this.updateMappingInputs()
|
||||
this.selectedFamily = this.lastSelectedEntity['schema']['family']
|
||||
this.selectedCategory = this.lastSelectedEntity['schema']['category']
|
||||
@@ -814,18 +846,11 @@ export default {
|
||||
this.selectedFamily = null
|
||||
this.selectedFamilyType = null
|
||||
this.selectedLevel = null
|
||||
this.familyTypes = null
|
||||
this.levels = null
|
||||
this.availableMethods = null
|
||||
this.availableCategories = null
|
||||
this.allTypes = null
|
||||
},
|
||||
getDataFromSelection(selectionParameters){
|
||||
this.availableMethods = selectionParameters.mappingMethods
|
||||
this.availableCategories = selectionParameters.categories
|
||||
this.selectedEntities = selectionParameters.selection
|
||||
this.allTypes = selectionParameters.types
|
||||
this.levels = selectionParameters.levels
|
||||
this.selectedLevel = selectionParameters.selectedLevelName
|
||||
},
|
||||
updateStatesFromSelectionData(){
|
||||
@@ -838,8 +863,22 @@ export default {
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
sketchup.exec({name: "mapper_initialized", data: {}})
|
||||
sketchup.exec({name: "collect_mapped_entities", data: {}})
|
||||
|
||||
bus.$on('mapper-initialized', async (initParameters) => {
|
||||
const initPars = JSON.parse(initParameters)
|
||||
this.categories = initPars.categories
|
||||
this.familyCategories = initPars.familyCategories
|
||||
})
|
||||
|
||||
bus.$on('mapper-source-updated', async (levels, types, familyInstances) => {
|
||||
// Parse data to json object
|
||||
this.familyInstanceTypes = JSON.parse(familyInstances)
|
||||
this.levels = JSON.parse(levels)
|
||||
this.types = JSON.parse(types)
|
||||
})
|
||||
|
||||
bus.$on('entities-selected', async (selectionParameters) => {
|
||||
// Parse data to json object
|
||||
const selectionPars = JSON.parse(selectionParameters)
|
||||
|
||||
@@ -145,7 +145,8 @@ export default {
|
||||
prefetch: true,
|
||||
variables() {
|
||||
return {
|
||||
id: this.sourceStreamId
|
||||
id: this.sourceStreamId,
|
||||
limit: 100
|
||||
}
|
||||
},
|
||||
skip() {
|
||||
@@ -219,9 +220,4 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -91,19 +91,19 @@
|
||||
mdi-check
|
||||
</v-icon>
|
||||
<v-icon v-else small class="mr-1 float-left">mdi-source-branch</v-icon>
|
||||
{{ branch.name }} ({{ branch.commits.totalCount }})
|
||||
{{ branch.name }} ({{ branch && branch.commits ? branch.commits.totalCount : 0 }})
|
||||
</v-list-item-title>
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
</v-menu>
|
||||
<v-menu offset-y>
|
||||
<template #activator="{ on, attrs }">
|
||||
<v-chip v-if="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>
|
||||
{{ selectedBranch.commits.items.length ? commitId : 'no commits' }}
|
||||
{{ selectedBranch.commits.items.length ? commitId : 'no commits' }}
|
||||
</v-chip>
|
||||
</template>
|
||||
<v-list dense>
|
||||
<v-list v-if="selectedBranch && selectedBranch.commits" dense>
|
||||
<v-list-item
|
||||
v-for="(commit, index) in selectedBranch.commits.items"
|
||||
:key="index"
|
||||
@@ -221,7 +221,8 @@ export default {
|
||||
query: streamQuery,
|
||||
variables() {
|
||||
return {
|
||||
id: this.streamId
|
||||
id: this.streamId,
|
||||
limit: 100
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -361,7 +362,9 @@ export default {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms))
|
||||
},
|
||||
openInWeb() {
|
||||
window.open(`${localStorage.getItem('serverUrl')}/streams/${this.streamId}`)
|
||||
var url = localStorage.getItem('frontend2') === "true" ? `${localStorage.getItem('serverUrl')}/projects/${this.streamId}` : `${localStorage.getItem('serverUrl')}/streams/${this.streamId}`
|
||||
window.open(url)
|
||||
|
||||
this.$mixpanel.track('Connector Action', { name: 'Open In Web' })
|
||||
},
|
||||
switchBranch(branchName) {
|
||||
@@ -501,13 +504,12 @@ export default {
|
||||
}
|
||||
})
|
||||
console.log('>>> SpeckleSketchUp: Sent to stream: ' + this.streamId, commit)
|
||||
const url = localStorage.getItem('frontend2') === 'true' ? `${localStorage.getItem('serverUrl')}/projects/${this.streamId}/models/${this.selectedBranch.id}@${res.data.commitCreate}` : `${localStorage.getItem('serverUrl')}/streams/${this.streamId}/commits/${res.data.commitCreate}`
|
||||
this.$eventHub.$emit('notification', {
|
||||
text: 'Model selection sent!\n',
|
||||
action: {
|
||||
name: 'View in Web',
|
||||
url: `${localStorage.getItem('serverUrl')}/streams/${this.streamId}/commits/${
|
||||
res.data.commitCreate
|
||||
}`
|
||||
url: url
|
||||
}
|
||||
})
|
||||
this.$apollo.queries.stream.refetch()
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
>
|
||||
mdi-plus-circle
|
||||
</v-icon>
|
||||
{{ `Create New ${isFE2 ? 'Project': 'Stream'}` }}
|
||||
{{ `Create New ${isFE2Terms ? 'Project': 'Stream'}` }}
|
||||
</v-btn>
|
||||
</template>
|
||||
|
||||
<v-card>
|
||||
<v-card-title class="text-h5">
|
||||
{{ `Create a New ${isFE2 ? 'Project' : 'Stream'}` }}
|
||||
{{ `Create a New ${isFE2Terms ? 'Project' : 'Stream'}` }}
|
||||
</v-card-title>
|
||||
<v-container class="px-6" pb-0>
|
||||
<!--
|
||||
@@ -56,7 +56,7 @@
|
||||
hide-details
|
||||
dense
|
||||
flat
|
||||
:placeholder="`${isFE2 ? 'Project' : 'Stream'} Name (Optional)`"
|
||||
:placeholder="`${isFE2Terms ? 'Project' : 'Stream'} Name (Optional)`"
|
||||
/>
|
||||
<v-text-field
|
||||
v-model="description"
|
||||
@@ -68,7 +68,7 @@
|
||||
/>
|
||||
<v-switch
|
||||
v-model="privateStream"
|
||||
:label="`Private ${isFE2 ? 'Project' : 'Stream'}`"
|
||||
:label="`Private ${isFE2Terms ? 'Project' : 'Stream'}`"
|
||||
></v-switch>
|
||||
</v-container>
|
||||
|
||||
@@ -171,7 +171,7 @@ export default {
|
||||
type: String,
|
||||
default: null
|
||||
},
|
||||
isFE2: {
|
||||
isFE2Terms: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
@@ -205,7 +205,14 @@ export default {
|
||||
},
|
||||
async getStream(){
|
||||
try {
|
||||
const streamWrapper = new StreamWrapper(this.createStreamByIdText, this.accountId, this.serverUrl, this.isFE2)
|
||||
const streamWrapper = new StreamWrapper(this.createStreamByIdText, this.accountId, this.serverUrl)
|
||||
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({
|
||||
query: gql`
|
||||
query Stream($id: String!){
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<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>
|
||||
@@ -0,0 +1,6 @@
|
||||
query{
|
||||
serverInfo {
|
||||
name
|
||||
canonicalUrl
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
query Stream($id: String!) {
|
||||
query Stream($id: String!, $limit: Int!) {
|
||||
stream(id: $id) {
|
||||
id
|
||||
name
|
||||
@@ -27,7 +27,7 @@ query Stream($id: String!) {
|
||||
referencedObject
|
||||
}
|
||||
}
|
||||
branches {
|
||||
branches (limit: $limit) {
|
||||
totalCount
|
||||
items {
|
||||
id
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
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,5 +1,5 @@
|
||||
query {
|
||||
user {
|
||||
user:activeUser {
|
||||
id
|
||||
email
|
||||
name
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
query User($id: String!) {
|
||||
user(id: $id) {
|
||||
user:otherUser(id: $id) {
|
||||
id
|
||||
email
|
||||
name
|
||||
bio
|
||||
company
|
||||
avatar
|
||||
verified
|
||||
profiles
|
||||
role
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
require('url')
|
||||
|
||||
export class StreamWrapper {
|
||||
constructor(streamIdOrUrl, accountId, serverUrl, isFE2) {
|
||||
this.isFE2 = isFE2
|
||||
constructor(streamIdOrUrl, accountId, serverUrl) {
|
||||
this.isFE2 = this.checkIsFE2(streamIdOrUrl)
|
||||
this.streamsKey = this.isFE2 ? 'projects/': 'streams/'
|
||||
this.branchesKey = this.isFE2 ? 'models/': 'branches/'
|
||||
this.commitsKey = this.isFE2 ? 'versions/': 'commits/'
|
||||
this.originalOutput = streamIdOrUrl
|
||||
this.originalOutput = streamIdOrUrl
|
||||
try {
|
||||
this.streamWrapperFromUrl(streamIdOrUrl)
|
||||
}
|
||||
@@ -17,6 +17,16 @@ 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){
|
||||
this.url = new URL(streamUrl)
|
||||
this.segments = this.url.pathname.split('/').map((segment) => segment + '/')
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
</div>
|
||||
<div v-if="allStreamsList" class="mt-5">
|
||||
<div v-for="stream in allStreamsList" :key="stream.id">
|
||||
<stream-card :stream-id="stream.id" />
|
||||
<stream-card :stream-id="stream.id"/>
|
||||
</div>
|
||||
<div class="actions text-center">
|
||||
<v-btn
|
||||
@@ -59,7 +59,10 @@ export default {
|
||||
StreamCard: () => import('@/components/StreamCard')
|
||||
},
|
||||
props: {
|
||||
streamSearchQuery: { type: String, default: null }
|
||||
streamSearchQuery: {
|
||||
type: String,
|
||||
default: null
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -121,12 +124,13 @@ export default {
|
||||
if (!this.savedStreams){
|
||||
this.savedStreams = []
|
||||
this.savedStreams.push(streamId)
|
||||
sketchup.exec({name: "save_stream", data: {stream_id: streamId}})
|
||||
} else {
|
||||
if (!this.savedStreams.includes(streamId)){
|
||||
this.savedStreams.push(streamId)
|
||||
sketchup.exec({name: "save_stream", data: {stream_id: streamId}})
|
||||
}
|
||||
}
|
||||
sketchup.exec({name: "save_stream", data: {stream_id: streamId}})
|
||||
})
|
||||
sketchup.exec({name: "load_saved_streams", data: {}})
|
||||
console.log('LAUNCHED')
|
||||
|
||||
@@ -12,7 +12,7 @@ if (process.env.NODE_ENV === 'development') {
|
||||
localStorage.setItem(AUTH_TOKEN, process.env.VUE_APP_DEV_TOKEN)
|
||||
localStorage.setItem('serverUrl', process.env.VUE_APP_DEFAULT_SERVER)
|
||||
} else if (!localStorage.getItem('serverUrl')) {
|
||||
localStorage.setItem('serverUrl', 'https://speckle.xyz')
|
||||
localStorage.setItem('serverUrl', 'https://app.speckle.systems')
|
||||
}
|
||||
|
||||
const authLink = setContext((_, { headers }) => {
|
||||
@@ -34,7 +34,7 @@ const defaultOptions = {
|
||||
return (
|
||||
(localStorage.getItem('serverUrl').includes('http')
|
||||
? localStorage.getItem('serverUrl')
|
||||
: 'https://speckle.xyz') + '/graphql'
|
||||
: 'https://app.speckle.systems') + '/graphql'
|
||||
)
|
||||
},
|
||||
|
||||
@@ -43,7 +43,7 @@ const defaultOptions = {
|
||||
wsEndpoint: (
|
||||
(localStorage.getItem('serverUrl').includes('http')
|
||||
? localStorage.getItem('serverUrl')
|
||||
: 'https://speckle.xyz') + '/graphql'
|
||||
: 'https://app.speckle.systems') + '/graphql'
|
||||
).replace('http', 'ws'),
|
||||
|
||||
// LocalStorage token
|
||||
|
||||
Reference in New Issue
Block a user