Compare commits

...

7 Commits

Author SHA1 Message Date
Oğuzhan Koral 85ee66ca4d Fix(instances): instance name prop is missing (#405)
Build and deploy / build (push) Has been cancelled
Build and deploy / deploy-installers (push) Has been cancelled
* add name to instances

* set name only if it is not empty
2025-03-07 12:04:16 +03:00
Jedd Morgan 5365dc858e Jedd/cxpla 169 update connector deployment ci to error on publishing zero (#404)
* Update deploy.yml

* Update build.yml
2025-03-05 11:47:56 +03:00
Oğuzhan Koral 69f9544638 get accounts always from sqlite - not from cached state (#403)
Build and deploy / build (push) Has been cancelled
Build and deploy / deploy-installers (push) Has been cancelled
2025-02-27 14:57:28 +03:00
Oğuzhan Koral bf5409cf90 Feat(dui3): add properties (#402)
Build and deploy / build (push) Has been cancelled
Build and deploy / deploy-installers (push) Has been cancelled
* rename sketchup_attributes with properties for send

* receive properties

* handle send receive properties
2025-02-18 22:32:05 +03:00
Oğuzhan Koral bd4f668526 Make selection is default (#401)
Build and deploy / build (push) Has been cancelled
Build and deploy / deploy-installers (push) Has been cancelled
2025-01-16 19:34:16 +03:00
Oğuzhan Koral d21df0c6fd Update build.yml
Build and deploy / build (push) Has been cancelled
Build and deploy / deploy-installers (push) Has been cancelled
2024-12-20 17:33:55 +03:00
Oğuzhan Koral d808fdaa09 Update build.yml 2024-12-20 17:31:44 +03:00
16 changed files with 91 additions and 24 deletions
+4
View File
@@ -31,6 +31,8 @@ jobs:
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v3.0.0
with:
versionSpec: 6.0.5 # github actions doesnt like 6.1.0 onwards https://github.com/GitTools/actions/blob/main/docs/versions.md
- name: Determine Version
id: gitversion
@@ -48,6 +50,8 @@ jobs:
with:
name: output-${{steps.gitversion.outputs.semVer}}
path: sketchup.zip
retention-days: 1
if-no-files-found: error
compression-level: 0 # no compression
- id: set-version
name: Set version to output
+3
View File
@@ -31,3 +31,6 @@ jobs:
wait-for-completion-timeout: 10m
display-workflow-run-url: true
display-workflow-run-url-interval: 10s
- uses: geekyeggo/delete-artifact@v5
with:
name: output-*
@@ -12,7 +12,7 @@ module SpeckleConnector3
# @return [States::State] the new updated state object
def self.update_state(state, resolve_id)
puts 'Initialisation of Speckle accounts requested by plugin'
accounts_data = state.speckle_state.accounts
accounts_data = SpeckleConnector3::Accounts.load_accounts
js_script = "accountsBinding.receiveResponse('#{resolve_id}', #{accounts_data.to_json})"
state.with_add_queue_js_command('getAccounts', js_script)
end
@@ -153,6 +153,11 @@ module SpeckleConnector3
definition_name = proxy['name']
definition = state.sketchup_state.sketchup_model.definitions.add(definition_name)
properties = proxy['properties'] || proxy['sketchup_attributes']
unless properties.nil?
SketchupModel::Dictionary::BaseDictionaryHandler
.attribute_dictionaries_to_native(definition, properties['dictionaries'])
end
definition.behavior.always_face_camera = proxy['alwaysFaceCamera'] if proxy['alwaysFaceCamera']
@definition_proxies[proxy['applicationId']] = SpeckleObjects::InstanceDefinitionProxy.new(
definition,
@@ -16,6 +16,7 @@ module SpeckleConnector3
super('selection', 'Selection', nil, summary)
@selected_object_ids = selected_object_ids
self[:selectedObjectIds] = selected_object_ids
self[:isDefault] = true # hard coded default value, that's fair
end
def check_expiry(ids)
@@ -46,11 +46,17 @@ module SpeckleConnector3
instance_id = entity.persistent_id.to_s
definition_id = entity.definition.persistent_id.to_s
instance_dictionaries = SketchupModel::Dictionary::BaseDictionaryHandler
.attribute_dictionaries_to_speckle(entity)
instance_att = instance_dictionaries.any? ? { dictionaries: instance_dictionaries } : {}
instance_proxies[instance_id] = SpeckleObjects::InstanceProxy.new(
definition_id,
entity.name,
SpeckleObjects::Other::Transform.from_transformation(entity.transformation, @units).value,
depth,
@units,
sketchup_attributes: instance_att,
application_id: instance_id
)
@@ -70,7 +76,17 @@ module SpeckleConnector3
return
end
definition_proxy = SpeckleObjects::InstanceDefinitionProxy.new(entity.definition, [], depth, application_id: definition_id)
definition_dictionaries = SketchupModel::Dictionary::BaseDictionaryHandler
.attribute_dictionaries_to_speckle(entity.definition)
definition_att = definition_dictionaries.any? ? { dictionaries: definition_dictionaries } : {}
definition_proxy = SpeckleObjects::InstanceDefinitionProxy.new(
entity.definition,
[],
depth,
sketchup_attributes: definition_att,
application_id: definition_id
)
definition_proxy[:name] = entity.definition.name
definition_proxy[:description] = entity.definition.description
@@ -16,7 +16,20 @@ module SpeckleConnector3
].freeze
# @param entity [Sketchup::Entity] entity to get attribute dictionaries
def self.attribute_dictionaries_to_speckle(entity, model_preferences)
def self.attribute_dictionaries_to_speckle(entity)
dictionaries = {}
return dictionaries if entity.attribute_dictionaries.nil?
entity.attribute_dictionaries.each do |att_dict|
dict_name = att_dict == '' ? 'empty_dictionary_name' : att_dict.name
dictionaries[dict_name] = att_dict.to_h unless IGNORED_DICTIONARY_NAMES.include?(att_dict.name)
end
dictionaries
end
# @param entity [Sketchup::Entity] entity to get attribute dictionaries
# @note v2 logic
def self.attribute_dictionaries_to_speckle_by_settings(entity, model_preferences)
dictionaries = {}
return dictionaries unless model_preferences[INCLUDE_ENTITY_ATTRIBUTES]
@@ -36,7 +36,7 @@ module SpeckleConnector3
self[:units] = units
self[:layer] = layer unless layer.nil?
self['@SpeckleSchema'] = speckle_schema if speckle_schema.any?
self[:sketchup_attributes] = sketchup_attributes if sketchup_attributes.any?
self[:properties] = sketchup_attributes if sketchup_attributes.any?
end
# rubocop:enable Metrics/ParameterLists
@@ -59,7 +59,7 @@ module SpeckleConnector3
# @param edge [Sketchup::Edge] edge to convert line.
def self.from_edge(speckle_state:, edge:, units:, model_preferences:, global_transformation: nil)
dictionaries = SketchupModel::Dictionary::BaseDictionaryHandler
.attribute_dictionaries_to_speckle(edge, model_preferences)
.attribute_dictionaries_to_speckle_by_settings(edge, model_preferences)
att = dictionaries.any? ? { dictionaries: dictionaries } : {}
speckle_schema = Mapper.to_speckle(speckle_state, edge, units, global_transformation: global_transformation)
start_pt = Geometry::Point.from_vertex(edge.start.position, units)
@@ -141,7 +141,10 @@ module SpeckleConnector3
edges.each do |edge|
edge.layer = layer
# edge.layer = line_layer.nil? ? layer : line_layer
unless line['sketchup_attributes'].nil?
if !line['properties'].nil?
SketchupModel::Dictionary::BaseDictionaryHandler
.attribute_dictionaries_to_native(edge, line['properties']['dictionaries'])
elsif !line['sketchup_attributes'].nil? # backward compatibility
SketchupModel::Dictionary::BaseDictionaryHandler
.attribute_dictionaries_to_native(edge, line['sketchup_attributes']['dictionaries'])
end
@@ -49,7 +49,7 @@ module SpeckleConnector3
# self[:renderMaterial] = render_material
self[:'@(31250)vertices'] = vertices
self[:'@(62500)faces'] = faces
self[:sketchup_attributes] = sketchup_attributes if sketchup_attributes.any?
self[:properties] = sketchup_attributes if sketchup_attributes.any?
self['@SpeckleSchema'] = speckle_schema if speckle_schema.any?
end
# rubocop:enable Metrics/ParameterLists
@@ -129,7 +129,10 @@ module SpeckleConnector3
# Smooth edges if they already soft
# FIXME: Below line should be reconsidered. It might be a good to know here mesh comes from NURBS or not.
face.edges.each { |edge| edge.smooth = true if edge.soft? } if has_any_non_planar_quad_mesh
unless mesh['sketchup_attributes'].nil?
if !mesh['properties'].nil?
SketchupModel::Dictionary::BaseDictionaryHandler
.attribute_dictionaries_to_native(face, mesh['properties']['dictionaries'])
elsif !mesh['sketchup_attributes'].nil? # backward compatibility
SketchupModel::Dictionary::BaseDictionaryHandler
.attribute_dictionaries_to_native(face, mesh['sketchup_attributes']['dictionaries'])
end
@@ -151,7 +154,7 @@ module SpeckleConnector3
# rubocop:disable Metrics/ParameterLists
def self.from_face(speckle_state:, face:, units:, model_preferences:, global_transform: nil, parent_material: nil)
dictionaries = SketchupModel::Dictionary::BaseDictionaryHandler
.attribute_dictionaries_to_speckle(face, model_preferences)
.attribute_dictionaries_to_speckle_by_settings(face, model_preferences)
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 }
@@ -278,7 +281,9 @@ module SpeckleConnector3
# @param mesh [Object] speckle mesh object
# @param entities [Sketchup::Entities] sketchup entities that mesh will be created in it as face.
def self.get_soften_setting(mesh, entities)
unless mesh['sketchup_attributes'].nil?
if !mesh['properties'].nil?
return mesh['properties']['is_soften'].nil? ? true : mesh['properties']['is_soften']
elsif !mesh['sketchup_attributes'].nil? # backward compatibility
return mesh['sketchup_attributes']['is_soften'].nil? ? true : mesh['sketchup_attributes']['is_soften']
end
@@ -55,7 +55,7 @@ module SpeckleConnector3
geometries.each do |geo|
if geo['speckle_type'] && geo['speckle_type'] == OBJECTS_GEOMETRY_MESH
geo['sketchup_attributes'] = { 'is_soften' => false }
geo['properties'] = { 'is_soften' => false }
end
end
@@ -57,7 +57,7 @@ module SpeckleConnector3
geometries.each do |geo|
if geo['speckle_type'] && geo['speckle_type'] == OBJECTS_GEOMETRY_MESH
geo['sketchup_attributes'] = { 'is_soften' => false }
geo['properties'] = { 'is_soften' => false }
end
end
@@ -20,7 +20,7 @@ module SpeckleConnector3
# @param object_ids [Array<String>]
# @param max_depth [Integer]
# @param application_id [String | NilClass]
def initialize(definition, object_ids, max_depth, application_id: nil)
def initialize(definition, object_ids, max_depth, sketchup_attributes: {}, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
application_id: application_id,
@@ -31,6 +31,7 @@ module SpeckleConnector3
self[:objects] = object_ids
self[:maxDepth] = max_depth
self[:alwaysFaceCamera] = definition.behavior.always_face_camera?
self[:properties] = sketchup_attributes if sketchup_attributes.any?
end
def add_object_id(object_id)
@@ -8,24 +8,35 @@ module SpeckleConnector3
module SpeckleObjects
class InstanceProxy < Base
SPECKLE_TYPE = SPECKLE_CORE_MODELS_INSTANCES_INSTANCE_PROXY
def initialize(definition_id, transform, max_depth, units, application_id: nil)
def initialize(definition_id, name, transform, max_depth, units, sketchup_attributes: {}, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
application_id: application_id,
id: nil
)
self[:name] = name if name != ""
self[:units] = units
self[:definitionId] = definition_id
self[:maxDepth] = max_depth
self[:transform] = transform
self[:properties] = sketchup_attributes if sketchup_attributes.any?
end
def self.to_native(state, instance_proxy, layer, entities, definition_proxies, &_convert_to_native)
definition_id = instance_proxy['definitionId']
proxy_transform = instance_proxy['transform']
name = instance_proxy['name']
transform = Other::Transform.to_native(proxy_transform, instance_proxy['units'])
definition = definition_proxies[definition_id].definition
instance = entities.add_instance(definition, transform)
instance.name = name if name
unless instance_proxy['properties'].nil?
SketchupModel::Dictionary::BaseDictionaryHandler
.attribute_dictionaries_to_native(instance, instance_proxy['properties']['dictionaries'])
end
instance.layer = layer if layer # TODO: CONVERTER_V2 check
# TODO: CONVERTER_V2 handle groups
return state, [instance, definition]
@@ -32,7 +32,7 @@ module SpeckleConnector3
self[:units] = units
self[:name] = name
self[:always_face_camera] = always_face_camera
self[:sketchup_attributes] = sketchup_attributes if sketchup_attributes.any?
self[:properties] = sketchup_attributes if sketchup_attributes.any?
self[:SpeckleSchema] = speckle_schema if speckle_schema.any?
# '@@' means that it is a detached property.
self['@@geometry'] = geometry
@@ -47,7 +47,7 @@ module SpeckleConnector3
# rubocop:disable Metrics/ParameterLists
def self.from_definition(definition, units, preferences, speckle_state, parent, &convert)
dictionaries = SketchupModel::Dictionary::BaseDictionaryHandler
.attribute_dictionaries_to_speckle(definition, preferences[:model])
.attribute_dictionaries_to_speckle_by_settings(definition, preferences[:model])
att = dictionaries.any? ? { dictionaries: dictionaries } : {}
speckle_schema = SketchupModel::Dictionary::SpeckleSchemaDictionaryHandler
.speckle_schema_to_speckle(definition)
@@ -118,7 +118,7 @@ module SpeckleConnector3
geometry = definition_obj['geometry'] || definition_obj['@geometry'] || definition_obj['displayValue']
always_face_camera = definition_obj['always_face_camera'].nil? ? false : definition_obj['always_face_camera']
sketchup_attributes = definition_obj['sketchup_attributes']
properties = definition_obj['properties'] || definition_obj['sketchup_attributes']
definition&.entities&.clear!
definition ||= sketchup_model.definitions.add(definition_name)
@@ -143,9 +143,9 @@ module SpeckleConnector3
# puts("definition finished: #{name} (#{application_id})")
# puts(" entity count: #{definition.entities.count}")
definition.behavior.always_face_camera = always_face_camera
unless sketchup_attributes.nil?
unless properties.nil?
SketchupModel::Dictionary::BaseDictionaryHandler
.attribute_dictionaries_to_native(definition, sketchup_attributes['dictionaries'])
.attribute_dictionaries_to_native(definition, properties['dictionaries'])
end
return state, [definition]
end
@@ -40,7 +40,7 @@ module SpeckleConnector3
self[:is_sketchup_group] = is_sketchup_group
# self[:renderMaterial] = render_material
self[:transform] = transform
self[:sketchup_attributes] = sketchup_attributes if sketchup_attributes.any?
self[:properties] = sketchup_attributes if sketchup_attributes.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
@@ -53,7 +53,7 @@ module SpeckleConnector3
group.persistent_id.to_s)
speckle_state = new_speckle_state
dictionaries = SketchupModel::Dictionary::BaseDictionaryHandler
.attribute_dictionaries_to_speckle(group, preferences[:model])
.attribute_dictionaries_to_speckle_by_settings(group, preferences[:model])
att = dictionaries.any? ? { dictionaries: dictionaries } : {}
speckle_schema = SketchupModel::Dictionary::SpeckleSchemaDictionaryHandler.speckle_schema_to_speckle(group)
block_instance = BlockInstance.new(
@@ -83,7 +83,7 @@ module SpeckleConnector3
speckle_state = new_speckle_state
dictionaries = SketchupModel::Dictionary::BaseDictionaryHandler
.attribute_dictionaries_to_speckle(component_instance, preferences[:model])
.attribute_dictionaries_to_speckle_by_settings(component_instance, preferences[:model])
att = dictionaries.any? ? { dictionaries: dictionaries } : {}
speckle_schema = SketchupModel::Dictionary::SpeckleSchemaDictionaryHandler
.speckle_schema_to_speckle(component_instance)
@@ -245,10 +245,15 @@ module SpeckleConnector3
end
instance.name = block['name'] unless block['name'].nil?
unless block['sketchup_attributes'].nil?
if !block['properties'].nil?
SketchupModel::Dictionary::BaseDictionaryHandler
.attribute_dictionaries_to_native(instance, block['properties']['dictionaries'])
elsif !block['sketchup_attributes'].nil? # backward compatibility
SketchupModel::Dictionary::BaseDictionaryHandler
.attribute_dictionaries_to_native(instance, block['sketchup_attributes']['dictionaries'])
end
return state, [instance, definition]
end
# rubocop:enable Metrics/AbcSize
@@ -32,7 +32,7 @@ module SpeckleConnector3
self[:emissive] = emissive
self[:metalness] = metalness
self[:roughness] = roughness
self[:sketchup_attributes] = sketchup_attributes
self[:properties] = sketchup_attributes
end
# rubocop:enable Metrics/ParameterLists