Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bd49e19c9e | |||
| 73bcd75b78 | |||
| a0578fa35d | |||
| 7de08d9f24 | |||
| d047f5e6d2 | |||
| 71071f817c | |||
| c7c864b8c0 | |||
| 67d4862f6b | |||
| 6a16327c30 | |||
| 060b1b8f41 | |||
| da2e228293 |
+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
|
||||
|
||||
@@ -31,7 +31,7 @@ What is Speckle? Check our ](https://speckle.xyz) ⇒ creating an account at our public server
|
||||
- [](https://app.speckle.systems) ⇒ creating an account at our public server
|
||||
- [](https://marketplace.digitalocean.com/apps/speckle-server?refcode=947a2b5d7dc1) ⇒ deploying an instance in 1 click
|
||||
|
||||
### Resources
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -13,6 +13,14 @@ 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'
|
||||
|
||||
@@ -75,7 +75,8 @@ module SpeckleConnector
|
||||
# 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.
@@ -2,8 +2,17 @@
|
||||
|
||||
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'
|
||||
@@ -12,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
|
||||
@@ -32,31 +46,82 @@ module SpeckleConnector
|
||||
mapped_selection
|
||||
end
|
||||
|
||||
def self.to_speckle(speckle_state, entity, units, model_preferences, global_transformation: nil, path: nil)
|
||||
speckle_schema = SketchupModel::Dictionary::SpeckleSchemaDictionaryHandler.speckle_schema_to_speckle(entity)
|
||||
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 = 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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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, model_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
|
||||
|
||||
@@ -10,9 +10,6 @@ module SpeckleConnector
|
||||
# Family instance for Revit mappings.
|
||||
class FamilyInstance < Base
|
||||
SPECKLE_TYPE = OBJECTS_BUILTELEMENTS_REVIT_FAMILY_INSTANCE
|
||||
READER = SketchupModel::Reader
|
||||
QUERY = SketchupModel::Query
|
||||
DICTIONARY = SketchupModel::Dictionary
|
||||
|
||||
# rubocop:disable Metrics/ParameterLists
|
||||
def initialize(family:, type:, level:, units:, base_point:, rotation:, application_id: nil)
|
||||
|
||||
@@ -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
|
||||
@@ -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)
|
||||
|
||||
@@ -154,7 +154,7 @@ module SpeckleConnector
|
||||
has_any_soften_edge = face.edges.any?(&:soft?)
|
||||
att = dictionaries.any? ? { is_soften: has_any_soften_edge, dictionaries: dictionaries }
|
||||
: { is_soften: has_any_soften_edge }
|
||||
speckle_schema = Mapper.to_speckle(speckle_state, face, units, model_preferences, global_transformation: global_transform)
|
||||
speckle_schema = Mapper.to_speckle(speckle_state, face, units, global_transformation: global_transform)
|
||||
material = face.material || face.back_material || parent_material
|
||||
speckle_mesh = Mesh.new(
|
||||
units: units,
|
||||
|
||||
@@ -84,7 +84,7 @@ module SpeckleConnector
|
||||
speckle_state = new_speckle_state
|
||||
|
||||
dictionaries = SketchupModel::Dictionary::BaseDictionaryHandler
|
||||
.attribute_dictionaries_to_speckle(component_instance, preferences)
|
||||
.attribute_dictionaries_to_speckle(component_instance, preferences[:model])
|
||||
att = dictionaries.any? ? { dictionaries: dictionaries } : {}
|
||||
speckle_schema = SketchupModel::Dictionary::SpeckleSchemaDictionaryHandler
|
||||
.speckle_schema_to_speckle(component_instance)
|
||||
|
||||
@@ -81,40 +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, &convert)
|
||||
Mapper.convert_mapped_entity(speckle_state, entity_with_path, preferences, units, &convert)
|
||||
end
|
||||
end
|
||||
|
||||
def self.convert_mapped_entity(speckle_state, entity_with_path, preferences, units, &convert)
|
||||
entity = entity_with_path[0]
|
||||
path = entity_with_path[1..-1]
|
||||
method = SPECKLE_SCHEMA_DICTIONARY_HANDLER.get_attribute(entity, 'method')
|
||||
if entity.is_a?(Sketchup::ComponentInstance) && method.nil?
|
||||
method = SPECKLE_SCHEMA_DICTIONARY_HANDLER.get_attribute(entity.definition, 'method')
|
||||
end
|
||||
|
||||
if !method.nil? && (method.include?('Floor') || method.include?('Wall')) && entity.is_a?(Sketchup::Face)
|
||||
global_transformation = QUERY::Entity.global_transformation(entity, path)
|
||||
floor = SpeckleObjects::Geometry::Mesh.from_face(speckle_state: speckle_state, face: entity,
|
||||
units: units, model_preferences: preferences,
|
||||
global_transform: global_transformation)
|
||||
return [floor, [entity]]
|
||||
end
|
||||
|
||||
if method == 'Direct Shape'
|
||||
direct_shape = DIRECT_SHAPE.from_entity(speckle_state, entity, path, units, preferences)
|
||||
return [direct_shape, [entity]]
|
||||
end
|
||||
|
||||
if ['New Revit Family', 'Family Instance'].include?(method)
|
||||
_speckle_state, block_instance = SpeckleObjects::Other::BlockInstance.from_component_instance(
|
||||
entity, units, preferences, speckle_state, path: path, &convert
|
||||
)
|
||||
return [block_instance, [entity]]
|
||||
end
|
||||
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -81,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
|
||||
|
||||
+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
|
||||
+36
-31
@@ -48,21 +48,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,12 +104,12 @@
|
||||
/>
|
||||
</v-container>
|
||||
<create-stream-dialog
|
||||
v-if="accounts().length !== 0"
|
||||
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>
|
||||
<v-container v-if="accounts() && accounts().length !== 0" fluid>
|
||||
<router-view :stream-search-query="streamSearchQuery"/>
|
||||
</v-container>
|
||||
<v-container v-else>
|
||||
@@ -128,6 +132,7 @@
|
||||
/*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";
|
||||
|
||||
@@ -144,18 +149,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) {
|
||||
var account = accounts.find((acct) => acct['userInfo']['id'] === uuid)
|
||||
if (selectedAccountId) {
|
||||
var account = accounts.find((acct) => acct['id'] === selectedAccountId)
|
||||
if (account){
|
||||
global.setSelectedAccount(account)
|
||||
}else{
|
||||
global.setSelectedAccount(accounts.find((acct) => acct['isDefault']))
|
||||
return
|
||||
}
|
||||
} else {
|
||||
global.setSelectedAccount(accounts.find((acct) => acct['isDefault']))
|
||||
}
|
||||
global.setSelectedAccount(accounts.find((acct) => acct['isDefault']))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +166,7 @@ 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')
|
||||
}
|
||||
@@ -205,8 +208,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)
|
||||
@@ -227,32 +241,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);
|
||||
// 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: {}})
|
||||
|
||||
@@ -145,7 +145,8 @@ export default {
|
||||
prefetch: true,
|
||||
variables() {
|
||||
return {
|
||||
id: this.sourceStreamId
|
||||
id: this.sourceStreamId,
|
||||
limit: 100
|
||||
}
|
||||
},
|
||||
skip() {
|
||||
|
||||
@@ -221,7 +221,8 @@ export default {
|
||||
query: streamQuery,
|
||||
variables() {
|
||||
return {
|
||||
id: this.streamId
|
||||
id: this.streamId,
|
||||
limit: 100
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -205,7 +205,14 @@ export default {
|
||||
},
|
||||
async getStream(){
|
||||
try {
|
||||
const streamWrapper = new StreamWrapper(this.createStreamByIdText, this.accountId, this.serverUrl, localStorage.getItem('frontend2') === 'true')
|
||||
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,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,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 + '/')
|
||||
|
||||
@@ -124,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