Compare commits

..

6 Commits

Author SHA1 Message Date
oguzhankoral 7b3f2e47bb Pass group selection info if only group selected 2023-12-07 16:09:12 +03:00
oguzhankoral 1a4e3b5a44 Implement family instance mapping 2023-12-07 16:03:02 +03:00
oguzhankoral ed0e1bf249 Set hard coded categories just once and source families when source set/updated 2023-12-07 16:02:37 +03:00
oguzhankoral 5e9566c1d6 Adjust available mapping methods according to selection 2023-12-07 16:01:51 +03:00
oguzhankoral 24ec910735 Filter family types for 'Family Instance' 2023-12-07 16:01:13 +03:00
oguzhankoral e4c53f536d Implement New Revit Family option 2023-12-05 23:05:38 +03:00
6 changed files with 10 additions and 50 deletions
@@ -102,12 +102,12 @@ module SpeckleConnector
if source_exist
{
selection: SketchupModel::Reader::MapperReader.entities_schema_details(selection),
mappingMethods: ['Direct Shape', 'New Revit Family', 'Family Instance']
mappingMethods: ['New Revit Family', 'Family Instance']
}.freeze
else
{
selection: SketchupModel::Reader::MapperReader.entities_schema_details(selection),
mappingMethods: ['Direct Shape', 'New Revit Family']
mappingMethods: ['New Revit Family']
}.freeze
end
end
@@ -64,8 +64,7 @@ module SpeckleConnector
def convert(entity, preferences, speckle_state, parent = :base)
convert = method(:convert)
unless SketchupModel::Reader::MapperReader.mapped_with_schema?(entity) &&
!entity.is_a?(Sketchup::ComponentDefinition)
unless SketchupModel::Reader::MapperReader.mapped_with_schema?(entity)
return from_native_to_speckle(entity, preferences, speckle_state, parent, &convert)
end
@@ -15,7 +15,7 @@ module SpeckleConnector
DICTIONARY = SketchupModel::Dictionary
# rubocop:disable Metrics/ParameterLists
def initialize(family:, type:, level:, units:, base_point:, rotation:, application_id: nil)
def initialize(family:, type:, level:, units:, base_point:, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
@@ -27,7 +27,6 @@ module SpeckleConnector
self[:level] = level
self[:units] = units
self[:basePoint] = base_point
self[:rotation] = rotation
end
# rubocop:enable Metrics/ParameterLists
end
@@ -89,11 +89,6 @@ 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
@@ -136,11 +131,8 @@ module SpeckleConnector
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),
base_point: SpeckleObjects::Geometry::Point
.from_vertex(component_instance.bounds.min.transform(transformation), units),
application_id: component_instance.persistent_id.to_s
)
end
@@ -271,26 +263,6 @@ 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
@@ -89,9 +89,6 @@ module SpeckleConnector
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)
+4 -11
View File
@@ -617,16 +617,14 @@ export default {
}
if (this.selectedMethod){
if (this.selectedFamily === null || this.selectedFamily === undefined){
if (this.inputFamilies[0]){
this.selectedFamily = this.inputFamilies[0]
}
this.selectedFamily = this.inputFamilies[0]
}
if (this.selectedLevel === null || this.selectedLevel === undefined){
if (this.levels[0]){
this.selectedLevel = this.levels[0].name
}
this.selectedLevel = this.levels[0].name
}
}
console.log(this.selectedFamily, "selectedFamily after")
console.log(this.selectedLevel, "selectedLevel after")
},
hideOptionalMappingInputs(){
this.categorySelectionActive = false
@@ -715,11 +713,6 @@ 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()
}
}