Compare commits

...

5 Commits

Author SHA1 Message Date
oguzhankoral e71714e282 Set inputs for mapped definition 2024-01-08 16:18:51 +03:00
oguzhankoral a6351659da Use insertion point for instances 2024-01-08 14:33:11 +03:00
oguzhankoral 80f62e6ee4 Fix transformation matrix 2024-01-08 12:17:48 +03:00
oguzhankoral b4761650b9 Calculate rotation of family instance 2023-12-08 02:15:56 +03:00
oguzhankoral 7921ab1f36 Add direct shape option to components back 2023-12-07 21:22:04 +03:00
4 changed files with 34 additions and 7 deletions
@@ -102,12 +102,12 @@ module SpeckleConnector
if source_exist
{
selection: SketchupModel::Reader::MapperReader.entities_schema_details(selection),
mappingMethods: ['New Revit Family', 'Family Instance']
mappingMethods: ['Direct Shape', 'New Revit Family', 'Family Instance']
}.freeze
else
{
selection: SketchupModel::Reader::MapperReader.entities_schema_details(selection),
mappingMethods: ['New Revit Family']
mappingMethods: ['Direct Shape', 'New Revit Family']
}.freeze
end
end
@@ -15,7 +15,7 @@ module SpeckleConnector
DICTIONARY = SketchupModel::Dictionary
# rubocop:disable Metrics/ParameterLists
def initialize(family:, type:, level:, units:, base_point:, application_id: nil)
def initialize(family:, type:, level:, units:, base_point:, rotation:, application_id: nil)
super(
speckle_type: SPECKLE_TYPE,
total_children_count: 0,
@@ -27,6 +27,7 @@ module SpeckleConnector
self[:level] = level
self[:units] = units
self[:basePoint] = base_point
self[:rotation] = rotation
end
# rubocop:enable Metrics/ParameterLists
end
@@ -136,8 +136,11 @@ module SpeckleConnector
type: type,
level: level,
units: units,
base_point: SpeckleObjects::Geometry::Point
.from_vertex(component_instance.bounds.min.transform(transformation), 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
@@ -268,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
+5 -2
View File
@@ -623,8 +623,6 @@ export default {
this.selectedLevel = this.levels[0].name
}
}
console.log(this.selectedFamily, "selectedFamily after")
console.log(this.selectedLevel, "selectedLevel after")
},
hideOptionalMappingInputs(){
this.categorySelectionActive = false
@@ -713,6 +711,11 @@ 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()
}
}