Compare commits

..

41 Commits

Author SHA1 Message Date
Claire Kuang 94de06e842 Update SpecklePropertyGoo.cs 2025-06-30 15:08:43 +01:00
Björn Steinhagen 641f6fcc76 fix(grasshopper): prevent duplicate nested block instances in receive (#958)
* fix: `consumedObjectIds` tracking preventing duplicate nested block instances

* refactor: remove redundant `isDefinitionObject` logic
2025-06-30 13:48:10 +01:00
Björn Steinhagen 65313008a4 fix(grasshopper): receive pipeline polish (#957)
* fix: loading, publish and query

* docs: explanations

* fix: format

* docs: remove old comment

---------

Co-authored-by: Claire Kuang <kuang.claire@gmail.com>
2025-06-29 16:19:47 +02:00
Claire Kuang f5ad1cff39 fix(grasshopper): a bunch of instance vs object casting issues (#954)
* adds instance converter and filter objects casting helper

* adds missing casting an fixes casting to speckle object passthrough

* cleans up more casting logic

* more casting fixes

* Update InstanceReferenceGeometryToSpeckleConverter.cs

* fixes goos inputs and outputs for expand collection, query, filter, etc

* removes deep copying from casting

* more mutations on object passthrough

* fixes missing model object instance  casting properties

* fixes build

* model instance and def casting issues for nesting

* im literally crying

* Update InstanceReferenceGeometryToSpeckleConverter.cs

* fix: POC disabling cyclomatic complexity

* refactors speckle object code to reduce complexity

* further strips model object casting since rhino objects can be passed as model objects

* light at the end of the tunnel

* last commit i swear

fixes model insstance casting since this actually registers as IGH_GeometricGoo of type reference

* last LAST commit on god

---------

Co-authored-by: Björn Steinhagen <steinhagen.bjoern@gmail.com>
2025-06-29 11:47:26 +02:00
Claire Kuang 5670b8e99e Merge branch 'dev' into bjorn/cnx-1625-blocks-in-gh8 2025-06-27 20:06:26 +01:00
Björn 39c4f2c7d4 chore: removing todo comments 2025-06-26 23:09:49 +02:00
Björn Steinhagen c2bb8b319d fix(grasshopper): improve block instance preview for nested instances (#951)
* fix: display block instances

- problem on deeply nested instances
- good poc

* chore: missing method in block definition

* fix: re-instating changes after param classes refactor

* fix: add 3-level depth limit for block instance DrawPreview methods

* fixes collection preview and some isvalid props

---------

Co-authored-by: Claire Kuang <kuang.claire@gmail.com>
2025-06-26 17:46:34 +01:00
Björn 2e2c8e1732 fix: throw if id null
review comment
2025-06-26 17:18:04 +02:00
Björn 6e6e737807 fix: auto-sync block instance definition references 2025-06-26 16:55:01 +02:00
Björn 8c8320ea75 fix: url broken 2025-06-26 15:54:24 +02:00
Björn 4d81bce0ea fix: preserve id in SpeckleBlockInstanceWrapper round-trip casting 2025-06-26 14:00:02 +02:00
Björn d513187acd fix: SpeckleBlockInstanceWrapper inheritance in DeepCopy() 2025-06-26 12:59:41 +02:00
Björn af3810bc98 chore: xml comment on the parameterless constructor 2025-06-26 11:14:04 +02:00
Claire Kuang 02f3c1c3fa Merge branch 'dev' into bjorn/cnx-1625-blocks-in-gh8 2025-06-26 01:58:20 +01:00
Claire Kuang 31c63cce22 moves all param classes to their own file (#950) 2025-06-26 01:37:43 +01:00
Claire Kuang f94acec6a5 adds create goo to wrapper class
also adds missing instance casting to create collection
2025-06-25 22:01:01 +01:00
Björn Steinhagen 093dbc826b feat(grasshopper): update load to handle blocks (#947)
* feat: block recognition in receive pipeline

* feat: `GrasshopperBlockUnpacker`

* feat: working nested blocks and removing `LocalToGlobalUnpacker`

* chore: cleanup

* refactor: remove unnecessary check

* refactor: better naming

* pr review fixes

* adds colors and materials to instance and defs on load

---------

Co-authored-by: Claire Kuang <kuang.claire@gmail.com>
2025-06-25 16:32:13 +01:00
Claire Kuang 5edaee1fa8 feat(grasshopper): adds color and materials to instances (#945)
* adds color and materials to instances

also includes refactoring for passthrough nodes

* some more appid and name changes

* removes unnecessary casting

also fixes some bugs with missing applicationIds on cast

* Update SpeckleBlockInstanceWrapper.ModelObjects.cs

* Update SpeckleBlockInstancePassthrough.cs

* fixes broken url
2025-06-25 14:26:09 +01:00
Claire Kuang 54b14b8bc9 fix dev merge changes 2025-06-25 11:20:26 +01:00
Claire Kuang a7ab4915c3 Merge branch 'dev' into bjorn/cnx-1625-blocks-in-gh8 2025-06-25 11:09:21 +01:00
Björn 03d231b056 Merge branch 'dev' into bjorn/cnx-1625-blocks-in-gh8 2025-06-23 15:31:27 +02:00
Björn Steinhagen 445e10dbb4 feat(grasshopper): nested block support (#934) 2025-06-23 14:55:47 +02:00
Björn c58a8d2757 Merge branch 'dev' into bjorn/cnx-1625-blocks-in-gh8 2025-06-23 12:31:31 +02:00
Claire Kuang dfb75d98c1 adds new icons for blocks 2025-06-18 20:11:35 +01:00
Claire Kuang a93f9e9c42 Merge branch 'dev' into bjorn/cnx-1625-blocks-in-gh8 2025-06-18 19:51:58 +01:00
Björn cd8dab48ae Merge remote-tracking branch 'origin/dev' into bjorn/cnx-1625-blocks-in-gh8 2025-06-17 16:22:12 +02:00
Björn Steinhagen a78c8962be refactor(grasshopper): make SpeckleBlockInstanceWrapper inherit from SpeckleObjectWrapper (#917)
* feat: first pass

* fix: deconstruct speckle params

* refactor: cleanup

* docs: `GeometryBase`note on `SpeckleBlockInstanceWrapper`

* refactor: CreateGoo() to remove type checking in ExpandCollection

* refactor: incorporating pr comments

* fixes deconstruct component

adds removed support for materials and collections

consolidates logic for name and output creation

---------

Co-authored-by: Claire Kuang <kuang.claire@gmail.com>
2025-06-17 16:19:08 +02:00
Claire Kuang a91ecd9e88 Merge branch 'dev' into bjorn/cnx-1625-blocks-in-gh8 2025-06-16 20:37:05 +01:00
Björn 0ed086d336 fix: still need explicit cases 2025-06-12 19:26:17 +02:00
Björn 9132514d86 fix: compiler errors 2025-06-12 11:20:58 +02:00
Björn f5c0a9eb96 refactor: SpeckleBlockInstanceWrapper to use BakingHelper 2025-06-12 11:14:45 +02:00
Björn 5d4b08d1d4 Merge remote-tracking branch 'origin/bjorn/cnx-1625-blocks-in-gh8' into bjorn/cnx-1625-blocks-in-gh8 2025-06-12 11:14:08 +02:00
Björn e0148aba62 fix: removing unresolved references
`ISpeckleGoo` removed on `props` pr
2025-06-12 11:13:50 +02:00
Claire Kuang 221371d668 Update Helpers.cs 2025-06-12 09:50:30 +01:00
Claire Kuang 7206a4477c Update Helpers.cs 2025-06-12 09:42:04 +01:00
Claire Kuang e0f042615b Merge branch 'dev' into bjorn/cnx-1625-blocks-in-gh8 2025-06-12 09:41:43 +01:00
Björn Steinhagen 9482d1fe83 feat (grasshopper): update publish to handle block instances and definitions (#909)
* feat: add `SpeckleBlockInstanceWrapper` class

empty

* chore: adds `SpeckleBlockInstanceWrapperGoo`

* chore: adds `SpeckleBlockInstanceParameters`

* chore: `SpeckleBlockInstanceWrapper` wrapped `Base` is `InstanceProxy`

* docs: tiny typo

* feat: `SpeckleBlockInstanceWrapper` and parameters

* fix: missing default constructor and naming refactor

* feat: initial commit for `SpeckleBlockDefinitionWrapper`

* Revert "feat: initial commit for `SpeckleBlockDefinitionWrapper`"

This reverts commit a3c1fcf978.

* fix: `SpeckleBlockInstanceWrapper`

- `type` correction for `Properties`
- keeping transforms in sync (kinda, waiting for PR merge)
- `DeepCopy()`

* fix: `SpeckleBlockInstanceWrapperGoo`

- `CastFrom`and `CastTo`methods
- `Duplicate` method

* fix: `SpeckleBlockInstanceParam`

- adds missing implementations

* feat: placeholders for `Bake` and `DrawPreview`

* feat: `CreateSpeckleBlockInstance`

* feat: `ModelObjects`

* fix: Rhino7 preprocessor directives

* fix: casting for GH created / referenced instances

* fix: `Transform` casting

* chore: icon for `CreateSpeckleBlockInstance`

* feat: casting to and from `CreateSpeckleBlockInstance`

* chore: removing redundant code

* feat: validating `SpeckleWrapper`

* chore: updates to `.ToString()`

* fix: recompute when `doc` definition changes

* refactor: `!string.IsNullOrWhiteSpace()`

* feat: deconstruct

* fix: cast for `RhinoObject`

* refactor: consolidate duplicate baking code

* Cleans up casting logic in instance and definitions

* refactor: `RhinoObject` coming from referenced instances

* docs: comments

* refactor: code clean up for `ModelInstanceDefinition`

* refactor: consistency across wrappers

* fix: intercept block definitions from pure gh

* docs: gh defined model block definition

* docs: api limitation on `ModelInstanceDefinition` constructor

* fix: stop instances from overwriting shared block definitions on bake

* feat: disallowing block definitions in collections for now

* feat: baking instances within collection

* feat: update publish to handle block instances and definitions

* refactpr: consolidating switch statements

* feat: runtime message on unsupported inputs for creating collections

* docs: `GrasshopperBlockPacker`

---------

Co-authored-by: Claire Kuang <kuang.claire@gmail.com>
2025-06-11 19:51:07 +02:00
Björn Steinhagen 6797f4baa4 feat(grasshopper): add SpeckleBlockInstance support (#893)
* feat: add `SpeckleBlockInstanceWrapper` class

empty

* chore: adds `SpeckleBlockInstanceWrapperGoo`

* chore: adds `SpeckleBlockInstanceParameters`

* chore: `SpeckleBlockInstanceWrapper` wrapped `Base` is `InstanceProxy`

* docs: tiny typo

* feat: `SpeckleBlockInstanceWrapper` and parameters

* fix: missing default constructor and naming refactor

* feat: initial commit for `SpeckleBlockDefinitionWrapper`

* Revert "feat: initial commit for `SpeckleBlockDefinitionWrapper`"

This reverts commit a3c1fcf978.

* fix: `SpeckleBlockInstanceWrapper`

- `type` correction for `Properties`
- keeping transforms in sync (kinda, waiting for PR merge)
- `DeepCopy()`

* fix: `SpeckleBlockInstanceWrapperGoo`

- `CastFrom`and `CastTo`methods
- `Duplicate` method

* fix: `SpeckleBlockInstanceParam`

- adds missing implementations

* feat: placeholders for `Bake` and `DrawPreview`

* feat: `CreateSpeckleBlockInstance`

* feat: `ModelObjects`

* fix: Rhino7 preprocessor directives

* fix: casting for GH created / referenced instances

* fix: `Transform` casting

* chore: icon for `CreateSpeckleBlockInstance`

* feat: casting to and from `CreateSpeckleBlockInstance`

* chore: removing redundant code

* feat: validating `SpeckleWrapper`

* chore: updates to `.ToString()`

* fix: recompute when `doc` definition changes

* refactor: `!string.IsNullOrWhiteSpace()`

* feat: deconstruct

* fix: cast for `RhinoObject`

* refactor: consolidate duplicate baking code

* Cleans up casting logic in instance and definitions

* refactor: `RhinoObject` coming from referenced instances

* docs: comments

* refactor: code clean up for `ModelInstanceDefinition`

* refactor: consistency across wrappers

* fix: intercept block definitions from pure gh

* docs: gh defined model block definition

* docs: api limitation on `ModelInstanceDefinition` constructor

* fix: stop instances from overwriting shared block definitions on bake

* feat: disallowing block definitions in collections for now

* feat: baking instances within collection

---------

Co-authored-by: Claire Kuang <kuang.claire@gmail.com>
2025-06-11 16:46:52 +02:00
Björn 751170acf8 Merge remote-tracking branch 'origin/dev' into bjorn/cnx-1625-blocks-in-gh8 2025-06-04 16:28:29 +02:00
Björn Steinhagen 6241780615 feat(grasshopper): add SpeckleBlockDefinition support (#891)
* feat: initial commit `SpeckleBlockDefinitionWrapper`

* feat: `SpeckleBlockDefinitionWrapper``Bake`and `DrawPreview`

* feat: Casting for `SpeckleBlockDefinitionWrapperGoo`

* feat: `SpeckleBlockDefinitionParam` functionality to `BakeGeometry`

* feat: `CreateSpeckleBlockDefinition`

* fix: casting and other things

* fix: defining objects of a definition, not all instance objects (LOL)

* refactor: preview

- still not previewing nicely though

* refactor: transform in helpers class

* chore: `CreateSpeckleBlockDefinition` icon

* docs: pr comment re. api limitation
2025-06-04 16:26:18 +02:00
Björn 0136d3fa13 Merge remote-tracking branch 'origin/dev' into bjorn/cnx-1625-blocks-in-gh8 2025-06-03 22:00:06 +02:00
337 changed files with 2714 additions and 10869 deletions
+4 -4
View File
@@ -7,12 +7,12 @@ jobs:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v5
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v5
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.4xx # Align with global.json (including roll forward rules)
@@ -28,12 +28,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v5
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.4xx # Align with global.json (including roll forward rules)
+4 -4
View File
@@ -16,12 +16,12 @@ jobs:
file_version: ${{ steps.set-version.outputs.file_version }}
steps:
- name: Checkout
uses: actions/checkout@v5
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v5
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.4xx # Align with global.json (including roll forward rules)
@@ -83,12 +83,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v5
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.4xx # Align with global.json (including roll forward rules)
@@ -259,9 +259,9 @@
"dependencies": {
"Microsoft.Extensions.DependencyInjection": "[2.2.0, )",
"Speckle.Connectors.Logging": "[1.0.0, )",
"Speckle.Objects": "[3.5.3, )",
"Speckle.Sdk": "[3.5.3, )",
"Speckle.Sdk.Dependencies": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )",
"Speckle.Sdk": "[3.4.3, )",
"Speckle.Sdk.Dependencies": "[3.4.3, )"
}
},
"speckle.connectors.dui": {
@@ -292,7 +292,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Speckle.Objects": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )"
}
},
"Microsoft.Extensions.DependencyInjection": {
@@ -336,18 +336,18 @@
},
"Speckle.Objects": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "T3xwwoALVGmhIuEjlDrTdDXZ9haFILT32r8OACWrRUItU3xMkOWGyob51Ca1MHPmo8B5gvbk2Gnm8AgReGnxWg==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "08BOhVaYUvFP8CgY5fGZJWvswIRsH2EbOBGguJnanx+RZqKYI9XJroGGew+CDfPU1c8ZWl37WX2bbdPhdSP2rQ==",
"dependencies": {
"Speckle.Sdk": "3.5.3"
"Speckle.Sdk": "3.4.3"
}
},
"Speckle.Sdk": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "o+HefwtPZBqyuUHEnKF+qb/ctCAlNc2BYIw3ULEsZ93zweHt5wOMvOeuPxIXR0Gvj3fg6yNlY2nUcdFEduIXYA==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "21Dg8kMOqUbV7jyhK7N+UwyO7S1++COMR5jU9mm/vx86pkj6pTAifNZMHmuG8/ZnwpBcUCmE4AzvW24mKlgEkg==",
"dependencies": {
"GraphQL.Client": "6.0.0",
"Microsoft.Bcl.AsyncInterfaces": "5.0.0",
@@ -357,14 +357,14 @@
"Microsoft.Extensions.Logging": "2.2.0",
"Speckle.DoubleNumerics": "4.1.0",
"Speckle.Newtonsoft.Json": "13.0.2",
"Speckle.Sdk.Dependencies": "3.5.3"
"Speckle.Sdk.Dependencies": "3.4.3"
}
},
"Speckle.Sdk.Dependencies": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "kC15SE4yZoVTasgywCm0SpY9yjBsQeUIDt4qoscYAgbn9pe0jj3uM0hZeJUCxn9Fdoj64OfQBpCKzR7VqhkwHQ=="
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "PyJAt9WAeVLUfxp/l1ZvGw20HAsvfBY/JgZCJmY5doc8lFa/9dhUMBJN/cNsVM5XJK+xdIBoEemgl3SMFwXNcg=="
}
}
}
@@ -259,9 +259,9 @@
"dependencies": {
"Microsoft.Extensions.DependencyInjection": "[2.2.0, )",
"Speckle.Connectors.Logging": "[1.0.0, )",
"Speckle.Objects": "[3.5.3, )",
"Speckle.Sdk": "[3.5.3, )",
"Speckle.Sdk.Dependencies": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )",
"Speckle.Sdk": "[3.4.3, )",
"Speckle.Sdk.Dependencies": "[3.4.3, )"
}
},
"speckle.connectors.dui": {
@@ -292,7 +292,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Speckle.Objects": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )"
}
},
"Microsoft.Extensions.DependencyInjection": {
@@ -336,18 +336,18 @@
},
"Speckle.Objects": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "T3xwwoALVGmhIuEjlDrTdDXZ9haFILT32r8OACWrRUItU3xMkOWGyob51Ca1MHPmo8B5gvbk2Gnm8AgReGnxWg==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "08BOhVaYUvFP8CgY5fGZJWvswIRsH2EbOBGguJnanx+RZqKYI9XJroGGew+CDfPU1c8ZWl37WX2bbdPhdSP2rQ==",
"dependencies": {
"Speckle.Sdk": "3.5.3"
"Speckle.Sdk": "3.4.3"
}
},
"Speckle.Sdk": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "o+HefwtPZBqyuUHEnKF+qb/ctCAlNc2BYIw3ULEsZ93zweHt5wOMvOeuPxIXR0Gvj3fg6yNlY2nUcdFEduIXYA==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "21Dg8kMOqUbV7jyhK7N+UwyO7S1++COMR5jU9mm/vx86pkj6pTAifNZMHmuG8/ZnwpBcUCmE4AzvW24mKlgEkg==",
"dependencies": {
"GraphQL.Client": "6.0.0",
"Microsoft.Bcl.AsyncInterfaces": "5.0.0",
@@ -357,14 +357,14 @@
"Microsoft.Extensions.Logging": "2.2.0",
"Speckle.DoubleNumerics": "4.1.0",
"Speckle.Newtonsoft.Json": "13.0.2",
"Speckle.Sdk.Dependencies": "3.5.3"
"Speckle.Sdk.Dependencies": "3.4.3"
}
},
"Speckle.Sdk.Dependencies": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "kC15SE4yZoVTasgywCm0SpY9yjBsQeUIDt4qoscYAgbn9pe0jj3uM0hZeJUCxn9Fdoj64OfQBpCKzR7VqhkwHQ=="
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "PyJAt9WAeVLUfxp/l1ZvGw20HAsvfBY/JgZCJmY5doc8lFa/9dhUMBJN/cNsVM5XJK+xdIBoEemgl3SMFwXNcg=="
}
}
}
@@ -259,9 +259,9 @@
"dependencies": {
"Microsoft.Extensions.DependencyInjection": "[2.2.0, )",
"Speckle.Connectors.Logging": "[1.0.0, )",
"Speckle.Objects": "[3.5.3, )",
"Speckle.Sdk": "[3.5.3, )",
"Speckle.Sdk.Dependencies": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )",
"Speckle.Sdk": "[3.4.3, )",
"Speckle.Sdk.Dependencies": "[3.4.3, )"
}
},
"speckle.connectors.dui": {
@@ -293,7 +293,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Speckle.Objects": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )"
}
},
"Microsoft.Extensions.DependencyInjection": {
@@ -337,18 +337,18 @@
},
"Speckle.Objects": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "T3xwwoALVGmhIuEjlDrTdDXZ9haFILT32r8OACWrRUItU3xMkOWGyob51Ca1MHPmo8B5gvbk2Gnm8AgReGnxWg==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "08BOhVaYUvFP8CgY5fGZJWvswIRsH2EbOBGguJnanx+RZqKYI9XJroGGew+CDfPU1c8ZWl37WX2bbdPhdSP2rQ==",
"dependencies": {
"Speckle.Sdk": "3.5.3"
"Speckle.Sdk": "3.4.3"
}
},
"Speckle.Sdk": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "o+HefwtPZBqyuUHEnKF+qb/ctCAlNc2BYIw3ULEsZ93zweHt5wOMvOeuPxIXR0Gvj3fg6yNlY2nUcdFEduIXYA==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "21Dg8kMOqUbV7jyhK7N+UwyO7S1++COMR5jU9mm/vx86pkj6pTAifNZMHmuG8/ZnwpBcUCmE4AzvW24mKlgEkg==",
"dependencies": {
"GraphQL.Client": "6.0.0",
"Microsoft.Bcl.AsyncInterfaces": "5.0.0",
@@ -358,14 +358,14 @@
"Microsoft.Extensions.Logging": "2.2.0",
"Speckle.DoubleNumerics": "4.1.0",
"Speckle.Newtonsoft.Json": "13.0.2",
"Speckle.Sdk.Dependencies": "3.5.3"
"Speckle.Sdk.Dependencies": "3.4.3"
}
},
"Speckle.Sdk.Dependencies": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "kC15SE4yZoVTasgywCm0SpY9yjBsQeUIDt4qoscYAgbn9pe0jj3uM0hZeJUCxn9Fdoj64OfQBpCKzR7VqhkwHQ=="
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "PyJAt9WAeVLUfxp/l1ZvGw20HAsvfBY/JgZCJmY5doc8lFa/9dhUMBJN/cNsVM5XJK+xdIBoEemgl3SMFwXNcg=="
}
}
}
@@ -210,9 +210,9 @@
"dependencies": {
"Microsoft.Extensions.DependencyInjection": "[2.2.0, )",
"Speckle.Connectors.Logging": "[1.0.0, )",
"Speckle.Objects": "[3.5.3, )",
"Speckle.Sdk": "[3.5.3, )",
"Speckle.Sdk.Dependencies": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )",
"Speckle.Sdk": "[3.4.3, )",
"Speckle.Sdk.Dependencies": "[3.4.3, )"
}
},
"speckle.connectors.dui": {
@@ -244,7 +244,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Speckle.Objects": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )"
}
},
"Microsoft.Extensions.DependencyInjection": {
@@ -288,18 +288,18 @@
},
"Speckle.Objects": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "T3xwwoALVGmhIuEjlDrTdDXZ9haFILT32r8OACWrRUItU3xMkOWGyob51Ca1MHPmo8B5gvbk2Gnm8AgReGnxWg==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "08BOhVaYUvFP8CgY5fGZJWvswIRsH2EbOBGguJnanx+RZqKYI9XJroGGew+CDfPU1c8ZWl37WX2bbdPhdSP2rQ==",
"dependencies": {
"Speckle.Sdk": "3.5.3"
"Speckle.Sdk": "3.4.3"
}
},
"Speckle.Sdk": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "o+HefwtPZBqyuUHEnKF+qb/ctCAlNc2BYIw3ULEsZ93zweHt5wOMvOeuPxIXR0Gvj3fg6yNlY2nUcdFEduIXYA==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "21Dg8kMOqUbV7jyhK7N+UwyO7S1++COMR5jU9mm/vx86pkj6pTAifNZMHmuG8/ZnwpBcUCmE4AzvW24mKlgEkg==",
"dependencies": {
"GraphQL.Client": "6.0.0",
"Microsoft.Data.Sqlite": "7.0.5",
@@ -307,14 +307,14 @@
"Microsoft.Extensions.Logging": "2.2.0",
"Speckle.DoubleNumerics": "4.1.0",
"Speckle.Newtonsoft.Json": "13.0.2",
"Speckle.Sdk.Dependencies": "3.5.3"
"Speckle.Sdk.Dependencies": "3.4.3"
}
},
"Speckle.Sdk.Dependencies": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "kC15SE4yZoVTasgywCm0SpY9yjBsQeUIDt4qoscYAgbn9pe0jj3uM0hZeJUCxn9Fdoj64OfQBpCKzR7VqhkwHQ=="
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "PyJAt9WAeVLUfxp/l1ZvGw20HAsvfBY/JgZCJmY5doc8lFa/9dhUMBJN/cNsVM5XJK+xdIBoEemgl3SMFwXNcg=="
}
},
"net8.0-windows7.0/win-x64": {
@@ -210,9 +210,9 @@
"dependencies": {
"Microsoft.Extensions.DependencyInjection": "[2.2.0, )",
"Speckle.Connectors.Logging": "[1.0.0, )",
"Speckle.Objects": "[3.5.3, )",
"Speckle.Sdk": "[3.5.3, )",
"Speckle.Sdk.Dependencies": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )",
"Speckle.Sdk": "[3.4.3, )",
"Speckle.Sdk.Dependencies": "[3.4.3, )"
}
},
"speckle.connectors.dui": {
@@ -244,7 +244,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Speckle.Objects": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )"
}
},
"Microsoft.Extensions.DependencyInjection": {
@@ -288,18 +288,18 @@
},
"Speckle.Objects": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "T3xwwoALVGmhIuEjlDrTdDXZ9haFILT32r8OACWrRUItU3xMkOWGyob51Ca1MHPmo8B5gvbk2Gnm8AgReGnxWg==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "08BOhVaYUvFP8CgY5fGZJWvswIRsH2EbOBGguJnanx+RZqKYI9XJroGGew+CDfPU1c8ZWl37WX2bbdPhdSP2rQ==",
"dependencies": {
"Speckle.Sdk": "3.5.3"
"Speckle.Sdk": "3.4.3"
}
},
"Speckle.Sdk": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "o+HefwtPZBqyuUHEnKF+qb/ctCAlNc2BYIw3ULEsZ93zweHt5wOMvOeuPxIXR0Gvj3fg6yNlY2nUcdFEduIXYA==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "21Dg8kMOqUbV7jyhK7N+UwyO7S1++COMR5jU9mm/vx86pkj6pTAifNZMHmuG8/ZnwpBcUCmE4AzvW24mKlgEkg==",
"dependencies": {
"GraphQL.Client": "6.0.0",
"Microsoft.Data.Sqlite": "7.0.5",
@@ -307,14 +307,14 @@
"Microsoft.Extensions.Logging": "2.2.0",
"Speckle.DoubleNumerics": "4.1.0",
"Speckle.Newtonsoft.Json": "13.0.2",
"Speckle.Sdk.Dependencies": "3.5.3"
"Speckle.Sdk.Dependencies": "3.4.3"
}
},
"Speckle.Sdk.Dependencies": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "kC15SE4yZoVTasgywCm0SpY9yjBsQeUIDt4qoscYAgbn9pe0jj3uM0hZeJUCxn9Fdoj64OfQBpCKzR7VqhkwHQ=="
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "PyJAt9WAeVLUfxp/l1ZvGw20HAsvfBY/JgZCJmY5doc8lFa/9dhUMBJN/cNsVM5XJK+xdIBoEemgl3SMFwXNcg=="
}
},
"net8.0-windows7.0/win-x64": {
@@ -60,7 +60,7 @@ public abstract class AutocadRootObjectBaseBuilder : IRootObjectBuilder<AutocadR
)]
public Task<RootObjectBuilderResult> Build(
IReadOnlyList<AutocadRootObject> objects,
string projectId,
SendInfo sendInfo,
IProgress<CardProgress> onOperationProgressed,
CancellationToken cancellationToken
)
@@ -95,19 +95,28 @@ public abstract class AutocadRootObjectBaseBuilder : IRootObjectBuilder<AutocadR
foreach (var (entity, applicationId) in atomicObjects)
{
cancellationToken.ThrowIfCancellationRequested();
// Create and add a collection for this entity if not done so already.
(Collection objectCollection, LayerTableRecord? autocadLayer) = CreateObjectCollection(entity, tr);
if (autocadLayer is not null)
using (var convertActivity = _activityFactory.Start("Converting object"))
{
usedAcadLayers.Add(autocadLayer);
root.elements.Add(objectCollection);
// Create and add a collection for this entity if not done so already.
(Collection objectCollection, LayerTableRecord? autocadLayer) = CreateObjectCollection(entity, tr);
if (autocadLayer is not null)
{
usedAcadLayers.Add(autocadLayer);
root.elements.Add(objectCollection);
}
var result = ConvertAutocadEntity(
entity,
applicationId,
objectCollection,
instanceProxies,
sendInfo.ProjectId
);
results.Add(result);
onOperationProgressed.Report(new("Converting", (double)++count / atomicObjects.Count));
}
var result = ConvertAutocadEntity(entity, applicationId, objectCollection, instanceProxies, projectId);
results.Add(result);
onOperationProgressed.Report(new("Converting", (double)++count / atomicObjects.Count));
}
if (results.All(x => x.Status == Status.ERROR))
@@ -3,15 +3,6 @@
<PropertyGroup Label="Globals">
<ProjectGuid>{41BC679F-887F-44CF-971D-A5502EE87DB0}</ProjectGuid>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\Debug\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Local|AnyCPU' ">
<OutputPath>bin\Local\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\Release\</OutputPath>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"
Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"/>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props"/>
@@ -268,9 +268,9 @@
"dependencies": {
"Microsoft.Extensions.DependencyInjection": "[2.2.0, )",
"Speckle.Connectors.Logging": "[1.0.0, )",
"Speckle.Objects": "[3.5.3, )",
"Speckle.Sdk": "[3.5.3, )",
"Speckle.Sdk.Dependencies": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )",
"Speckle.Sdk": "[3.4.3, )",
"Speckle.Sdk.Dependencies": "[3.4.3, )"
}
},
"speckle.connectors.dui": {
@@ -302,7 +302,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Speckle.Objects": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )"
}
},
"Microsoft.Extensions.DependencyInjection": {
@@ -346,18 +346,18 @@
},
"Speckle.Objects": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "T3xwwoALVGmhIuEjlDrTdDXZ9haFILT32r8OACWrRUItU3xMkOWGyob51Ca1MHPmo8B5gvbk2Gnm8AgReGnxWg==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "08BOhVaYUvFP8CgY5fGZJWvswIRsH2EbOBGguJnanx+RZqKYI9XJroGGew+CDfPU1c8ZWl37WX2bbdPhdSP2rQ==",
"dependencies": {
"Speckle.Sdk": "3.5.3"
"Speckle.Sdk": "3.4.3"
}
},
"Speckle.Sdk": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "o+HefwtPZBqyuUHEnKF+qb/ctCAlNc2BYIw3ULEsZ93zweHt5wOMvOeuPxIXR0Gvj3fg6yNlY2nUcdFEduIXYA==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "21Dg8kMOqUbV7jyhK7N+UwyO7S1++COMR5jU9mm/vx86pkj6pTAifNZMHmuG8/ZnwpBcUCmE4AzvW24mKlgEkg==",
"dependencies": {
"GraphQL.Client": "6.0.0",
"Microsoft.Bcl.AsyncInterfaces": "5.0.0",
@@ -367,14 +367,14 @@
"Microsoft.Extensions.Logging": "2.2.0",
"Speckle.DoubleNumerics": "4.1.0",
"Speckle.Newtonsoft.Json": "13.0.2",
"Speckle.Sdk.Dependencies": "3.5.3"
"Speckle.Sdk.Dependencies": "3.4.3"
}
},
"Speckle.Sdk.Dependencies": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "kC15SE4yZoVTasgywCm0SpY9yjBsQeUIDt4qoscYAgbn9pe0jj3uM0hZeJUCxn9Fdoj64OfQBpCKzR7VqhkwHQ=="
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "PyJAt9WAeVLUfxp/l1ZvGw20HAsvfBY/JgZCJmY5doc8lFa/9dhUMBJN/cNsVM5XJK+xdIBoEemgl3SMFwXNcg=="
}
}
}
@@ -268,9 +268,9 @@
"dependencies": {
"Microsoft.Extensions.DependencyInjection": "[2.2.0, )",
"Speckle.Connectors.Logging": "[1.0.0, )",
"Speckle.Objects": "[3.5.3, )",
"Speckle.Sdk": "[3.5.3, )",
"Speckle.Sdk.Dependencies": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )",
"Speckle.Sdk": "[3.4.3, )",
"Speckle.Sdk.Dependencies": "[3.4.3, )"
}
},
"speckle.connectors.dui": {
@@ -302,7 +302,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Speckle.Objects": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )"
}
},
"Microsoft.Extensions.DependencyInjection": {
@@ -346,18 +346,18 @@
},
"Speckle.Objects": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "T3xwwoALVGmhIuEjlDrTdDXZ9haFILT32r8OACWrRUItU3xMkOWGyob51Ca1MHPmo8B5gvbk2Gnm8AgReGnxWg==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "08BOhVaYUvFP8CgY5fGZJWvswIRsH2EbOBGguJnanx+RZqKYI9XJroGGew+CDfPU1c8ZWl37WX2bbdPhdSP2rQ==",
"dependencies": {
"Speckle.Sdk": "3.5.3"
"Speckle.Sdk": "3.4.3"
}
},
"Speckle.Sdk": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "o+HefwtPZBqyuUHEnKF+qb/ctCAlNc2BYIw3ULEsZ93zweHt5wOMvOeuPxIXR0Gvj3fg6yNlY2nUcdFEduIXYA==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "21Dg8kMOqUbV7jyhK7N+UwyO7S1++COMR5jU9mm/vx86pkj6pTAifNZMHmuG8/ZnwpBcUCmE4AzvW24mKlgEkg==",
"dependencies": {
"GraphQL.Client": "6.0.0",
"Microsoft.Bcl.AsyncInterfaces": "5.0.0",
@@ -367,14 +367,14 @@
"Microsoft.Extensions.Logging": "2.2.0",
"Speckle.DoubleNumerics": "4.1.0",
"Speckle.Newtonsoft.Json": "13.0.2",
"Speckle.Sdk.Dependencies": "3.5.3"
"Speckle.Sdk.Dependencies": "3.4.3"
}
},
"Speckle.Sdk.Dependencies": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "kC15SE4yZoVTasgywCm0SpY9yjBsQeUIDt4qoscYAgbn9pe0jj3uM0hZeJUCxn9Fdoj64OfQBpCKzR7VqhkwHQ=="
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "PyJAt9WAeVLUfxp/l1ZvGw20HAsvfBY/JgZCJmY5doc8lFa/9dhUMBJN/cNsVM5XJK+xdIBoEemgl3SMFwXNcg=="
}
}
}
@@ -268,9 +268,9 @@
"dependencies": {
"Microsoft.Extensions.DependencyInjection": "[2.2.0, )",
"Speckle.Connectors.Logging": "[1.0.0, )",
"Speckle.Objects": "[3.5.3, )",
"Speckle.Sdk": "[3.5.3, )",
"Speckle.Sdk.Dependencies": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )",
"Speckle.Sdk": "[3.4.3, )",
"Speckle.Sdk.Dependencies": "[3.4.3, )"
}
},
"speckle.connectors.dui": {
@@ -302,7 +302,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Speckle.Objects": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )"
}
},
"Microsoft.Extensions.DependencyInjection": {
@@ -346,18 +346,18 @@
},
"Speckle.Objects": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "T3xwwoALVGmhIuEjlDrTdDXZ9haFILT32r8OACWrRUItU3xMkOWGyob51Ca1MHPmo8B5gvbk2Gnm8AgReGnxWg==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "08BOhVaYUvFP8CgY5fGZJWvswIRsH2EbOBGguJnanx+RZqKYI9XJroGGew+CDfPU1c8ZWl37WX2bbdPhdSP2rQ==",
"dependencies": {
"Speckle.Sdk": "3.5.3"
"Speckle.Sdk": "3.4.3"
}
},
"Speckle.Sdk": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "o+HefwtPZBqyuUHEnKF+qb/ctCAlNc2BYIw3ULEsZ93zweHt5wOMvOeuPxIXR0Gvj3fg6yNlY2nUcdFEduIXYA==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "21Dg8kMOqUbV7jyhK7N+UwyO7S1++COMR5jU9mm/vx86pkj6pTAifNZMHmuG8/ZnwpBcUCmE4AzvW24mKlgEkg==",
"dependencies": {
"GraphQL.Client": "6.0.0",
"Microsoft.Bcl.AsyncInterfaces": "5.0.0",
@@ -367,14 +367,14 @@
"Microsoft.Extensions.Logging": "2.2.0",
"Speckle.DoubleNumerics": "4.1.0",
"Speckle.Newtonsoft.Json": "13.0.2",
"Speckle.Sdk.Dependencies": "3.5.3"
"Speckle.Sdk.Dependencies": "3.4.3"
}
},
"Speckle.Sdk.Dependencies": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "kC15SE4yZoVTasgywCm0SpY9yjBsQeUIDt4qoscYAgbn9pe0jj3uM0hZeJUCxn9Fdoj64OfQBpCKzR7VqhkwHQ=="
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "PyJAt9WAeVLUfxp/l1ZvGw20HAsvfBY/JgZCJmY5doc8lFa/9dhUMBJN/cNsVM5XJK+xdIBoEemgl3SMFwXNcg=="
}
}
}
@@ -219,9 +219,9 @@
"dependencies": {
"Microsoft.Extensions.DependencyInjection": "[2.2.0, )",
"Speckle.Connectors.Logging": "[1.0.0, )",
"Speckle.Objects": "[3.5.3, )",
"Speckle.Sdk": "[3.5.3, )",
"Speckle.Sdk.Dependencies": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )",
"Speckle.Sdk": "[3.4.3, )",
"Speckle.Sdk.Dependencies": "[3.4.3, )"
}
},
"speckle.connectors.dui": {
@@ -254,7 +254,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Speckle.Objects": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )"
}
},
"Microsoft.Extensions.DependencyInjection": {
@@ -298,18 +298,18 @@
},
"Speckle.Objects": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "T3xwwoALVGmhIuEjlDrTdDXZ9haFILT32r8OACWrRUItU3xMkOWGyob51Ca1MHPmo8B5gvbk2Gnm8AgReGnxWg==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "08BOhVaYUvFP8CgY5fGZJWvswIRsH2EbOBGguJnanx+RZqKYI9XJroGGew+CDfPU1c8ZWl37WX2bbdPhdSP2rQ==",
"dependencies": {
"Speckle.Sdk": "3.5.3"
"Speckle.Sdk": "3.4.3"
}
},
"Speckle.Sdk": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "o+HefwtPZBqyuUHEnKF+qb/ctCAlNc2BYIw3ULEsZ93zweHt5wOMvOeuPxIXR0Gvj3fg6yNlY2nUcdFEduIXYA==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "21Dg8kMOqUbV7jyhK7N+UwyO7S1++COMR5jU9mm/vx86pkj6pTAifNZMHmuG8/ZnwpBcUCmE4AzvW24mKlgEkg==",
"dependencies": {
"GraphQL.Client": "6.0.0",
"Microsoft.Data.Sqlite": "7.0.5",
@@ -317,14 +317,14 @@
"Microsoft.Extensions.Logging": "2.2.0",
"Speckle.DoubleNumerics": "4.1.0",
"Speckle.Newtonsoft.Json": "13.0.2",
"Speckle.Sdk.Dependencies": "3.5.3"
"Speckle.Sdk.Dependencies": "3.4.3"
}
},
"Speckle.Sdk.Dependencies": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "kC15SE4yZoVTasgywCm0SpY9yjBsQeUIDt4qoscYAgbn9pe0jj3uM0hZeJUCxn9Fdoj64OfQBpCKzR7VqhkwHQ=="
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "PyJAt9WAeVLUfxp/l1ZvGw20HAsvfBY/JgZCJmY5doc8lFa/9dhUMBJN/cNsVM5XJK+xdIBoEemgl3SMFwXNcg=="
}
},
"net8.0-windows7.0/win-x64": {
@@ -219,9 +219,9 @@
"dependencies": {
"Microsoft.Extensions.DependencyInjection": "[2.2.0, )",
"Speckle.Connectors.Logging": "[1.0.0, )",
"Speckle.Objects": "[3.5.3, )",
"Speckle.Sdk": "[3.5.3, )",
"Speckle.Sdk.Dependencies": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )",
"Speckle.Sdk": "[3.4.3, )",
"Speckle.Sdk.Dependencies": "[3.4.3, )"
}
},
"speckle.connectors.dui": {
@@ -254,7 +254,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Speckle.Objects": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )"
}
},
"Microsoft.Extensions.DependencyInjection": {
@@ -298,18 +298,18 @@
},
"Speckle.Objects": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "T3xwwoALVGmhIuEjlDrTdDXZ9haFILT32r8OACWrRUItU3xMkOWGyob51Ca1MHPmo8B5gvbk2Gnm8AgReGnxWg==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "08BOhVaYUvFP8CgY5fGZJWvswIRsH2EbOBGguJnanx+RZqKYI9XJroGGew+CDfPU1c8ZWl37WX2bbdPhdSP2rQ==",
"dependencies": {
"Speckle.Sdk": "3.5.3"
"Speckle.Sdk": "3.4.3"
}
},
"Speckle.Sdk": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "o+HefwtPZBqyuUHEnKF+qb/ctCAlNc2BYIw3ULEsZ93zweHt5wOMvOeuPxIXR0Gvj3fg6yNlY2nUcdFEduIXYA==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "21Dg8kMOqUbV7jyhK7N+UwyO7S1++COMR5jU9mm/vx86pkj6pTAifNZMHmuG8/ZnwpBcUCmE4AzvW24mKlgEkg==",
"dependencies": {
"GraphQL.Client": "6.0.0",
"Microsoft.Data.Sqlite": "7.0.5",
@@ -317,14 +317,14 @@
"Microsoft.Extensions.Logging": "2.2.0",
"Speckle.DoubleNumerics": "4.1.0",
"Speckle.Newtonsoft.Json": "13.0.2",
"Speckle.Sdk.Dependencies": "3.5.3"
"Speckle.Sdk.Dependencies": "3.4.3"
}
},
"Speckle.Sdk.Dependencies": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "kC15SE4yZoVTasgywCm0SpY9yjBsQeUIDt4qoscYAgbn9pe0jj3uM0hZeJUCxn9Fdoj64OfQBpCKzR7VqhkwHQ=="
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "PyJAt9WAeVLUfxp/l1ZvGw20HAsvfBY/JgZCJmY5doc8lFa/9dhUMBJN/cNsVM5XJK+xdIBoEemgl3SMFwXNcg=="
}
},
"net8.0-windows7.0/win-x64": {
@@ -96,7 +96,7 @@ public class CsiSharedSelectionBinding : ISelectionBinding, IDisposable
var typeKey = (ModelObjectType)objectType[i];
var typeName = typeKey.ToString();
encodedIds.Add(ObjectIdentifier.Encode(objectType[i], objectName[i]));
typeCounts[typeName] = (typeCounts.TryGetValue(typeName, out var count) ? count : 0) + 1;
typeCounts[typeName] = (typeCounts.TryGetValue(typeName, out var count) ? count : 0) + 1; // NOTE: Cross-framework compatibility (net 48 and net8)
}
var summary =
encodedIds.Count == 0
@@ -1,8 +1,6 @@
using Microsoft.Extensions.DependencyInjection;
using Speckle.Connectors.Common.Cancellation;
using Speckle.Connectors.CSiShared.HostApp;
using Speckle.Connectors.CSiShared.Operations.Send.Settings;
using Speckle.Connectors.CSiShared.Settings;
using Speckle.Connectors.CSiShared.Utils;
using Speckle.Connectors.DUI.Bindings;
using Speckle.Connectors.DUI.Bridge;
@@ -25,7 +23,6 @@ public sealed class CsiSharedSendBinding : ISendBinding
private readonly ICsiApplicationService _csiApplicationService;
private readonly ICsiConversionSettingsFactory _csiConversionSettingsFactory;
private readonly ISendOperationManagerFactory _sendOperationManagerFactory;
private readonly ToSpeckleSettingsManager _toSpeckleSettingsManager;
public CsiSharedSendBinding(
IBrowserBridge parent,
@@ -33,8 +30,7 @@ public sealed class CsiSharedSendBinding : ISendBinding
ICancellationManager cancellationManager,
ICsiConversionSettingsFactory csiConversionSettingsFactory,
ICsiApplicationService csiApplicationService,
ISendOperationManagerFactory sendOperationManagerFactory,
ToSpeckleSettingsManager toSpeckleSettingsManager
ISendOperationManagerFactory sendOperationManagerFactory
)
{
_sendFilters = sendFilters.ToList();
@@ -44,13 +40,11 @@ public sealed class CsiSharedSendBinding : ISendBinding
_csiConversionSettingsFactory = csiConversionSettingsFactory;
_csiApplicationService = csiApplicationService;
_sendOperationManagerFactory = sendOperationManagerFactory;
_toSpeckleSettingsManager = toSpeckleSettingsManager;
}
public List<ISendFilter> GetSendFilters() => _sendFilters;
public List<ICardSetting> GetSendSettings() =>
[new LoadCaseCombinationSetting([], _csiApplicationService.SapModel), new ResultTypeSetting([])];
public List<ICardSetting> GetSendSettings() => [];
public async Task Send(string modelCardId)
{
@@ -58,17 +52,9 @@ public sealed class CsiSharedSendBinding : ISendBinding
await manager.Process(
Commands,
modelCardId,
(sp, card) =>
{
(sp, _) =>
sp.GetRequiredService<IConverterSettingsStore<CsiConversionSettings>>()
.Initialize(
_csiConversionSettingsFactory.Create(
_csiApplicationService.SapModel,
_toSpeckleSettingsManager.GetLoadCasesAndCombinations(card),
_toSpeckleSettingsManager.GetResultTypes(card)
)
);
},
.Initialize(_csiConversionSettingsFactory.Create(_csiApplicationService.SapModel)),
card => card.SendFilter.NotNull().RefreshObjectIds().Select(DecodeObjectIdentifier).ToList()
);
}
@@ -1,27 +0,0 @@
using Microsoft.Extensions.DependencyInjection;
using Speckle.Converters.CSiShared.ToSpeckle.Helpers;
using Speckle.Converters.CSiShared.Utils;
namespace Speckle.Connectors.CSiShared.HostApp.Helpers;
public class CsiResultsExtractorFactory
{
private readonly IServiceProvider _serviceProvider;
public CsiResultsExtractorFactory(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
}
public IApplicationResultsExtractor GetExtractor(string resultsKey) =>
resultsKey switch
{
ResultsKey.BASE_REACT => _serviceProvider.GetRequiredService<CsiBaseReactResultsExtractor>(),
ResultsKey.FRAME_FORCES => _serviceProvider.GetRequiredService<CsiFrameForceResultsExtractor>(),
ResultsKey.JOINT_REACT => _serviceProvider.GetRequiredService<CsiJointReactResultsExtractor>(),
ResultsKey.PIER_FORCES => _serviceProvider.GetRequiredService<CsiPierForceResultsExtractor>(),
ResultsKey.SPANDREL_FORCES => _serviceProvider.GetRequiredService<CsiSpandrelForceResultsExtractor>(),
ResultsKey.STORY_DRIFTS => _serviceProvider.GetRequiredService<CsiStoryDriftsResultsExtractor>(),
_ => throw new InvalidOperationException($"{resultsKey} not accounted for in CsiResultsExtractorFactory")
};
}
@@ -4,11 +4,9 @@ using Speckle.Connectors.Common.Conversion;
using Speckle.Connectors.Common.Operations;
using Speckle.Connectors.CSiShared.HostApp;
using Speckle.Connectors.CSiShared.HostApp.Helpers;
using Speckle.Connectors.CSiShared.Utils;
using Speckle.Converters.Common;
using Speckle.Converters.CSiShared;
using Speckle.Converters.CSiShared.Extensions;
using Speckle.Converters.CSiShared.Utils;
using Speckle.Sdk;
using Speckle.Sdk.Logging;
using Speckle.Sdk.Models;
@@ -39,7 +37,6 @@ public class CsiRootObjectBuilder : IRootObjectBuilder<ICsiWrapper>
private readonly ILogger<CsiRootObjectBuilder> _logger;
private readonly ISdkActivityFactory _activityFactory;
private readonly ICsiApplicationService _csiApplicationService;
private readonly AnalysisResultsExtractor _analysisResultsExtractor;
public CsiRootObjectBuilder(
IRootToSpeckleConverter rootToSpeckleConverter,
@@ -49,8 +46,7 @@ public class CsiRootObjectBuilder : IRootObjectBuilder<ICsiWrapper>
ISectionUnpacker sectionUnpacker,
ILogger<CsiRootObjectBuilder> logger,
ISdkActivityFactory activityFactory,
ICsiApplicationService csiApplicationService,
AnalysisResultsExtractor analysisResultsExtractor
ICsiApplicationService csiApplicationService
)
{
_converterSettings = converterSettings;
@@ -61,7 +57,6 @@ public class CsiRootObjectBuilder : IRootObjectBuilder<ICsiWrapper>
_logger = logger;
_activityFactory = activityFactory;
_csiApplicationService = csiApplicationService;
_analysisResultsExtractor = analysisResultsExtractor;
}
/// <summary>
@@ -75,7 +70,7 @@ public class CsiRootObjectBuilder : IRootObjectBuilder<ICsiWrapper>
/// </remarks>
public async Task<RootObjectBuilderResult> Build(
IReadOnlyList<ICsiWrapper> csiObjects,
string projectId,
SendInfo sendInfo,
IProgress<CardProgress> onOperationProgressed,
CancellationToken cancellationToken
)
@@ -94,6 +89,8 @@ public class CsiRootObjectBuilder : IRootObjectBuilder<ICsiWrapper>
foreach (ICsiWrapper csiObject in csiObjects)
{
cancellationToken.ThrowIfCancellationRequested();
using var _2 = _activityFactory.Start("Convert");
var result = ConvertCsiObject(csiObject, rootObjectCollection);
results.Add(result);
@@ -117,34 +114,6 @@ public class CsiRootObjectBuilder : IRootObjectBuilder<ICsiWrapper>
rootObjectCollection[ProxyKeys.SECTION] = _sectionUnpacker.UnpackSections().ToList();
}
// Extract analysis results (if applicable)
// NOTE: objectSelectionSummary used to extract results for objects being published ONLY
// NOTE: etabs is complicated and we can't get specifics from original selection
var objectSelectionSummary = GetObjectSummary(csiObjects);
var selectedCasesAndCombinations = _converterSettings.Current.SelectedLoadCasesAndCombinations;
var requestedResultTypes = _converterSettings.Current.SelectedResultTypes;
if (selectedCasesAndCombinations?.Count > 0)
{
if (requestedResultTypes == null || requestedResultTypes.Count == 0)
{
throw new SpeckleException(
"No result type input for the requested load cases and combinations. Adjust publish settings."
);
}
if (!_csiApplicationService.SapModel.GetModelIsLocked())
{
throw new SpeckleException("Model unlocked. No access to analysis results.");
}
var analysisResults = _analysisResultsExtractor.ExtractAnalysisResults(
selectedCasesAndCombinations,
requestedResultTypes,
objectSelectionSummary
);
rootObjectCollection["analysisResults"] = analysisResults;
}
return new RootObjectBuilderResult(rootObjectCollection, results);
}
@@ -191,22 +160,4 @@ public class CsiRootObjectBuilder : IRootObjectBuilder<ICsiWrapper>
return new(Status.ERROR, applicationId, sourceType, null, ex);
}
}
/// <summary>
/// Generates a summary of object types and their associated names from the collection of CSI wrappers.
/// </summary>
/// <remarks>
/// A summary of object names for each object type is needed for getting analysis results of the selected objects only.
/// During object conversion, however, we lose the selection (like a clear selection)(presumably because of other api calls).
/// This has to be recreated since GetSelection() return type is bound by the interface.
/// The LINQ-based implementation is computationally inexpensive as it operates on an already-loaded collection without additional API calls.
/// Also, we don't want to rely on user selection remaining active, what if someone re-publishes using model card cache?
/// </remarks>
private Dictionary<ModelObjectType, List<string>> GetObjectSummary(IReadOnlyList<ICsiWrapper> csiObjects) =>
csiObjects
.GroupBy(csiObject => csiObject.ObjectType)
.ToDictionary(
group => group.Key, // ModelObjectType (FRAME, JOINT, etc.)
group => group.Select(obj => obj.Name).ToList() // Extract Name from each ICsiWrapper and convert to List<string>
);
}
@@ -1,73 +0,0 @@
using Speckle.Connectors.Common.Caching;
using Speckle.Connectors.DUI.Models.Card;
using Speckle.InterfaceGenerator;
using Speckle.Newtonsoft.Json.Linq;
using Speckle.Sdk.Common;
namespace Speckle.Connectors.CSiShared.Operations.Send.Settings;
[GenerateAutoInterface]
public class ToSpeckleSettingsManager : IToSpeckleSettingsManager
{
private readonly ISendConversionCache _sendConversionCache;
private readonly Dictionary<string, List<string>?> _loadCaseCombinationCache = new();
private readonly Dictionary<string, List<string>?> _resultTypeCache = new();
public ToSpeckleSettingsManager(ISendConversionCache sendConversionCache)
{
_sendConversionCache = sendConversionCache;
}
public List<string> GetLoadCasesAndCombinations(SenderModelCard modelCard)
{
var setting = modelCard.Settings?.FirstOrDefault(s => s.Id == "loadCasesAndCombinations");
var returnValue = (setting?.Value as JArray)?.Select(x => x.ToString()).ToList() ?? [];
if (_loadCaseCombinationCache.TryGetValue(modelCard.ModelCardId.NotNull(), out List<string>? previousValue))
{
if (!AreListsEqual(previousValue, returnValue))
{
EvictCacheForModelCard(modelCard);
}
}
_loadCaseCombinationCache[modelCard.ModelCardId] = returnValue;
return returnValue;
}
public List<string> GetResultTypes(SenderModelCard modelCard)
{
var setting = modelCard.Settings?.FirstOrDefault(s => s.Id == "resultTypes");
var returnValue = (setting?.Value as JArray)?.Select(x => x.ToString()).ToList() ?? [];
if (_resultTypeCache.TryGetValue(modelCard.ModelCardId.NotNull(), out List<string>? previousValue))
{
if (!AreListsEqual(previousValue, returnValue))
{
EvictCacheForModelCard(modelCard);
}
}
_resultTypeCache[modelCard.ModelCardId] = returnValue;
return returnValue;
}
private static bool AreListsEqual(List<string>? list1, List<string>? list2)
{
if (list1 == null && list2 == null)
{
return true;
}
if (list1 == null || list2 == null)
{
return false;
}
return list1.Count == list2.Count && list1.OrderBy(x => x).SequenceEqual(list2.OrderBy(x => x));
}
private void EvictCacheForModelCard(SenderModelCard modelCard)
{
var objectIds = modelCard.SendFilter != null ? modelCard.SendFilter.NotNull().RefreshObjectIds() : [];
_sendConversionCache.EvictObjects(objectIds);
}
}
@@ -8,8 +8,6 @@ using Speckle.Connectors.CSiShared.Builders;
using Speckle.Connectors.CSiShared.Filters;
using Speckle.Connectors.CSiShared.HostApp;
using Speckle.Connectors.CSiShared.HostApp.Helpers;
using Speckle.Connectors.CSiShared.Operations.Send.Settings;
using Speckle.Connectors.CSiShared.Utils;
using Speckle.Connectors.DUI;
using Speckle.Connectors.DUI.Bindings;
using Speckle.Connectors.DUI.Bridge;
@@ -46,18 +44,13 @@ public static class ServiceRegistration
services.AddScoped<SendOperation<ICsiWrapper>>();
services.AddScoped<CsiMaterialPropertyExtractor>();
services.AddScoped<CsiResultsExtractorFactory>();
services.AddScoped<MaterialUnpacker>();
services.AddScoped<IFrameSectionPropertyExtractor, CsiFrameSectionPropertyExtractor>();
services.AddScoped<IShellSectionPropertyExtractor, CsiShellSectionPropertyExtractor>();
services.AddScoped<AnalysisResultsExtractor>();
// add converter caches
services.AddScoped<CsiToSpeckleCacheSingleton>();
// add settings manager
services.AddScoped<ToSpeckleSettingsManager>();
return services;
}
}
@@ -1,13 +0,0 @@
using Speckle.Connectors.CSiShared.Utils;
using Speckle.Connectors.DUI.Settings;
namespace Speckle.Connectors.CSiShared.Settings;
public class LoadCaseCombinationSetting(List<string> values, cSapModel sapModel) : ICardSetting
{
public string? Id { get; set; } = "loadCasesAndCombinations";
public string? Title { get; set; } = "Load Cases & Combinations";
public string? Type { get; set; } = "array";
public object? Value { get; set; } = values;
public List<string>? Enum { get; set; } = LoadCaseHelper.GetLoadCasesAndCombinations(sapModel);
}
@@ -1,13 +0,0 @@
using Speckle.Connectors.DUI.Settings;
using Speckle.Converters.CSiShared.Utils;
namespace Speckle.Connectors.CSiShared.Settings;
public class ResultTypeSetting(List<string> values) : ICardSetting
{
public string? Id { get; set; } = "resultTypes";
public string? Title { get; set; } = "Result Type";
public string? Type { get; set; } = "array";
public object? Value { get; set; } = values;
public List<string>? Enum { get; set; } = ResultsKey.All.OrderBy(x => x).ToList();
}
@@ -18,7 +18,6 @@
<Compile Include="$(MSBuildThisFileDirectory)Bindings\CsiSharedSelectionBinding.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bindings\CsiSharedSendBinding.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Filters\CsiSharedSelectionFilter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)HostApp\Helpers\CsiResultsExtractorFactory.cs" />
<Compile Include="$(MSBuildThisFileDirectory)HostApp\MaterialUnpacker.cs" />
<Compile Include="$(MSBuildThisFileDirectory)HostApp\CsiSendCollectionManager.cs" />
<Compile Include="$(MSBuildThisFileDirectory)HostApp\Helpers\CsiFrameSectionPropertyExtractor.cs" />
@@ -28,17 +27,12 @@
<Compile Include="$(MSBuildThisFileDirectory)HostApp\Helpers\ISectionPropertyExtractor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)HostApp\Helpers\ISectionUnpacker.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Operations\Send\CsiRootObjectBuilder.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Operations\Send\Settings\ToSpeckleSettingsManager.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Plugin\CsiPluginBase.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Plugin\SpeckleFormBase.cs" />
<Compile Include="$(MSBuildThisFileDirectory)GlobalUsing.cs" />
<Compile Include="$(MSBuildThisFileDirectory)HostApp\CsiApplicationService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)HostApp\CsiDocumentModelStore.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ServiceRegistration.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Settings\LoadCaseCombinationSetting.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Settings\ResultTypeSetting.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utils\LoadCaseHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utils\AnalysisResultsExtractor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utils\ObjectIdentifiers.cs" />
</ItemGroup>
<ItemGroup>
@@ -1,184 +0,0 @@
using Speckle.Connectors.CSiShared.HostApp.Helpers;
using Speckle.Converters.Common;
using Speckle.Converters.CSiShared;
using Speckle.Converters.CSiShared.Utils;
using Speckle.Sdk;
using Speckle.Sdk.Models;
namespace Speckle.Connectors.CSiShared.Utils;
public class AnalysisResultsExtractor
{
private readonly IConverterSettingsStore<CsiConversionSettings> _converterSettingsStore;
private readonly CsiResultsExtractorFactory _resultsExtractorFactory;
public AnalysisResultsExtractor(
IConverterSettingsStore<CsiConversionSettings> converterSettingsStore,
CsiResultsExtractorFactory resultsExtractorFactory
)
{
_converterSettingsStore = converterSettingsStore;
_resultsExtractorFactory = resultsExtractorFactory;
}
/// <summary>
/// Extracts complete analysis results including units retrieval, load case configuration, and results extraction.
/// Assumes inputs have been validated by caller.
/// </summary>
public Base ExtractAnalysisResults(
List<string> selectedCasesAndCombinations,
List<string> requestedResultTypes,
Dictionary<ModelObjectType, List<string>> objectSelectionSummary
)
{
// Step 1: get analysis units
var analysisResults = CreateAnalysisResultsWithUnits();
// Step 2: configure and validate load cases
ConfigureAndValidateSelectedLoadCases(selectedCasesAndCombinations);
// Step 3: extract results using clean factory pattern
ExtractResults(requestedResultTypes, objectSelectionSummary, analysisResults);
return analysisResults;
}
/// <summary>
/// Instantiates a Base object and pre-populates it with the models defined force units.
/// </summary>
/// <returns></returns>
/// <exception cref="SpeckleException"></exception>
private Base CreateAnalysisResultsWithUnits()
{
var forceUnit = eForce.NotApplicable;
var lengthUnit = eLength.NotApplicable;
var temperatureUnit = eTemperature.NotApplicable;
int success = _converterSettingsStore.Current.SapModel.GetDatabaseUnits_2(
ref forceUnit,
ref lengthUnit,
ref temperatureUnit
);
if (success != 0)
{
throw new SpeckleException("Failed to retrieve units for analysis results");
}
return new Base
{
["forceUnit"] = forceUnit.ToString(),
["lengthUnit"] = lengthUnit.ToString(),
["temperatureUnit"] = temperatureUnit.ToString()
};
}
private void ExtractResults(
List<string> requestedResultTypes,
Dictionary<ModelObjectType, List<string>> objectSelectionSummary,
Base analysisResults
)
{
foreach (var resultType in requestedResultTypes)
{
var extractor = _resultsExtractorFactory.GetExtractor(resultType);
objectSelectionSummary.TryGetValue(extractor.TargetObjectType, out var objectNames);
analysisResults[extractor.ResultsKey] = extractor.GetResults(objectNames);
}
}
/// <summary>
/// Responsible for two things. Firstly, we need to setup the results so that only the requested cases and combinations
/// are published. Secondly, we need to ensure that the requested cases and combinations are actually run.
/// </summary>
private void ConfigureAndValidateSelectedLoadCases(List<string> selectedLoadCases)
{
// step 1: configure load cases for output
ConfigureSelectedLoadCases(selectedLoadCases);
// step 2: validate they are complete (throws on failure)
ValidateSelectedCasesAreComplete(selectedLoadCases);
}
private void ConfigureSelectedLoadCases(List<string> selectedLoadCases)
{
// deselect all load cases and combos
_converterSettingsStore.Current.SapModel.Results.Setup.DeselectAllCasesAndCombosForOutput();
// ui presents cases and combinations as a flat list. we need to distinguish if the string is a case or combo
// do this by seeing if the string is within the list of defined cases
// typically defined load cases << defined load combinations, so this approach should be more efficient
int numberOfLoadCases = 0;
string[] loadCaseNames = [];
_converterSettingsStore.Current.SapModel.LoadCases.GetNameList(ref numberOfLoadCases, ref loadCaseNames);
// set user selected combos to true (i.e. to export)
foreach (var selectedLoadCase in selectedLoadCases)
{
int success = loadCaseNames.Contains(selectedLoadCase)
? _converterSettingsStore.Current.SapModel.Results.Setup.SetCaseSelectedForOutput(selectedLoadCase)
: _converterSettingsStore.Current.SapModel.Results.Setup.SetComboSelectedForOutput(selectedLoadCase);
// ui should only present valid options
// `AnalysisResultsExtractor` only fetches load cases and load combinations (not patterns), so this should never throw
if (success != 0)
{
throw new InvalidOperationException($"Failed to set {selectedLoadCase} for output.");
}
}
}
private void ValidateSelectedCasesAreComplete(List<string> selectedCasesAndCombinations)
{
// get status for all load cases (combinations not included in this API call)
int numberItems = 0;
string[] caseNames = [];
int[] statuses = [];
int result = _converterSettingsStore.Current.SapModel.Analyze.GetCaseStatus(
ref numberItems,
ref caseNames,
ref statuses
);
if (result != 0)
{
throw new SpeckleException("Failed to retrieve load case status from model.");
}
// build lookup dictionary for load cases only
var caseStatusLookup = caseNames
.Zip(statuses, (name, status) => new { name, status })
.ToDictionary(x => x.name, x => x.status);
// separate selected items into cases and combinations
var selectedCases = selectedCasesAndCombinations.Where(item => caseStatusLookup.ContainsKey(item)).ToList();
var selectedCombinations = selectedCasesAndCombinations.Except(selectedCases).ToList();
// validate load cases status
var notFinishedCases = new List<string>();
foreach (var caseName in selectedCases)
{
int status = caseStatusLookup[caseName];
if (status != 4) // 1 = Not run, 2 = Could not start, 3 = Not finished, 4 = Finished
{
notFinishedCases.Add($"{caseName}");
}
}
// TODO: Validate load combinations status
// for now, assume combinations are valid if we can't validate them
if (selectedCombinations.Count != 0)
{
// combinations validation not implemented - assuming they're valid for now
// it'll get complicated, we can't get the status of a combination, so we need to check the constituent cases
}
if (notFinishedCases.Count != 0)
{
string errorMessage =
$"Analysis not complete for load cases: {string.Join(", ", notFinishedCases)}. Run analysis first.";
throw new SpeckleException(errorMessage);
}
}
}
@@ -1,56 +0,0 @@
namespace Speckle.Connectors.CSiShared.Utils;
public static class LoadCaseHelper
{
public static List<string> GetLoadCasesAndCombinations(cSapModel sapModel)
{
var loadCasesAndCombos = new List<string>();
try
{
// Check if model is loaded to prevent crashes
var modelFilename = sapModel.GetModelFilename();
if (string.IsNullOrEmpty(modelFilename))
{
return loadCasesAndCombos; // Return empty list if no model
}
// Get Load Cases
int numberItems = 0;
string[]? names = null;
int ret = sapModel.LoadCases.GetNameList(ref numberItems, ref names);
if (ret == 0 && names != null)
{
for (int i = 0; i < numberItems; i++)
{
loadCasesAndCombos.Add(names[i]);
}
}
// Get Load Combinations
numberItems = 0;
names = null;
ret = sapModel.RespCombo.GetNameList(ref numberItems, ref names);
if (ret == 0 && names != null)
{
for (int i = 0; i < numberItems; i++)
{
loadCasesAndCombos.Add(names[i]);
}
}
}
catch (System.Runtime.InteropServices.COMException)
{
// Return empty list on COM errors to prevent crashes
return new List<string>();
}
catch (System.InvalidOperationException)
{
// Return empty list on invalid operations to prevent crashes
return new List<string>();
}
return loadCasesAndCombos.Distinct().OrderBy(x => x).ToList();
}
}
@@ -259,9 +259,9 @@
"dependencies": {
"Microsoft.Extensions.DependencyInjection": "[2.2.0, )",
"Speckle.Connectors.Logging": "[1.0.0, )",
"Speckle.Objects": "[3.5.3, )",
"Speckle.Sdk": "[3.5.3, )",
"Speckle.Sdk.Dependencies": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )",
"Speckle.Sdk": "[3.4.3, )",
"Speckle.Sdk.Dependencies": "[3.4.3, )"
}
},
"speckle.connectors.dui": {
@@ -285,7 +285,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Speckle.Objects": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )"
}
},
"speckle.converters.etabs21": {
@@ -335,18 +335,18 @@
},
"Speckle.Objects": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "T3xwwoALVGmhIuEjlDrTdDXZ9haFILT32r8OACWrRUItU3xMkOWGyob51Ca1MHPmo8B5gvbk2Gnm8AgReGnxWg==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "08BOhVaYUvFP8CgY5fGZJWvswIRsH2EbOBGguJnanx+RZqKYI9XJroGGew+CDfPU1c8ZWl37WX2bbdPhdSP2rQ==",
"dependencies": {
"Speckle.Sdk": "3.5.3"
"Speckle.Sdk": "3.4.3"
}
},
"Speckle.Sdk": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "o+HefwtPZBqyuUHEnKF+qb/ctCAlNc2BYIw3ULEsZ93zweHt5wOMvOeuPxIXR0Gvj3fg6yNlY2nUcdFEduIXYA==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "21Dg8kMOqUbV7jyhK7N+UwyO7S1++COMR5jU9mm/vx86pkj6pTAifNZMHmuG8/ZnwpBcUCmE4AzvW24mKlgEkg==",
"dependencies": {
"GraphQL.Client": "6.0.0",
"Microsoft.Bcl.AsyncInterfaces": "5.0.0",
@@ -356,14 +356,14 @@
"Microsoft.Extensions.Logging": "2.2.0",
"Speckle.DoubleNumerics": "4.1.0",
"Speckle.Newtonsoft.Json": "13.0.2",
"Speckle.Sdk.Dependencies": "3.5.3"
"Speckle.Sdk.Dependencies": "3.4.3"
}
},
"Speckle.Sdk.Dependencies": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "kC15SE4yZoVTasgywCm0SpY9yjBsQeUIDt4qoscYAgbn9pe0jj3uM0hZeJUCxn9Fdoj64OfQBpCKzR7VqhkwHQ=="
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "PyJAt9WAeVLUfxp/l1ZvGw20HAsvfBY/JgZCJmY5doc8lFa/9dhUMBJN/cNsVM5XJK+xdIBoEemgl3SMFwXNcg=="
}
}
}
@@ -210,9 +210,9 @@
"dependencies": {
"Microsoft.Extensions.DependencyInjection": "[2.2.0, )",
"Speckle.Connectors.Logging": "[1.0.0, )",
"Speckle.Objects": "[3.5.3, )",
"Speckle.Sdk": "[3.5.3, )",
"Speckle.Sdk.Dependencies": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )",
"Speckle.Sdk": "[3.4.3, )",
"Speckle.Sdk.Dependencies": "[3.4.3, )"
}
},
"speckle.connectors.dui": {
@@ -236,7 +236,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Speckle.Objects": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )"
}
},
"speckle.converters.etabs22": {
@@ -286,18 +286,18 @@
},
"Speckle.Objects": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "T3xwwoALVGmhIuEjlDrTdDXZ9haFILT32r8OACWrRUItU3xMkOWGyob51Ca1MHPmo8B5gvbk2Gnm8AgReGnxWg==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "08BOhVaYUvFP8CgY5fGZJWvswIRsH2EbOBGguJnanx+RZqKYI9XJroGGew+CDfPU1c8ZWl37WX2bbdPhdSP2rQ==",
"dependencies": {
"Speckle.Sdk": "3.5.3"
"Speckle.Sdk": "3.4.3"
}
},
"Speckle.Sdk": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "o+HefwtPZBqyuUHEnKF+qb/ctCAlNc2BYIw3ULEsZ93zweHt5wOMvOeuPxIXR0Gvj3fg6yNlY2nUcdFEduIXYA==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "21Dg8kMOqUbV7jyhK7N+UwyO7S1++COMR5jU9mm/vx86pkj6pTAifNZMHmuG8/ZnwpBcUCmE4AzvW24mKlgEkg==",
"dependencies": {
"GraphQL.Client": "6.0.0",
"Microsoft.Data.Sqlite": "7.0.5",
@@ -305,14 +305,14 @@
"Microsoft.Extensions.Logging": "2.2.0",
"Speckle.DoubleNumerics": "4.1.0",
"Speckle.Newtonsoft.Json": "13.0.2",
"Speckle.Sdk.Dependencies": "3.5.3"
"Speckle.Sdk.Dependencies": "3.4.3"
}
},
"Speckle.Sdk.Dependencies": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "kC15SE4yZoVTasgywCm0SpY9yjBsQeUIDt4qoscYAgbn9pe0jj3uM0hZeJUCxn9Fdoj64OfQBpCKzR7VqhkwHQ=="
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "PyJAt9WAeVLUfxp/l1ZvGw20HAsvfBY/JgZCJmY5doc8lFa/9dhUMBJN/cNsVM5XJK+xdIBoEemgl3SMFwXNcg=="
}
}
}
@@ -259,9 +259,9 @@
"dependencies": {
"Microsoft.Extensions.DependencyInjection": "[2.2.0, )",
"Speckle.Connectors.Logging": "[1.0.0, )",
"Speckle.Objects": "[3.5.3, )",
"Speckle.Sdk": "[3.5.3, )",
"Speckle.Sdk.Dependencies": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )",
"Speckle.Sdk": "[3.4.3, )",
"Speckle.Sdk.Dependencies": "[3.4.3, )"
}
},
"speckle.connectors.dui": {
@@ -285,7 +285,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Speckle.Objects": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )"
}
},
"speckle.converters.navisworks2020": {
@@ -337,18 +337,18 @@
},
"Speckle.Objects": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "T3xwwoALVGmhIuEjlDrTdDXZ9haFILT32r8OACWrRUItU3xMkOWGyob51Ca1MHPmo8B5gvbk2Gnm8AgReGnxWg==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "08BOhVaYUvFP8CgY5fGZJWvswIRsH2EbOBGguJnanx+RZqKYI9XJroGGew+CDfPU1c8ZWl37WX2bbdPhdSP2rQ==",
"dependencies": {
"Speckle.Sdk": "3.5.3"
"Speckle.Sdk": "3.4.3"
}
},
"Speckle.Sdk": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "o+HefwtPZBqyuUHEnKF+qb/ctCAlNc2BYIw3ULEsZ93zweHt5wOMvOeuPxIXR0Gvj3fg6yNlY2nUcdFEduIXYA==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "21Dg8kMOqUbV7jyhK7N+UwyO7S1++COMR5jU9mm/vx86pkj6pTAifNZMHmuG8/ZnwpBcUCmE4AzvW24mKlgEkg==",
"dependencies": {
"GraphQL.Client": "6.0.0",
"Microsoft.Bcl.AsyncInterfaces": "5.0.0",
@@ -358,14 +358,14 @@
"Microsoft.Extensions.Logging": "2.2.0",
"Speckle.DoubleNumerics": "4.1.0",
"Speckle.Newtonsoft.Json": "13.0.2",
"Speckle.Sdk.Dependencies": "3.5.3"
"Speckle.Sdk.Dependencies": "3.4.3"
}
},
"Speckle.Sdk.Dependencies": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "kC15SE4yZoVTasgywCm0SpY9yjBsQeUIDt4qoscYAgbn9pe0jj3uM0hZeJUCxn9Fdoj64OfQBpCKzR7VqhkwHQ=="
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "PyJAt9WAeVLUfxp/l1ZvGw20HAsvfBY/JgZCJmY5doc8lFa/9dhUMBJN/cNsVM5XJK+xdIBoEemgl3SMFwXNcg=="
}
},
".NETFramework,Version=v4.8/win-x64": {
@@ -259,9 +259,9 @@
"dependencies": {
"Microsoft.Extensions.DependencyInjection": "[2.2.0, )",
"Speckle.Connectors.Logging": "[1.0.0, )",
"Speckle.Objects": "[3.5.3, )",
"Speckle.Sdk": "[3.5.3, )",
"Speckle.Sdk.Dependencies": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )",
"Speckle.Sdk": "[3.4.3, )",
"Speckle.Sdk.Dependencies": "[3.4.3, )"
}
},
"speckle.connectors.dui": {
@@ -285,7 +285,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Speckle.Objects": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )"
}
},
"speckle.converters.navisworks2021": {
@@ -337,18 +337,18 @@
},
"Speckle.Objects": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "T3xwwoALVGmhIuEjlDrTdDXZ9haFILT32r8OACWrRUItU3xMkOWGyob51Ca1MHPmo8B5gvbk2Gnm8AgReGnxWg==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "08BOhVaYUvFP8CgY5fGZJWvswIRsH2EbOBGguJnanx+RZqKYI9XJroGGew+CDfPU1c8ZWl37WX2bbdPhdSP2rQ==",
"dependencies": {
"Speckle.Sdk": "3.5.3"
"Speckle.Sdk": "3.4.3"
}
},
"Speckle.Sdk": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "o+HefwtPZBqyuUHEnKF+qb/ctCAlNc2BYIw3ULEsZ93zweHt5wOMvOeuPxIXR0Gvj3fg6yNlY2nUcdFEduIXYA==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "21Dg8kMOqUbV7jyhK7N+UwyO7S1++COMR5jU9mm/vx86pkj6pTAifNZMHmuG8/ZnwpBcUCmE4AzvW24mKlgEkg==",
"dependencies": {
"GraphQL.Client": "6.0.0",
"Microsoft.Bcl.AsyncInterfaces": "5.0.0",
@@ -358,14 +358,14 @@
"Microsoft.Extensions.Logging": "2.2.0",
"Speckle.DoubleNumerics": "4.1.0",
"Speckle.Newtonsoft.Json": "13.0.2",
"Speckle.Sdk.Dependencies": "3.5.3"
"Speckle.Sdk.Dependencies": "3.4.3"
}
},
"Speckle.Sdk.Dependencies": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "kC15SE4yZoVTasgywCm0SpY9yjBsQeUIDt4qoscYAgbn9pe0jj3uM0hZeJUCxn9Fdoj64OfQBpCKzR7VqhkwHQ=="
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "PyJAt9WAeVLUfxp/l1ZvGw20HAsvfBY/JgZCJmY5doc8lFa/9dhUMBJN/cNsVM5XJK+xdIBoEemgl3SMFwXNcg=="
}
},
".NETFramework,Version=v4.8/win-x64": {
@@ -259,9 +259,9 @@
"dependencies": {
"Microsoft.Extensions.DependencyInjection": "[2.2.0, )",
"Speckle.Connectors.Logging": "[1.0.0, )",
"Speckle.Objects": "[3.5.3, )",
"Speckle.Sdk": "[3.5.3, )",
"Speckle.Sdk.Dependencies": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )",
"Speckle.Sdk": "[3.4.3, )",
"Speckle.Sdk.Dependencies": "[3.4.3, )"
}
},
"speckle.connectors.dui": {
@@ -285,7 +285,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Speckle.Objects": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )"
}
},
"speckle.converters.navisworks2022": {
@@ -337,18 +337,18 @@
},
"Speckle.Objects": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "T3xwwoALVGmhIuEjlDrTdDXZ9haFILT32r8OACWrRUItU3xMkOWGyob51Ca1MHPmo8B5gvbk2Gnm8AgReGnxWg==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "08BOhVaYUvFP8CgY5fGZJWvswIRsH2EbOBGguJnanx+RZqKYI9XJroGGew+CDfPU1c8ZWl37WX2bbdPhdSP2rQ==",
"dependencies": {
"Speckle.Sdk": "3.5.3"
"Speckle.Sdk": "3.4.3"
}
},
"Speckle.Sdk": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "o+HefwtPZBqyuUHEnKF+qb/ctCAlNc2BYIw3ULEsZ93zweHt5wOMvOeuPxIXR0Gvj3fg6yNlY2nUcdFEduIXYA==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "21Dg8kMOqUbV7jyhK7N+UwyO7S1++COMR5jU9mm/vx86pkj6pTAifNZMHmuG8/ZnwpBcUCmE4AzvW24mKlgEkg==",
"dependencies": {
"GraphQL.Client": "6.0.0",
"Microsoft.Bcl.AsyncInterfaces": "5.0.0",
@@ -358,14 +358,14 @@
"Microsoft.Extensions.Logging": "2.2.0",
"Speckle.DoubleNumerics": "4.1.0",
"Speckle.Newtonsoft.Json": "13.0.2",
"Speckle.Sdk.Dependencies": "3.5.3"
"Speckle.Sdk.Dependencies": "3.4.3"
}
},
"Speckle.Sdk.Dependencies": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "kC15SE4yZoVTasgywCm0SpY9yjBsQeUIDt4qoscYAgbn9pe0jj3uM0hZeJUCxn9Fdoj64OfQBpCKzR7VqhkwHQ=="
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "PyJAt9WAeVLUfxp/l1ZvGw20HAsvfBY/JgZCJmY5doc8lFa/9dhUMBJN/cNsVM5XJK+xdIBoEemgl3SMFwXNcg=="
}
},
".NETFramework,Version=v4.8/win-x64": {
@@ -259,9 +259,9 @@
"dependencies": {
"Microsoft.Extensions.DependencyInjection": "[2.2.0, )",
"Speckle.Connectors.Logging": "[1.0.0, )",
"Speckle.Objects": "[3.5.3, )",
"Speckle.Sdk": "[3.5.3, )",
"Speckle.Sdk.Dependencies": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )",
"Speckle.Sdk": "[3.4.3, )",
"Speckle.Sdk.Dependencies": "[3.4.3, )"
}
},
"speckle.connectors.dui": {
@@ -285,7 +285,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Speckle.Objects": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )"
}
},
"speckle.converters.navisworks2023": {
@@ -337,18 +337,18 @@
},
"Speckle.Objects": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "T3xwwoALVGmhIuEjlDrTdDXZ9haFILT32r8OACWrRUItU3xMkOWGyob51Ca1MHPmo8B5gvbk2Gnm8AgReGnxWg==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "08BOhVaYUvFP8CgY5fGZJWvswIRsH2EbOBGguJnanx+RZqKYI9XJroGGew+CDfPU1c8ZWl37WX2bbdPhdSP2rQ==",
"dependencies": {
"Speckle.Sdk": "3.5.3"
"Speckle.Sdk": "3.4.3"
}
},
"Speckle.Sdk": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "o+HefwtPZBqyuUHEnKF+qb/ctCAlNc2BYIw3ULEsZ93zweHt5wOMvOeuPxIXR0Gvj3fg6yNlY2nUcdFEduIXYA==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "21Dg8kMOqUbV7jyhK7N+UwyO7S1++COMR5jU9mm/vx86pkj6pTAifNZMHmuG8/ZnwpBcUCmE4AzvW24mKlgEkg==",
"dependencies": {
"GraphQL.Client": "6.0.0",
"Microsoft.Bcl.AsyncInterfaces": "5.0.0",
@@ -358,14 +358,14 @@
"Microsoft.Extensions.Logging": "2.2.0",
"Speckle.DoubleNumerics": "4.1.0",
"Speckle.Newtonsoft.Json": "13.0.2",
"Speckle.Sdk.Dependencies": "3.5.3"
"Speckle.Sdk.Dependencies": "3.4.3"
}
},
"Speckle.Sdk.Dependencies": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "kC15SE4yZoVTasgywCm0SpY9yjBsQeUIDt4qoscYAgbn9pe0jj3uM0hZeJUCxn9Fdoj64OfQBpCKzR7VqhkwHQ=="
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "PyJAt9WAeVLUfxp/l1ZvGw20HAsvfBY/JgZCJmY5doc8lFa/9dhUMBJN/cNsVM5XJK+xdIBoEemgl3SMFwXNcg=="
}
},
".NETFramework,Version=v4.8/win-x64": {
@@ -259,9 +259,9 @@
"dependencies": {
"Microsoft.Extensions.DependencyInjection": "[2.2.0, )",
"Speckle.Connectors.Logging": "[1.0.0, )",
"Speckle.Objects": "[3.5.3, )",
"Speckle.Sdk": "[3.5.3, )",
"Speckle.Sdk.Dependencies": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )",
"Speckle.Sdk": "[3.4.3, )",
"Speckle.Sdk.Dependencies": "[3.4.3, )"
}
},
"speckle.connectors.dui": {
@@ -285,7 +285,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Speckle.Objects": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )"
}
},
"speckle.converters.navisworks2024": {
@@ -337,18 +337,18 @@
},
"Speckle.Objects": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "T3xwwoALVGmhIuEjlDrTdDXZ9haFILT32r8OACWrRUItU3xMkOWGyob51Ca1MHPmo8B5gvbk2Gnm8AgReGnxWg==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "08BOhVaYUvFP8CgY5fGZJWvswIRsH2EbOBGguJnanx+RZqKYI9XJroGGew+CDfPU1c8ZWl37WX2bbdPhdSP2rQ==",
"dependencies": {
"Speckle.Sdk": "3.5.3"
"Speckle.Sdk": "3.4.3"
}
},
"Speckle.Sdk": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "o+HefwtPZBqyuUHEnKF+qb/ctCAlNc2BYIw3ULEsZ93zweHt5wOMvOeuPxIXR0Gvj3fg6yNlY2nUcdFEduIXYA==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "21Dg8kMOqUbV7jyhK7N+UwyO7S1++COMR5jU9mm/vx86pkj6pTAifNZMHmuG8/ZnwpBcUCmE4AzvW24mKlgEkg==",
"dependencies": {
"GraphQL.Client": "6.0.0",
"Microsoft.Bcl.AsyncInterfaces": "5.0.0",
@@ -358,14 +358,14 @@
"Microsoft.Extensions.Logging": "2.2.0",
"Speckle.DoubleNumerics": "4.1.0",
"Speckle.Newtonsoft.Json": "13.0.2",
"Speckle.Sdk.Dependencies": "3.5.3"
"Speckle.Sdk.Dependencies": "3.4.3"
}
},
"Speckle.Sdk.Dependencies": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "kC15SE4yZoVTasgywCm0SpY9yjBsQeUIDt4qoscYAgbn9pe0jj3uM0hZeJUCxn9Fdoj64OfQBpCKzR7VqhkwHQ=="
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "PyJAt9WAeVLUfxp/l1ZvGw20HAsvfBY/JgZCJmY5doc8lFa/9dhUMBJN/cNsVM5XJK+xdIBoEemgl3SMFwXNcg=="
}
},
".NETFramework,Version=v4.8/win-x64": {
@@ -265,9 +265,9 @@
"dependencies": {
"Microsoft.Extensions.DependencyInjection": "[2.2.0, )",
"Speckle.Connectors.Logging": "[1.0.0, )",
"Speckle.Objects": "[3.5.3, )",
"Speckle.Sdk": "[3.5.3, )",
"Speckle.Sdk.Dependencies": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )",
"Speckle.Sdk": "[3.4.3, )",
"Speckle.Sdk.Dependencies": "[3.4.3, )"
}
},
"speckle.connectors.dui": {
@@ -291,7 +291,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Speckle.Objects": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )"
}
},
"speckle.converters.navisworks2025": {
@@ -337,18 +337,18 @@
},
"Speckle.Objects": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "T3xwwoALVGmhIuEjlDrTdDXZ9haFILT32r8OACWrRUItU3xMkOWGyob51Ca1MHPmo8B5gvbk2Gnm8AgReGnxWg==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "08BOhVaYUvFP8CgY5fGZJWvswIRsH2EbOBGguJnanx+RZqKYI9XJroGGew+CDfPU1c8ZWl37WX2bbdPhdSP2rQ==",
"dependencies": {
"Speckle.Sdk": "3.5.3"
"Speckle.Sdk": "3.4.3"
}
},
"Speckle.Sdk": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "o+HefwtPZBqyuUHEnKF+qb/ctCAlNc2BYIw3ULEsZ93zweHt5wOMvOeuPxIXR0Gvj3fg6yNlY2nUcdFEduIXYA==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "21Dg8kMOqUbV7jyhK7N+UwyO7S1++COMR5jU9mm/vx86pkj6pTAifNZMHmuG8/ZnwpBcUCmE4AzvW24mKlgEkg==",
"dependencies": {
"GraphQL.Client": "6.0.0",
"Microsoft.Bcl.AsyncInterfaces": "5.0.0",
@@ -358,14 +358,14 @@
"Microsoft.Extensions.Logging": "2.2.0",
"Speckle.DoubleNumerics": "4.1.0",
"Speckle.Newtonsoft.Json": "13.0.2",
"Speckle.Sdk.Dependencies": "3.5.3"
"Speckle.Sdk.Dependencies": "3.4.3"
}
},
"Speckle.Sdk.Dependencies": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "kC15SE4yZoVTasgywCm0SpY9yjBsQeUIDt4qoscYAgbn9pe0jj3uM0hZeJUCxn9Fdoj64OfQBpCKzR7VqhkwHQ=="
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "PyJAt9WAeVLUfxp/l1ZvGw20HAsvfBY/JgZCJmY5doc8lFa/9dhUMBJN/cNsVM5XJK+xdIBoEemgl3SMFwXNcg=="
}
},
".NETFramework,Version=v4.8/win-x64": {
@@ -266,9 +266,9 @@
"dependencies": {
"Microsoft.Extensions.DependencyInjection": "[2.2.0, )",
"Speckle.Connectors.Logging": "[1.0.0, )",
"Speckle.Objects": "[3.5.3, )",
"Speckle.Sdk": "[3.5.3, )",
"Speckle.Sdk.Dependencies": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )",
"Speckle.Sdk": "[3.4.3, )",
"Speckle.Sdk.Dependencies": "[3.4.3, )"
}
},
"speckle.connectors.dui": {
@@ -292,7 +292,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Speckle.Objects": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )"
}
},
"speckle.converters.navisworks2026": {
@@ -339,18 +339,18 @@
},
"Speckle.Objects": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "T3xwwoALVGmhIuEjlDrTdDXZ9haFILT32r8OACWrRUItU3xMkOWGyob51Ca1MHPmo8B5gvbk2Gnm8AgReGnxWg==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "08BOhVaYUvFP8CgY5fGZJWvswIRsH2EbOBGguJnanx+RZqKYI9XJroGGew+CDfPU1c8ZWl37WX2bbdPhdSP2rQ==",
"dependencies": {
"Speckle.Sdk": "3.5.3"
"Speckle.Sdk": "3.4.3"
}
},
"Speckle.Sdk": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "o+HefwtPZBqyuUHEnKF+qb/ctCAlNc2BYIw3ULEsZ93zweHt5wOMvOeuPxIXR0Gvj3fg6yNlY2nUcdFEduIXYA==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "21Dg8kMOqUbV7jyhK7N+UwyO7S1++COMR5jU9mm/vx86pkj6pTAifNZMHmuG8/ZnwpBcUCmE4AzvW24mKlgEkg==",
"dependencies": {
"GraphQL.Client": "6.0.0",
"Microsoft.Bcl.AsyncInterfaces": "5.0.0",
@@ -360,14 +360,14 @@
"Microsoft.Extensions.Logging": "2.2.0",
"Speckle.DoubleNumerics": "4.1.0",
"Speckle.Newtonsoft.Json": "13.0.2",
"Speckle.Sdk.Dependencies": "3.5.3"
"Speckle.Sdk.Dependencies": "3.4.3"
}
},
"Speckle.Sdk.Dependencies": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "kC15SE4yZoVTasgywCm0SpY9yjBsQeUIDt4qoscYAgbn9pe0jj3uM0hZeJUCxn9Fdoj64OfQBpCKzR7VqhkwHQ=="
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "PyJAt9WAeVLUfxp/l1ZvGw20HAsvfBY/JgZCJmY5doc8lFa/9dhUMBJN/cNsVM5XJK+xdIBoEemgl3SMFwXNcg=="
}
},
".NETFramework,Version=v4.8/win-x64": {
@@ -73,7 +73,6 @@ public class NavisworksSendBinding : ISendBinding
new IncludeInternalPropertiesSetting(false),
new ConvertHiddenElementsSetting(false),
new PreserveModelHierarchySetting(false),
new RevitCategoryMappingSetting(false)
];
public async Task Send(string modelCardId) =>
@@ -94,8 +93,7 @@ public class NavisworksSendBinding : ISendBinding
visualRepresentationMode: _toSpeckleSettingsManagerNavisworks.GetVisualRepresentationMode(modelCard),
convertHiddenElements: _toSpeckleSettingsManagerNavisworks.GetConvertHiddenElements(modelCard),
includeInternalProperties: _toSpeckleSettingsManagerNavisworks.GetIncludeInternalProperties(modelCard),
preserveModelHierarchy: _toSpeckleSettingsManagerNavisworks.GetPreserveModelHierarchy(modelCard),
mappingToRevitCategories: _toSpeckleSettingsManagerNavisworks.GetMappingToRevitCategories(modelCard)
preserveModelHierarchy: _toSpeckleSettingsManagerNavisworks.GetPreserveModelHierarchy(modelCard)
)
);
@@ -151,22 +151,22 @@ public class NavisworksSavedViewsFilter : DiscriminatedObject, ISendFilterSelect
foreach (NAV.SavedItem item in ((NAV.GroupItem)parentItem).Children)
{
switch (item)
switch (item.IsGroup)
{
// case NAV.SavedViewpoint { ContainsVisibilityOverrides: false }:
// Legacy defensive behaviour: skip viewpoints without visibility overrides.
// Essentially, send everything, or whatever the current view state for hidden elements is.
// break;
case NAV.SavedViewpointAnimationCut:
// Skip animation cuts.
// THIS IS COMMENTED OUT AS IT IS LEGACY DEFENSIVE BEHAVIOUR - DISCUSSION REQUIRED
// case false when item is NAV.SavedViewpoint { ContainsVisibilityOverrides: false }:
// // If the saved view does not contain visibility overrides, this is effectively everything in the model.
// // This will need to be the documented behaviour.
// break;
case false:
collectedSets.Add((NAV.SavedViewpoint)item);
break;
case NAV.SavedViewpoint savedViewpoint:
collectedSets.Add(savedViewpoint);
default: // handles item.IsGroup == true
if (((NAV.GroupItem)item).Children.Count > 0) // Don't add empty groups
{
CollectSavedViews(item, collectedSets);
}
break;
case NAV.GroupItem groupItem when groupItem.Children.Count > 0:
CollectSavedViews(groupItem, collectedSets);
break;
// No action for empty groups or unknown types.
}
}
}
@@ -32,9 +32,18 @@ public class NavisworksRootObjectBuilder(
internal NavisworksConversionSettings GetCurrentSettings() => converterSettings.Current;
/// <summary>
/// Asynchronously builds a Speckle object hierarchy from Navisworks model items.
/// </summary>
/// <param name="navisworksModelItems">The list of Navisworks items to convert.</param>
/// <param name="sendInfo">Information about the send operation.</param>
/// <param name="onOperationProgressed">Progress reporting callback.</param>
/// <param name="cancellationToken">Token to cancel the operation.</param>
/// <returns>A result containing the root collection and conversion results.</returns>
/// <exception cref="SpeckleException">Thrown when no objects can be converted.</exception>
public async Task<RootObjectBuilderResult> Build(
IReadOnlyList<NAV.ModelItem> navisworksModelItems,
string projectId,
SendInfo sendInfo,
IProgress<CardProgress> onOperationProgressed,
CancellationToken cancellationToken
)
@@ -45,7 +54,7 @@ public class NavisworksRootObjectBuilder(
#endif
using var activity = activityFactory.Start("Build");
ValidateInputs(navisworksModelItems, projectId, onOperationProgressed);
ValidateInputs(navisworksModelItems, sendInfo, onOperationProgressed);
// 2. Initialize root collection
var rootCollection = InitializeRootCollection();
@@ -53,7 +62,7 @@ public class NavisworksRootObjectBuilder(
// 3. Convert all model items and store results
var (convertedElements, conversionResults) = await ConvertModelItemsAsync(
navisworksModelItems,
projectId,
sendInfo,
onOperationProgressed,
cancellationToken
);
@@ -71,7 +80,7 @@ public class NavisworksRootObjectBuilder(
private static void ValidateInputs(
IReadOnlyList<NAV.ModelItem> navisworksModelItems,
string projectId,
SendInfo sendInfo,
IProgress<CardProgress> onOperationProgressed
)
{
@@ -85,11 +94,9 @@ public class NavisworksRootObjectBuilder(
throw new ArgumentNullException(nameof(navisworksModelItems));
}
if (onOperationProgressed == null || projectId == null)
if (onOperationProgressed == null || sendInfo == null)
{
throw new ArgumentNullException(
onOperationProgressed == null ? nameof(onOperationProgressed) : nameof(projectId)
);
throw new ArgumentNullException(onOperationProgressed == null ? nameof(onOperationProgressed) : nameof(sendInfo));
}
}
@@ -102,7 +109,7 @@ public class NavisworksRootObjectBuilder(
private Task<(Dictionary<string, Base?> converted, List<SendConversionResult> results)> ConvertModelItemsAsync(
IReadOnlyList<NAV.ModelItem> navisworksModelItems,
string projectId,
SendInfo sendInfo,
IProgress<CardProgress> onOperationProgressed,
CancellationToken cancellationToken
)
@@ -115,7 +122,7 @@ public class NavisworksRootObjectBuilder(
foreach (var item in navisworksModelItems)
{
cancellationToken.ThrowIfCancellationRequested();
var converted = ConvertNavisworksItem(item, convertedBases, projectId);
var converted = ConvertNavisworksItem(item, convertedBases, sendInfo);
results.Add(converted);
processedCount++;
onOperationProgressed.Report(new CardProgress("Converting", (double)processedCount / totalCount));
@@ -303,7 +310,7 @@ public class NavisworksRootObjectBuilder(
private SendConversionResult ConvertNavisworksItem(
NAV.ModelItem navisworksItem,
Dictionary<string, Base?> convertedBases,
string projectId
SendInfo sendInfo
)
{
string applicationId = elementSelectionService.GetModelItemPath(navisworksItem);
@@ -311,7 +318,7 @@ public class NavisworksRootObjectBuilder(
try
{
Base converted = sendConversionCache.TryGetValue(applicationId, projectId, out ObjectReference? cached)
Base converted = sendConversionCache.TryGetValue(applicationId, sendInfo.ProjectId, out ObjectReference? cached)
? cached
: rootToSpeckleConverter.Convert(navisworksItem);
@@ -1,12 +0,0 @@
using Speckle.Connectors.DUI.Settings;
namespace Speckle.Connector.Navisworks.Operations.Send.Settings;
public class RevitCategoryMappingSetting(bool value) : ICardSetting
{
public string? Id { get; set; } = "mappingToRevitCategories";
public string? Title { get; set; } = "Map to Revit Categories";
public string? Type { get; set; } = "boolean";
public List<string>? Enum { get; set; }
public object? Value { get; set; } = value;
}
@@ -18,7 +18,6 @@ public class ToSpeckleSettingsManagerNavisworks : IToSpeckleSettingsManagerNavis
private readonly Dictionary<string, bool?> _convertHiddenElementsCache = [];
private readonly Dictionary<string, bool?> _includeInternalPropertiesCache = [];
private readonly Dictionary<string, bool?> _preserveModelHierarchyCache = [];
private readonly Dictionary<string, bool?> _revitCategoryMappingCache = [];
public ToSpeckleSettingsManagerNavisworks(ISendConversionCache sendConversionCache)
{
@@ -64,41 +63,23 @@ public class ToSpeckleSettingsManagerNavisworks : IToSpeckleSettingsManagerNavis
throw new ArgumentNullException(nameof(modelCard));
}
var originString = modelCard.Settings?.FirstOrDefault(s => s.Id == "originMode")?.Value as string;
if (!OriginModeSetting.OriginModeMap.TryGetValue(originString ?? string.Empty, out var origin))
var originString = modelCard.Settings?.First(s => s.Id == "originMode").Value as string;
if (originString is not null && OriginModeSetting.OriginModeMap.TryGetValue(originString, out OriginMode origin))
{
return OriginMode.ModelOrigin; // Default to ModelOrigin if not specified or invalid
}
if (_originModeCache.TryGetValue(modelCard.ModelCardId.NotNull(), out var previousType) && previousType != origin)
{
EvictCacheForModelCard(modelCard);
}
_originModeCache[modelCard.ModelCardId.NotNull()] = origin;
return origin;
}
public bool GetMappingToRevitCategories(SenderModelCard modelCard)
{
if (modelCard == null)
{
throw new ArgumentNullException(nameof(modelCard));
}
var value = modelCard.Settings?.FirstOrDefault(s => s.Id == "mappingToRevitCategories")?.Value as bool?;
var returnValue = value != null && value.NotNull();
if (_revitCategoryMappingCache.TryGetValue(modelCard.ModelCardId.NotNull(), out var previousValue))
{
if (previousValue != returnValue)
if (_originModeCache.TryGetValue(modelCard.ModelCardId.NotNull(), out OriginMode previousType))
{
EvictCacheForModelCard(modelCard);
if (previousType != origin)
{
EvictCacheForModelCard(modelCard);
}
}
_originModeCache[modelCard.ModelCardId.NotNull()] = origin;
return origin;
}
_revitCategoryMappingCache[modelCard.ModelCardId] = returnValue;
return returnValue;
throw new ArgumentException($"Invalid origin mode value: {originString}");
}
public bool GetConvertHiddenElements(SenderModelCard modelCard)
@@ -25,11 +25,10 @@
<Compile Include="$(MSBuildThisFileDirectory)Operations\Send\GeometryNodeMerger.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)Operations\Send\NavisworksHierarchyBuilder.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Operations\Send\NavisworksRootObjectBuilder.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)Operations\Send\Settings\ConvertHiddenElementsSetting.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Operations\Send\Settings\ConvertHiddenEleementsSetting.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)Operations\Send\Settings\IncludeInternalPropertiesSetting.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)Operations\Send\Settings\OriginModeSetting.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)Operations\Send\Settings\PreserveModelHierarchySetting.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Operations\Send\Settings\RevitCategoryMapping.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Operations\Send\Settings\ToSpeckleSettingsManagerNavisworks.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)Operations\Send\Settings\VisualRepresentationSetting.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)Operations\Send\Filters\NavisworksSelectionFilter.cs"/>
@@ -281,9 +281,9 @@
"dependencies": {
"Microsoft.Extensions.DependencyInjection": "[2.2.0, )",
"Speckle.Connectors.Logging": "[1.0.0, )",
"Speckle.Objects": "[3.5.3, )",
"Speckle.Sdk": "[3.5.3, )",
"Speckle.Sdk.Dependencies": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )",
"Speckle.Sdk": "[3.4.3, )",
"Speckle.Sdk.Dependencies": "[3.4.3, )"
}
},
"speckle.connectors.dui": {
@@ -306,7 +306,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Speckle.Objects": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )"
}
},
"speckle.converters.revit2022": {
@@ -351,11 +351,11 @@
},
"Speckle.Objects": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "T3xwwoALVGmhIuEjlDrTdDXZ9haFILT32r8OACWrRUItU3xMkOWGyob51Ca1MHPmo8B5gvbk2Gnm8AgReGnxWg==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "08BOhVaYUvFP8CgY5fGZJWvswIRsH2EbOBGguJnanx+RZqKYI9XJroGGew+CDfPU1c8ZWl37WX2bbdPhdSP2rQ==",
"dependencies": {
"Speckle.Sdk": "3.5.3"
"Speckle.Sdk": "3.4.3"
}
},
"Speckle.Revit.API": {
@@ -366,9 +366,9 @@
},
"Speckle.Sdk": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "o+HefwtPZBqyuUHEnKF+qb/ctCAlNc2BYIw3ULEsZ93zweHt5wOMvOeuPxIXR0Gvj3fg6yNlY2nUcdFEduIXYA==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "21Dg8kMOqUbV7jyhK7N+UwyO7S1++COMR5jU9mm/vx86pkj6pTAifNZMHmuG8/ZnwpBcUCmE4AzvW24mKlgEkg==",
"dependencies": {
"GraphQL.Client": "6.0.0",
"Microsoft.Bcl.AsyncInterfaces": "5.0.0",
@@ -378,14 +378,14 @@
"Microsoft.Extensions.Logging": "2.2.0",
"Speckle.DoubleNumerics": "4.1.0",
"Speckle.Newtonsoft.Json": "13.0.2",
"Speckle.Sdk.Dependencies": "3.5.3"
"Speckle.Sdk.Dependencies": "3.4.3"
}
},
"Speckle.Sdk.Dependencies": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "kC15SE4yZoVTasgywCm0SpY9yjBsQeUIDt4qoscYAgbn9pe0jj3uM0hZeJUCxn9Fdoj64OfQBpCKzR7VqhkwHQ=="
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "PyJAt9WAeVLUfxp/l1ZvGw20HAsvfBY/JgZCJmY5doc8lFa/9dhUMBJN/cNsVM5XJK+xdIBoEemgl3SMFwXNcg=="
}
}
}
@@ -281,9 +281,9 @@
"dependencies": {
"Microsoft.Extensions.DependencyInjection": "[2.2.0, )",
"Speckle.Connectors.Logging": "[1.0.0, )",
"Speckle.Objects": "[3.5.3, )",
"Speckle.Sdk": "[3.5.3, )",
"Speckle.Sdk.Dependencies": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )",
"Speckle.Sdk": "[3.4.3, )",
"Speckle.Sdk.Dependencies": "[3.4.3, )"
}
},
"speckle.connectors.dui": {
@@ -306,7 +306,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Speckle.Objects": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )"
}
},
"speckle.converters.revit2023": {
@@ -351,11 +351,11 @@
},
"Speckle.Objects": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "T3xwwoALVGmhIuEjlDrTdDXZ9haFILT32r8OACWrRUItU3xMkOWGyob51Ca1MHPmo8B5gvbk2Gnm8AgReGnxWg==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "08BOhVaYUvFP8CgY5fGZJWvswIRsH2EbOBGguJnanx+RZqKYI9XJroGGew+CDfPU1c8ZWl37WX2bbdPhdSP2rQ==",
"dependencies": {
"Speckle.Sdk": "3.5.3"
"Speckle.Sdk": "3.4.3"
}
},
"Speckle.Revit.API": {
@@ -366,9 +366,9 @@
},
"Speckle.Sdk": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "o+HefwtPZBqyuUHEnKF+qb/ctCAlNc2BYIw3ULEsZ93zweHt5wOMvOeuPxIXR0Gvj3fg6yNlY2nUcdFEduIXYA==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "21Dg8kMOqUbV7jyhK7N+UwyO7S1++COMR5jU9mm/vx86pkj6pTAifNZMHmuG8/ZnwpBcUCmE4AzvW24mKlgEkg==",
"dependencies": {
"GraphQL.Client": "6.0.0",
"Microsoft.Bcl.AsyncInterfaces": "5.0.0",
@@ -378,14 +378,14 @@
"Microsoft.Extensions.Logging": "2.2.0",
"Speckle.DoubleNumerics": "4.1.0",
"Speckle.Newtonsoft.Json": "13.0.2",
"Speckle.Sdk.Dependencies": "3.5.3"
"Speckle.Sdk.Dependencies": "3.4.3"
}
},
"Speckle.Sdk.Dependencies": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "kC15SE4yZoVTasgywCm0SpY9yjBsQeUIDt4qoscYAgbn9pe0jj3uM0hZeJUCxn9Fdoj64OfQBpCKzR7VqhkwHQ=="
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "PyJAt9WAeVLUfxp/l1ZvGw20HAsvfBY/JgZCJmY5doc8lFa/9dhUMBJN/cNsVM5XJK+xdIBoEemgl3SMFwXNcg=="
}
}
}
@@ -281,9 +281,9 @@
"dependencies": {
"Microsoft.Extensions.DependencyInjection": "[2.2.0, )",
"Speckle.Connectors.Logging": "[1.0.0, )",
"Speckle.Objects": "[3.5.3, )",
"Speckle.Sdk": "[3.5.3, )",
"Speckle.Sdk.Dependencies": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )",
"Speckle.Sdk": "[3.4.3, )",
"Speckle.Sdk.Dependencies": "[3.4.3, )"
}
},
"speckle.connectors.dui": {
@@ -306,7 +306,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Speckle.Objects": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )"
}
},
"speckle.converters.revit2024": {
@@ -351,11 +351,11 @@
},
"Speckle.Objects": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "T3xwwoALVGmhIuEjlDrTdDXZ9haFILT32r8OACWrRUItU3xMkOWGyob51Ca1MHPmo8B5gvbk2Gnm8AgReGnxWg==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "08BOhVaYUvFP8CgY5fGZJWvswIRsH2EbOBGguJnanx+RZqKYI9XJroGGew+CDfPU1c8ZWl37WX2bbdPhdSP2rQ==",
"dependencies": {
"Speckle.Sdk": "3.5.3"
"Speckle.Sdk": "3.4.3"
}
},
"Speckle.Revit.API": {
@@ -366,9 +366,9 @@
},
"Speckle.Sdk": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "o+HefwtPZBqyuUHEnKF+qb/ctCAlNc2BYIw3ULEsZ93zweHt5wOMvOeuPxIXR0Gvj3fg6yNlY2nUcdFEduIXYA==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "21Dg8kMOqUbV7jyhK7N+UwyO7S1++COMR5jU9mm/vx86pkj6pTAifNZMHmuG8/ZnwpBcUCmE4AzvW24mKlgEkg==",
"dependencies": {
"GraphQL.Client": "6.0.0",
"Microsoft.Bcl.AsyncInterfaces": "5.0.0",
@@ -378,14 +378,14 @@
"Microsoft.Extensions.Logging": "2.2.0",
"Speckle.DoubleNumerics": "4.1.0",
"Speckle.Newtonsoft.Json": "13.0.2",
"Speckle.Sdk.Dependencies": "3.5.3"
"Speckle.Sdk.Dependencies": "3.4.3"
}
},
"Speckle.Sdk.Dependencies": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "kC15SE4yZoVTasgywCm0SpY9yjBsQeUIDt4qoscYAgbn9pe0jj3uM0hZeJUCxn9Fdoj64OfQBpCKzR7VqhkwHQ=="
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "PyJAt9WAeVLUfxp/l1ZvGw20HAsvfBY/JgZCJmY5doc8lFa/9dhUMBJN/cNsVM5XJK+xdIBoEemgl3SMFwXNcg=="
}
}
}
@@ -226,9 +226,9 @@
"dependencies": {
"Microsoft.Extensions.DependencyInjection": "[2.2.0, )",
"Speckle.Connectors.Logging": "[1.0.0, )",
"Speckle.Objects": "[3.5.3, )",
"Speckle.Sdk": "[3.5.3, )",
"Speckle.Sdk.Dependencies": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )",
"Speckle.Sdk": "[3.4.3, )",
"Speckle.Sdk.Dependencies": "[3.4.3, )"
}
},
"speckle.connectors.dui": {
@@ -251,7 +251,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Speckle.Objects": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )"
}
},
"speckle.converters.revit2025": {
@@ -296,11 +296,11 @@
},
"Speckle.Objects": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "T3xwwoALVGmhIuEjlDrTdDXZ9haFILT32r8OACWrRUItU3xMkOWGyob51Ca1MHPmo8B5gvbk2Gnm8AgReGnxWg==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "08BOhVaYUvFP8CgY5fGZJWvswIRsH2EbOBGguJnanx+RZqKYI9XJroGGew+CDfPU1c8ZWl37WX2bbdPhdSP2rQ==",
"dependencies": {
"Speckle.Sdk": "3.5.3"
"Speckle.Sdk": "3.4.3"
}
},
"Speckle.Revit.API": {
@@ -311,9 +311,9 @@
},
"Speckle.Sdk": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "o+HefwtPZBqyuUHEnKF+qb/ctCAlNc2BYIw3ULEsZ93zweHt5wOMvOeuPxIXR0Gvj3fg6yNlY2nUcdFEduIXYA==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "21Dg8kMOqUbV7jyhK7N+UwyO7S1++COMR5jU9mm/vx86pkj6pTAifNZMHmuG8/ZnwpBcUCmE4AzvW24mKlgEkg==",
"dependencies": {
"GraphQL.Client": "6.0.0",
"Microsoft.Data.Sqlite": "7.0.5",
@@ -321,14 +321,14 @@
"Microsoft.Extensions.Logging": "2.2.0",
"Speckle.DoubleNumerics": "4.1.0",
"Speckle.Newtonsoft.Json": "13.0.2",
"Speckle.Sdk.Dependencies": "3.5.3"
"Speckle.Sdk.Dependencies": "3.4.3"
}
},
"Speckle.Sdk.Dependencies": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "kC15SE4yZoVTasgywCm0SpY9yjBsQeUIDt4qoscYAgbn9pe0jj3uM0hZeJUCxn9Fdoj64OfQBpCKzR7VqhkwHQ=="
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "PyJAt9WAeVLUfxp/l1ZvGw20HAsvfBY/JgZCJmY5doc8lFa/9dhUMBJN/cNsVM5XJK+xdIBoEemgl3SMFwXNcg=="
}
},
"net8.0-windows7.0/win-x64": {
@@ -219,9 +219,9 @@
"dependencies": {
"Microsoft.Extensions.DependencyInjection": "[2.2.0, )",
"Speckle.Connectors.Logging": "[1.0.0, )",
"Speckle.Objects": "[3.5.3, )",
"Speckle.Sdk": "[3.5.3, )",
"Speckle.Sdk.Dependencies": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )",
"Speckle.Sdk": "[3.4.3, )",
"Speckle.Sdk.Dependencies": "[3.4.3, )"
}
},
"speckle.connectors.dui": {
@@ -244,7 +244,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Speckle.Objects": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )"
}
},
"speckle.converters.revit2026": {
@@ -280,11 +280,11 @@
},
"Speckle.Objects": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "T3xwwoALVGmhIuEjlDrTdDXZ9haFILT32r8OACWrRUItU3xMkOWGyob51Ca1MHPmo8B5gvbk2Gnm8AgReGnxWg==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "08BOhVaYUvFP8CgY5fGZJWvswIRsH2EbOBGguJnanx+RZqKYI9XJroGGew+CDfPU1c8ZWl37WX2bbdPhdSP2rQ==",
"dependencies": {
"Speckle.Sdk": "3.5.3"
"Speckle.Sdk": "3.4.3"
}
},
"Speckle.Revit.API": {
@@ -295,9 +295,9 @@
},
"Speckle.Sdk": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "o+HefwtPZBqyuUHEnKF+qb/ctCAlNc2BYIw3ULEsZ93zweHt5wOMvOeuPxIXR0Gvj3fg6yNlY2nUcdFEduIXYA==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "21Dg8kMOqUbV7jyhK7N+UwyO7S1++COMR5jU9mm/vx86pkj6pTAifNZMHmuG8/ZnwpBcUCmE4AzvW24mKlgEkg==",
"dependencies": {
"GraphQL.Client": "6.0.0",
"Microsoft.Data.Sqlite": "7.0.5",
@@ -305,14 +305,14 @@
"Microsoft.Extensions.Logging": "2.2.0",
"Speckle.DoubleNumerics": "4.1.0",
"Speckle.Newtonsoft.Json": "13.0.2",
"Speckle.Sdk.Dependencies": "3.5.3"
"Speckle.Sdk.Dependencies": "3.4.3"
}
},
"Speckle.Sdk.Dependencies": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "kC15SE4yZoVTasgywCm0SpY9yjBsQeUIDt4qoscYAgbn9pe0jj3uM0hZeJUCxn9Fdoj64OfQBpCKzR7VqhkwHQ=="
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "PyJAt9WAeVLUfxp/l1ZvGw20HAsvfBY/JgZCJmY5doc8lFa/9dhUMBJN/cNsVM5XJK+xdIBoEemgl3SMFwXNcg=="
}
},
"net8.0-windows7.0/win-x64": {
@@ -72,7 +72,6 @@ internal sealed class BasicConnectorBindingRevit : IBasicConnectorBinding
return new DocumentInfo("", "", "") { Message = "Family environment files not supported by Speckle." };
}
//should this use the Hashcode of the document instead of something like CreationGUID?
var info = new DocumentInfo(doc.PathName, doc.Title, doc.GetHashCode().ToString());
return info;
@@ -216,13 +216,12 @@ internal sealed class RevitSendBinding : RevitBaseBinding, ISendBinding
newSelectedObjectIds.Add(element.UniqueId);
}
// NOTE: preserve & persist original user selection for selection filter implemented during
// [CNX-2400](https://linear.app/speckle/issue/CNX-2400/object-dont-update-on-publish)
// NOTE: update with current document for views and categories filter since these represent dynamic queries
// View & categories filters self-update their SelectedObjectIds in RefreshObjectIds(), maintaining consistency
var objectIds =
modelCard.SendFilter is RevitSelectionFilter ? modelCard.SendFilter.SelectedObjectIds : newSelectedObjectIds;
await Commands.SetFilterObjectIds(modelCard.ModelCardId.NotNull(), modelCard.SendFilter.IdMap, objectIds);
// We update the state on the UI SenderModelCard to prevent potential inconsistencies between hostApp IdMap in sendfilters.
await Commands.SetFilterObjectIds(
modelCard.ModelCardId.NotNull(),
modelCard.SendFilter.IdMap,
newSelectedObjectIds
);
}
return documentElementContexts;
@@ -3,45 +3,48 @@ using Autodesk.Revit.DB.ExtensibleStorage;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Events;
using Microsoft.Extensions.Logging;
using Speckle.Connectors.Common.Threading;
using Speckle.Connectors.DUI.Bridge;
using Speckle.Connectors.DUI.Models;
using Speckle.Connectors.DUI.Utils;
using Speckle.Connectors.Revit.Plugin;
using Speckle.Converters.RevitShared.Helpers;
using Speckle.Sdk;
using Speckle.Sdk.Common;
using Speckle.Sdk.SQLite;
namespace Speckle.Connectors.Revit.HostApp;
// POC: should be interfaced out
internal sealed class RevitDocumentStore : DocumentModelStore
{
private readonly ILogger<RevitDocumentStore> _logger;
// POC: move to somewhere central?
private static readonly Guid s_revitDocumentStoreId = new("D35B3695-EDC9-4E15-B62A-D3FC2CB83FA3");
private readonly IAppIdleManager _idleManager;
private readonly RevitContext _revitContext;
private readonly DocumentModelStorageSchema _documentModelStorageSchema;
private readonly IdStorageSchema _idStorageSchema;
private readonly ITopLevelExceptionHandler _topLevelExceptionHandler;
private readonly ISqLiteJsonCacheManager _jsonCacheManager;
private readonly IThreadContext _threadContext;
public RevitDocumentStore(
ILogger<DocumentModelStore> logger,
IAppIdleManager idleManager,
RevitContext revitContext,
IJsonSerializer jsonSerializer,
DocumentModelStorageSchema documentModelStorageSchema,
IdStorageSchema idStorageSchema,
ITopLevelExceptionHandler topLevelExceptionHandler,
IRevitTask revitTask,
ISqLiteJsonCacheManagerFactory jsonCacheManagerFactory,
ILogger<RevitDocumentStore> logger
IThreadContext threadContext,
IRevitTask revitTask
)
: base(logger, jsonSerializer)
{
_jsonCacheManager = jsonCacheManagerFactory.CreateForUser("ConnectorsFileData");
_idleManager = idleManager;
_revitContext = revitContext;
_documentModelStorageSchema = documentModelStorageSchema;
_idStorageSchema = idStorageSchema;
_topLevelExceptionHandler = topLevelExceptionHandler;
_logger = logger;
_threadContext = threadContext;
UIApplication uiApplication = _revitContext.UIApplication.NotNull();
@@ -98,52 +101,80 @@ internal sealed class RevitDocumentStore : DocumentModelStore
return;
}
try
{
var key = GetKeyForDocument(document);
if (key != null)
_threadContext
.RunOnMain(() =>
{
_jsonCacheManager.UpdateObject(key, modelCardState);
}
}
catch (Exception ex) when (!ex.IsFatal())
{
var key = GetKeyForDocument(document);
_logger.LogError(ex, "Failed to save model card state for document {DocumentId}", key);
}
//if not the same active document then don't save the current cards to a bad document!
if (!EnsureActiveDocumentIsSame(document))
{
return;
}
using Transaction t = new(document, "Speckle Write State");
t.Start();
using DataStorage ds = GetSettingsDataStorage(document) ?? DataStorage.Create(document);
using Entity stateEntity = new(_documentModelStorageSchema.GetSchema());
string serializedModels = Serialize();
stateEntity.Set("contents", serializedModels);
using Entity idEntity = new(_idStorageSchema.GetSchema());
idEntity.Set("Id", s_revitDocumentStoreId);
ds.SetEntity(idEntity);
ds.SetEntity(stateEntity);
t.Commit();
})
.FireAndForget();
}
private string? GetKeyForDocument(Document doc)
private bool EnsureActiveDocumentIsSame(Document document)
{
string? id = doc?.ProjectInformation?.UniqueId; //ProjectInformation Should only be null for family docs
#if REVIT_2024_OR_GREATER
id ??= doc.CreationGUID.ToString(); //fallback for family docs
#endif
return id;
var localDoc = _revitContext.UIApplication?.ActiveUIDocument?.Document;
if (localDoc == null)
{
return false;
}
return localDoc.Equals(document);
}
protected override void LoadState()
{
var document = _revitContext.UIApplication?.ActiveUIDocument?.Document;
// POC: this can happen? A: Not really, imho (dim) (Adam seyz yes it can if loading also triggers a save)
if (document == null)
{
return;
}
var stateEntity = GetSpeckleEntity(document);
var stateEntity = GetSpeckleEntity(_revitContext.UIApplication?.ActiveUIDocument?.Document);
if (stateEntity == null || !stateEntity.IsValid())
{
ClearAndSave();
return;
}
var key = GetKeyForDocument(document);
if (key != null)
string modelsString = stateEntity.Get<string>("contents");
LoadFromString(modelsString);
}
private DataStorage? GetSettingsDataStorage(Document doc)
{
using FilteredElementCollector collector = new(doc);
FilteredElementCollector dataStorages = collector.OfClass(typeof(DataStorage));
foreach (Element element in dataStorages)
{
var state = _jsonCacheManager.GetObject(key);
LoadFromString(state);
DataStorage dataStorage = (DataStorage)element;
Entity settingIdEntity = dataStorage.GetEntity(_idStorageSchema.GetSchema());
if (!settingIdEntity.IsValid())
{
continue;
}
Guid id = settingIdEntity.Get<Guid>("Id");
if (!id.Equals(s_revitDocumentStoreId))
{
continue;
}
return dataStorage;
}
return null;
}
private Entity? GetSpeckleEntity(Document? doc)
@@ -19,7 +19,7 @@ public class ToHostSettingsManager : IToHostSettingsManager
public Transform? GetReferencePointSetting(ModelCard modelCard)
{
var referencePointString = modelCard.Settings?.FirstOrDefault(s => s.Id == "referencePoint")?.Value as string;
var referencePointString = modelCard.Settings?.First(s => s.Id == "referencePoint").Value as string;
if (
referencePointString is not null
&& ReferencePointSetting.ReferencePointMap.TryGetValue(
@@ -2,9 +2,7 @@ using Autodesk.Revit.DB;
using Speckle.Connectors.DUI.Exceptions;
using Speckle.Connectors.DUI.Models.Card.SendFilter;
using Speckle.Connectors.DUI.Utils;
using Speckle.Converters.RevitShared.Extensions;
using Speckle.Converters.RevitShared.Helpers;
using Speckle.Sdk;
namespace Speckle.Connectors.RevitShared.Operations.Send.Filters;
@@ -77,8 +75,8 @@ public class RevitViewsFilter : DiscriminatedObject, ISendFilter, IRevitSendFilt
//this used to throw an exception, but we don't want to fail loudly if the view is not found
return [];
}
IEnumerable<Element> elementsInView = GetFilteredElementsForView(view);
using var viewCollector = new FilteredElementCollector(_doc, view.Id);
var elementsInView = viewCollector.ToElements();
// NOTE: FilteredElementCollector() includes sweeps and reveals from a wall family's definition and includes them as additional objects
// on this return. displayValue for Wall already includes these, therefore we end up with duplicate elements on wall sweeps
@@ -127,52 +125,4 @@ public class RevitViewsFilter : DiscriminatedObject, ISendFilter, IRevitSendFilt
_revitContext = revitContext;
_doc = _revitContext.UIApplication?.ActiveUIDocument.Document;
}
// NOTE: Element collector returns parts and source elements even when Parts Visibility is set as "Show Parts" only.
// Below function collects list of ids to exclude from final list.
private HashSet<ElementId> GetSourceElementIdsToExclude(IEnumerable<Element> elements)
{
var elementsToExclude = new HashSet<ElementId>();
foreach (var element in elements)
{
// check if element is a part
if (element.Category?.GetBuiltInCategory() == BuiltInCategory.OST_Parts && element is Part part)
{
try
{
// get source element ids from the part
var sourceIds = part.GetSourceElementIds();
if (sourceIds != null)
{
foreach (var sourceId in sourceIds)
{
elementsToExclude.Add(sourceId.HostElementId);
}
}
}
catch (Exception e) when (!e.IsFatal())
{
// silently continue processing other Parts if one fails
// this follows the pattern used elsewhere in the codebase
}
}
}
return elementsToExclude;
}
private IEnumerable<Element> GetFilteredElementsForView(View view)
{
using var viewCollector = new FilteredElementCollector(_doc, view.Id);
var allElements = viewCollector.ToElements();
// parts filtering when view is set to show Parts only (and overwrites allElements)
if (view.PartsVisibility == PartsVisibility.ShowPartsOnly)
{
var idsToExclude = GetSourceElementIdsToExclude(allElements);
return allElements.Where(e => !idsToExclude.Contains(e.Id));
}
return allElements;
}
}
@@ -33,17 +33,17 @@ public class RevitRootObjectBuilder(
{
public Task<RootObjectBuilderResult> Build(
IReadOnlyList<DocumentToConvert> documentElementContexts,
string projectId,
SendInfo sendInfo,
IProgress<CardProgress> onOperationProgressed,
CancellationToken ct = default
) =>
threadContext.RunOnMainAsync(
() => Task.FromResult(BuildSync(documentElementContexts, projectId, onOperationProgressed, ct))
() => Task.FromResult(BuildSync(documentElementContexts, sendInfo, onOperationProgressed, ct))
);
private RootObjectBuilderResult BuildSync(
IReadOnlyList<DocumentToConvert> documentElementContexts,
string projectId,
SendInfo sendInfo,
IProgress<CardProgress> onOperationProgressed,
CancellationToken cancellationToken
)
@@ -183,7 +183,10 @@ public class RevitRootObjectBuilder(
// non-transformed elements can safely rely on cache
// TODO: Potential here to transform cached objects and NOT reconvert,
// TODO: we wont do !hasTransform here, and re-set application id before this
if (!hasTransform && sendConversionCache.TryGetValue(projectId, applicationId, out ObjectReference? value))
if (
!hasTransform
&& sendConversionCache.TryGetValue(sendInfo.ProjectId, applicationId, out ObjectReference? value)
)
{
converted = value;
cacheHitCount++;
@@ -225,16 +228,7 @@ public class RevitRootObjectBuilder(
}
}
// if we ended up skipping everything, there is a reason for this, that users can diagnose themselves
// this can occur if a published view contains only unsupported objects or if user trying to ONLY send linked model
// docs but the setting is disabled
if (skippedObjectCount == atomicObjectCount)
{
throw new SpeckleException("No supported objects visible. Update publish filter or check publish settings.");
}
// this is, I suppose, fully on us?
if (results.All(x => x.Status == Status.ERROR))
if (results.All(x => x.Status == Status.ERROR) || skippedObjectCount == atomicObjectCount)
{
throw new SpeckleException("Failed to convert all objects.");
}
@@ -37,7 +37,7 @@ public class ToSpeckleSettingsManager : IToSpeckleSettingsManager
public DetailLevelType GetDetailLevelSetting(SenderModelCard modelCard)
{
var fidelityString = modelCard.Settings?.FirstOrDefault(s => s.Id == "detailLevel")?.Value as string;
var fidelityString = modelCard.Settings?.First(s => s.Id == "detailLevel").Value as string;
if (
fidelityString is not null
&& DetailLevelSetting.GeometryFidelityMap.TryGetValue(fidelityString, out DetailLevelType fidelity)
@@ -59,7 +59,7 @@ public class ToSpeckleSettingsManager : IToSpeckleSettingsManager
public Transform? GetReferencePointSetting(ModelCard modelCard)
{
var referencePointString = modelCard.Settings?.FirstOrDefault(s => s.Id == "referencePoint")?.Value as string;
var referencePointString = modelCard.Settings?.First(s => s.Id == "referencePoint").Value as string;
if (
referencePointString is not null
&& ReferencePointSetting.ReferencePointMap.TryGetValue(
@@ -90,7 +90,7 @@ public class ToSpeckleSettingsManager : IToSpeckleSettingsManager
public bool GetSendParameterNullOrEmptyStringsSetting(SenderModelCard modelCard)
{
var value = modelCard.Settings?.FirstOrDefault(s => s.Id == "nullemptyparams")?.Value as bool?;
var value = modelCard.Settings?.First(s => s.Id == "nullemptyparams").Value as bool?;
var returnValue = value != null && value.NotNull();
if (_sendNullParamsCache.TryGetValue(modelCard.ModelCardId.NotNull(), out bool? previousValue))
{
@@ -108,7 +108,7 @@ public class ToSpeckleSettingsManager : IToSpeckleSettingsManager
// TODO: Evaluate cache invalidation for GetLinkedModelsSetting
public bool GetLinkedModelsSetting(SenderModelCard modelCard)
{
var value = modelCard.Settings?.FirstOrDefault(s => s.Id == "includeLinkedModels")?.Value as bool?;
var value = modelCard.Settings?.First(s => s.Id == "includeLinkedModels").Value as bool?;
var returnValue = value != null && value.NotNull();
if (_sendLinkedModelsCache.TryGetValue(modelCard.ModelCardId.NotNull(), out bool? previousValue))
@@ -124,7 +124,7 @@ public class ToSpeckleSettingsManager : IToSpeckleSettingsManager
public bool GetSendRebarsAsVolumetric(SenderModelCard modelCard)
{
var value = modelCard.Settings?.FirstOrDefault(s => s.Id == "sendRebarsAsVolumetric")?.Value as bool?;
var value = modelCard.Settings?.First(s => s.Id == "sendRebarsAsVolumetric").Value as bool?;
var returnValue = value != null && value.NotNull();
if (_sendRebarsAsVolumetricCache.TryGetValue(modelCard.ModelCardId.NotNull(), out bool? previousValue))
{
@@ -38,10 +38,6 @@ public class RevitThreadContext : ThreadContext
return default;
}
});
if (ex is OperationCanceledException operation)
{
throw operation;
}
if (ex is not null)
{
throw new SpeckleRevitTaskException(ex);
@@ -65,10 +61,6 @@ public class RevitThreadContext : ThreadContext
return default;
}
});
if (ex is OperationCanceledException operation)
{
throw operation;
}
if (ex is not null)
{
throw new SpeckleRevitTaskException(ex);
@@ -112,11 +104,6 @@ public class RevitThreadContext : ThreadContext
ex = e;
}
});
if (ex is OperationCanceledException operation)
{
throw operation;
}
if (ex is not null)
{
throw new SpeckleRevitTaskException(ex);
@@ -7,7 +7,7 @@ using Speckle.Sdk.Common;
namespace Speckle.Connectors.Revit.Plugin;
#pragma warning disable CA1032
public class SpeckleRevitTaskException(Exception exception) : SpeckleException(exception.Message, exception)
public class SpeckleRevitTaskException(Exception exception) : SpeckleException("Revit operation failed", exception)
#pragma warning restore CA1032
{
public static async Task ProcessException<T>(
@@ -37,9 +37,9 @@
<Compile Include="$(MSBuildThisFileDirectory)HostApp\SendCollectionManager.cs" />
<Compile Include="$(MSBuildThisFileDirectory)HostApp\ElementUnpacker.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Operations\Receive\ITransactionManager.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Operations\Receive\ReferencePointSetting.cs" />
<Compile Include="$(MSBuildThisFileDirectory)operations\receive\ReferencePointSetting.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Operations\Receive\RevitHostObjectBuilder.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Operations\Receive\ToHostSettingsManager.cs" />
<Compile Include="$(MSBuildThisFileDirectory)operations\receive\ToHostSettingsManager.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Operations\Receive\TransactionManager.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Operations\Send\Filters\IRevitSendFilter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Operations\Send\Filters\RevitCategoriesFilter.cs" />
@@ -61,4 +61,4 @@
<Compile Include="$(MSBuildThisFileDirectory)Plugin\RevitCefPlugin.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Plugin\SpeckleRevitTaskException.cs" />
</ItemGroup>
</Project>
</Project>
+1 -1
View File
@@ -5,7 +5,7 @@
</ItemGroup>
<Target AfterTargets="Build" Name="WarnIfPublicReleaseVersionInstalled" Condition="'$(RhinoVersion)' != '' And '$(ContinuousIntegrationBuild)' != 'true' And '$(OS)' == 'Windows_NT'">
<Warning
Text="Conflicting Rhino plugin detected - Do you have a public release installed? at '@(PublicReleasePath)'"
Text="Conflicting Rhino plugin detected - Do you have a public release installed?"
Condition="Exists(@(PublicReleasePath))" />
</Target>
@@ -13,9 +13,9 @@
},
"GrasshopperAsyncComponent": {
"type": "Direct",
"requested": "[2.0.3, )",
"resolved": "2.0.3",
"contentHash": "AZvHP96WhYZWftVi7J3J65LiZmXO3hGS6W4AntMMb099gkrLqeiBKC2DOYD6YM9cOyQqly3S5knbUL2yr0jc4Q==",
"requested": "[2.0.1, )",
"resolved": "2.0.1",
"contentHash": "K/LyJbYscXIdV07tPhsZgyUdwzf7vsXJBraVik6ge35T9lLYrriG5Dy9XF8ox7Q2ko5y5aTzh768+vYCdDkL5g==",
"dependencies": {
"PolySharp": "1.14.1"
}
@@ -325,9 +325,9 @@
"dependencies": {
"Microsoft.Extensions.DependencyInjection": "[2.2.0, )",
"Speckle.Connectors.Logging": "[1.0.0, )",
"Speckle.Objects": "[3.5.3, )",
"Speckle.Sdk": "[3.5.3, )",
"Speckle.Sdk.Dependencies": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )",
"Speckle.Sdk": "[3.4.3, )",
"Speckle.Sdk.Dependencies": "[3.4.3, )"
}
},
"speckle.connectors.logging": {
@@ -337,7 +337,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Speckle.Objects": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )"
}
},
"speckle.converters.rhino7": {
@@ -382,18 +382,18 @@
},
"Speckle.Objects": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "T3xwwoALVGmhIuEjlDrTdDXZ9haFILT32r8OACWrRUItU3xMkOWGyob51Ca1MHPmo8B5gvbk2Gnm8AgReGnxWg==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "08BOhVaYUvFP8CgY5fGZJWvswIRsH2EbOBGguJnanx+RZqKYI9XJroGGew+CDfPU1c8ZWl37WX2bbdPhdSP2rQ==",
"dependencies": {
"Speckle.Sdk": "3.5.3"
"Speckle.Sdk": "3.4.3"
}
},
"Speckle.Sdk": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "o+HefwtPZBqyuUHEnKF+qb/ctCAlNc2BYIw3ULEsZ93zweHt5wOMvOeuPxIXR0Gvj3fg6yNlY2nUcdFEduIXYA==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "21Dg8kMOqUbV7jyhK7N+UwyO7S1++COMR5jU9mm/vx86pkj6pTAifNZMHmuG8/ZnwpBcUCmE4AzvW24mKlgEkg==",
"dependencies": {
"GraphQL.Client": "6.0.0",
"Microsoft.Bcl.AsyncInterfaces": "5.0.0",
@@ -403,14 +403,14 @@
"Microsoft.Extensions.Logging": "2.2.0",
"Speckle.DoubleNumerics": "4.1.0",
"Speckle.Newtonsoft.Json": "13.0.2",
"Speckle.Sdk.Dependencies": "3.5.3"
"Speckle.Sdk.Dependencies": "3.4.3"
}
},
"Speckle.Sdk.Dependencies": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "kC15SE4yZoVTasgywCm0SpY9yjBsQeUIDt4qoscYAgbn9pe0jj3uM0hZeJUCxn9Fdoj64OfQBpCKzR7VqhkwHQ=="
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "PyJAt9WAeVLUfxp/l1ZvGw20HAsvfBY/JgZCJmY5doc8lFa/9dhUMBJN/cNsVM5XJK+xdIBoEemgl3SMFwXNcg=="
}
}
}
@@ -13,9 +13,9 @@
},
"GrasshopperAsyncComponent": {
"type": "Direct",
"requested": "[2.0.3, )",
"resolved": "2.0.3",
"contentHash": "AZvHP96WhYZWftVi7J3J65LiZmXO3hGS6W4AntMMb099gkrLqeiBKC2DOYD6YM9cOyQqly3S5knbUL2yr0jc4Q==",
"requested": "[2.0.1, )",
"resolved": "2.0.1",
"contentHash": "K/LyJbYscXIdV07tPhsZgyUdwzf7vsXJBraVik6ge35T9lLYrriG5Dy9XF8ox7Q2ko5y5aTzh768+vYCdDkL5g==",
"dependencies": {
"PolySharp": "1.14.1"
}
@@ -325,9 +325,9 @@
"dependencies": {
"Microsoft.Extensions.DependencyInjection": "[2.2.0, )",
"Speckle.Connectors.Logging": "[1.0.0, )",
"Speckle.Objects": "[3.5.3, )",
"Speckle.Sdk": "[3.5.3, )",
"Speckle.Sdk.Dependencies": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )",
"Speckle.Sdk": "[3.4.3, )",
"Speckle.Sdk.Dependencies": "[3.4.3, )"
}
},
"speckle.connectors.logging": {
@@ -337,12 +337,13 @@
"type": "Project",
"dependencies": {
"Microsoft.Extensions.Logging.Abstractions": "[2.2.0, )",
"Speckle.Objects": "[3.5.3, )"
"Speckle.Objects": "[3.4.3, )"
}
},
"speckle.converters.rhino8": {
"type": "Project",
"dependencies": {
"RhinoCommon": "[8.9.24194.18121, )",
"Speckle.Converters.Common": "[1.0.0, )"
}
},
@@ -381,18 +382,18 @@
},
"Speckle.Objects": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "T3xwwoALVGmhIuEjlDrTdDXZ9haFILT32r8OACWrRUItU3xMkOWGyob51Ca1MHPmo8B5gvbk2Gnm8AgReGnxWg==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "08BOhVaYUvFP8CgY5fGZJWvswIRsH2EbOBGguJnanx+RZqKYI9XJroGGew+CDfPU1c8ZWl37WX2bbdPhdSP2rQ==",
"dependencies": {
"Speckle.Sdk": "3.5.3"
"Speckle.Sdk": "3.4.3"
}
},
"Speckle.Sdk": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "o+HefwtPZBqyuUHEnKF+qb/ctCAlNc2BYIw3ULEsZ93zweHt5wOMvOeuPxIXR0Gvj3fg6yNlY2nUcdFEduIXYA==",
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "21Dg8kMOqUbV7jyhK7N+UwyO7S1++COMR5jU9mm/vx86pkj6pTAifNZMHmuG8/ZnwpBcUCmE4AzvW24mKlgEkg==",
"dependencies": {
"GraphQL.Client": "6.0.0",
"Microsoft.Bcl.AsyncInterfaces": "5.0.0",
@@ -402,14 +403,14 @@
"Microsoft.Extensions.Logging": "2.2.0",
"Speckle.DoubleNumerics": "4.1.0",
"Speckle.Newtonsoft.Json": "13.0.2",
"Speckle.Sdk.Dependencies": "3.5.3"
"Speckle.Sdk.Dependencies": "3.4.3"
}
},
"Speckle.Sdk.Dependencies": {
"type": "CentralTransitive",
"requested": "[3.5.3, )",
"resolved": "3.5.3",
"contentHash": "kC15SE4yZoVTasgywCm0SpY9yjBsQeUIDt4qoscYAgbn9pe0jj3uM0hZeJUCxn9Fdoj64OfQBpCKzR7VqhkwHQ=="
"requested": "[3.4.3, )",
"resolved": "3.4.3",
"contentHash": "PyJAt9WAeVLUfxp/l1ZvGw20HAsvfBY/JgZCJmY5doc8lFa/9dhUMBJN/cNsVM5XJK+xdIBoEemgl3SMFwXNcg=="
}
}
}
@@ -158,19 +158,10 @@ public class CreateCollection : VariableParameterComponentBase
{
foreach (var obj in objects)
{
// handle data objects directly (deep copy to avoid mutations)
// NOTE: DataObject first, since a DataObject with one geo is castable to speckle geometry
if (obj is SpeckleDataObjectWrapperGoo dataObjectWrapperGoo)
// deep copy to avoid mutations
if (obj?.ToSpeckleObjectWrapper() is SpeckleObjectWrapper objWrapper)
{
var dataObjectWrapper = dataObjectWrapperGoo.Value.DeepCopy();
dataObjectWrapper.Path = childPath;
dataObjectWrapper.Parent = parentCollection;
parentCollection.Elements.Add(dataObjectWrapper);
}
// handle geometry objects (deep copy to avoid mutations)
else if (obj?.ToSpeckleGeometryWrapper() is SpeckleGeometryWrapper objWrapper)
{
SpeckleGeometryWrapper wrapper = objWrapper.DeepCopy();
SpeckleObjectWrapper wrapper = objWrapper.DeepCopy();
wrapper.Path = childPath;
wrapper.Parent = parentCollection;
parentCollection.Elements.Add(wrapper);
@@ -1,6 +1,7 @@
using System.Collections;
using System.Runtime.InteropServices;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Parameters;
using Grasshopper.Kernel.Types;
using Speckle.Connectors.GrasshopperShared.HostApp;
using Speckle.Connectors.GrasshopperShared.Parameters;
@@ -54,18 +55,18 @@ public class ExpandCollection : GH_Component, IGH_VariableParameterComponent
// Separate objects and collections
// Note: SpeckleBlockInstanceWrapper inherits from SpeckleObjectWrapper,
// so it will be included in objects
List<SpeckleWrapper> objects = wrapper.GetAtomicObjects().ToList();
List<SpeckleCollectionWrapper> collections = wrapper.Elements.OfType<SpeckleCollectionWrapper>().ToList();
var objects = wrapper.Elements.OfType<SpeckleObjectWrapper>().ToList();
var collections = wrapper.Elements.OfType<SpeckleCollectionWrapper>().ToList();
var outputParams = new List<OutputParamWrapper>();
if (objects.Count != 0)
{
var param = new SpeckleOutputParam
var param = new Param_GenericObject()
{
Name = "_objects",
NickName = "_objs",
Description =
"Some collections may contain a mix of objects and other collections. These are the objects directly contained in this collection.",
"Some collections may contain a mix of objects and other collections. Here we output the atomic objects from within this collection.",
Access = GH_ParamAccess.list
};
@@ -93,7 +94,7 @@ public class ExpandCollection : GH_Component, IGH_VariableParameterComponent
nickName += "..." + childWrapper.Name[^6..];
}
var param = new SpeckleOutputParam
var param = new Param_GenericObject()
{
Name = childWrapper.Name,
NickName = nickName,
@@ -112,7 +113,10 @@ public class ExpandCollection : GH_Component, IGH_VariableParameterComponent
else
{
// Create appropriate Goo types for child objects
List<IGH_Goo> childObjectGoos = childWrapper.GetAtomicObjects().Select(obj => obj.CreateGoo()).ToList();
List<IGH_Goo> childObjectGoos = childWrapper
.Elements.OfType<SpeckleObjectWrapper>()
.Select(obj => obj.CreateGoo())
.ToList();
outputValue = childObjectGoos;
}
@@ -190,7 +194,7 @@ public class ExpandCollection : GH_Component, IGH_VariableParameterComponent
foreach (var newParam in outputParams)
{
var param = new SpeckleOutputParam
var param = new Param_GenericObject
{
Name = newParam.Param.Name,
NickName = newParam.Param.NickName,
@@ -213,7 +217,7 @@ public class ExpandCollection : GH_Component, IGH_VariableParameterComponent
public IGH_Param CreateParameter(GH_ParameterSide side, int index)
{
var myParam = new SpeckleOutputParam
var myParam = new Param_GenericObject
{
Name = GH_ComponentParamServer.InventUniqueNickname("ABCD", Params.Input),
MutableNickName = true,
@@ -226,4 +230,4 @@ public class ExpandCollection : GH_Component, IGH_VariableParameterComponent
public bool DestroyParameter(GH_ParameterSide side, int index) => side == GH_ParameterSide.Output;
}
public record OutputParamWrapper(SpeckleOutputParam Param, object Values, string? Topology);
public record OutputParamWrapper(Param_GenericObject Param, object Values, string? Topology);
@@ -8,8 +8,8 @@ public static class ComponentCategories
// categories
public const string OPERATIONS = " Models";
public const string OBJECTS = " Objects";
public const string COLLECTIONS = " Collections";
public const string OBJECTS = " Objects";
public const string COLLECTIONS = " Collections";
public const string PARAMETERS = " Params";
public const string DEVELOPER = "Dev";
}
@@ -28,202 +28,99 @@ public class DeconstructSpeckleParam : GH_Component, IGH_VariableParameterCompon
public override Guid ComponentGuid => GetType().GUID;
protected override Bitmap Icon => Resources.speckle_deconstruct;
protected override void RegisterInputParams(GH_InputParamManager pManager) =>
protected override void RegisterInputParams(GH_InputParamManager pManager)
{
pManager.AddGenericParameter("Speckle Param", "SP", "Speckle param to deconstruct", GH_ParamAccess.item);
}
protected override void RegisterOutputParams(GH_OutputParamManager pManager) { }
protected override void SolveInstance(IGH_DataAccess da)
{
// on first iteration, discover all fields from all objects to create stable output structure
if (da.Iteration == 0)
{
var allFields = DiscoverAllFieldsFromInput();
if (allFields.Count > 0)
{
var requiredOutputs = CreateOutputParamsFromFieldNames(allFields);
if (OutputMismatch(requiredOutputs))
{
OnPingDocument()?.ScheduleSolution(5, _ => CreateOutputs(requiredOutputs));
return;
}
}
}
// process current object normally
object data = new();
if (!da.GetData(0, ref data))
da.GetData(0, ref data);
List<OutputParamWrapper> outputParams = new();
switch (data)
{
return;
case SpeckleCollectionWrapperGoo collectionGoo when collectionGoo.Value != null:
// get children elements from the wrapper to override the elements prop while parsing
List<IGH_Goo> children = collectionGoo.Value.Elements.Select(o => ((SpeckleWrapper)o).CreateGoo()).ToList();
outputParams = ParseSpeckleWrapper(collectionGoo.Value, children);
break;
case SpeckleObjectWrapperGoo objectGoo when objectGoo.Value != null:
outputParams = ParseSpeckleWrapper(objectGoo.Value);
break;
case SpeckleBlockInstanceWrapperGoo blockInstanceGoo when blockInstanceGoo.Value != null:
outputParams = ParseSpeckleWrapper(blockInstanceGoo.Value);
break;
case SpeckleBlockDefinitionWrapperGoo blockDef:
outputParams = ParseSpeckleWrapper(blockDef.Value);
break;
case SpeckleMaterialWrapperGoo materialGoo when materialGoo.Value != null:
outputParams = ParseSpeckleWrapper(materialGoo.Value);
break;
case SpecklePropertyGroupGoo propGoo:
Name = $"properties ({propGoo.Value.Count})";
outputParams = new();
foreach (var key in propGoo.Value.Keys)
{
ISpecklePropertyGoo value = propGoo.Value[key];
object? outputValue = value is SpecklePropertyGoo prop
? prop.Value
: value is SpecklePropertyGroupGoo propGroup
? propGroup
: value;
outputParams.Add(CreateOutputParamByKeyValue(key, outputValue, GH_ParamAccess.item));
}
break;
default:
AddRuntimeMessage(GH_RuntimeMessageLevel.Error, $"Type cannot be deconstructed: {data.GetType().Name}");
return;
}
var outputParams = DeconstructObject(data);
if (outputParams == null)
{
return;
}
// set component name based on the current object
NickName = Name;
// set output data - fill missing fields with nulls for objects that don't have all fields
SetOutputData(da, outputParams);
}
/// <summary>
/// Discovers all unique field names and their access types from all input objects by looking at volatile data directly.
/// </summary>
/// <returns>A dictionary mapping field names to their required parameter access types.</returns>
private IReadOnlyDictionary<string, GH_ParamAccess> DiscoverAllFieldsFromInput()
{
Dictionary<string, GH_ParamAccess> allFields = [];
foreach (var item in Params.Input[0].VolatileData.AllData(true))
if (da.Iteration == 0 && OutputMismatch(outputParams))
{
var objectOutputs = DeconstructObject(item);
if (objectOutputs != null)
OnPingDocument()
.ScheduleSolution(
5,
_ =>
{
CreateOutputs(outputParams);
}
);
}
else
{
for (int i = 0; i < outputParams.Count; i++)
{
foreach (var output in objectOutputs)
var outParam = Params.Output[i];
var outParamWrapper = outputParams[i];
switch (outParam.Access)
{
string fieldName = output.Param.Name;
allFields[fieldName] = output.Param.Access;
case GH_ParamAccess.item:
da.SetData(i, outParamWrapper.Value);
break;
case GH_ParamAccess.list:
da.SetDataList(i, outParamWrapper.Value as IList);
break;
}
}
}
return allFields;
}
/// <summary>
/// Creates output parameter wrappers from field names and their corresponding access types.
/// </summary>
/// <param name="fieldAccessTypes">Dictionary mapping field names to their required parameter access types.</param>
/// <returns>List of output parameter wrappers with correct access types.</returns>
private List<OutputParamWrapper> CreateOutputParamsFromFieldNames(
IReadOnlyDictionary<string, GH_ParamAccess> fieldAccessTypes
) => fieldAccessTypes.Select(kvp => CreateOutputParamByKeyValue(kvp.Key, null, kvp.Value)).ToList();
/// <summary>
/// Deconstructs a single object into its constituent fields/properties.
/// </summary>
private List<OutputParamWrapper>? DeconstructObject(object data) =>
data switch
{
// get children elements from wrapper to override elements prop while parsing
SpeckleCollectionWrapperGoo collectionGoo when collectionGoo.Value != null
=> ParseSpeckleWrapper(
collectionGoo.Value,
collectionGoo.Value.Elements.Select(o => ((SpeckleWrapper)o).CreateGoo()).ToList()
),
// get geometries from wrapper to override displayValue prop while parsing
SpeckleDataObjectWrapperGoo dataObjectGoo when dataObjectGoo.Value != null
=> ParseSpeckleWrapper(
dataObjectGoo.Value,
null,
dataObjectGoo.Value.Geometries.Select(o => o.CreateGoo()).ToList()
),
SpeckleGeometryWrapperGoo objectGoo when objectGoo.Value != null => ParseSpeckleWrapper(objectGoo.Value),
SpeckleBlockInstanceWrapperGoo blockInstanceGoo when blockInstanceGoo.Value != null
=> ParseSpeckleWrapper(blockInstanceGoo.Value),
SpeckleBlockDefinitionWrapperGoo blockDef when blockDef.Value != null => ParseSpeckleWrapper(blockDef.Value),
SpeckleMaterialWrapperGoo materialGoo when materialGoo.Value != null => ParseSpeckleWrapper(materialGoo.Value),
SpecklePropertyGroupGoo propGoo when propGoo.Value != null => ParsePropertyGroup(propGoo),
_ => HandleUnsupportedType(data)
};
/// <summary>
/// Handles SpecklePropertyGroupGoo objects by extracting their key-value pairs.
/// </summary>
private List<OutputParamWrapper> ParsePropertyGroup(SpecklePropertyGroupGoo propGoo)
{
Name = $"properties ({propGoo.Value.Count})";
List<OutputParamWrapper> objectOutputs = new();
foreach (var key in propGoo.Value.Keys)
{
ISpecklePropertyGoo value = propGoo.Value[key];
object? outputValue = value switch
{
SpecklePropertyGoo prop => prop.Value,
SpecklePropertyGroupGoo propGroup => propGroup,
_ => value
};
// determine access type based on the value
GH_ParamAccess access = outputValue is IList ? GH_ParamAccess.list : GH_ParamAccess.item;
objectOutputs.Add(CreateOutputParamByKeyValue(key, outputValue, access));
}
return objectOutputs;
}
/// <summary>
/// Handles unsupported object types by logging an error and returning null.
/// </summary>
private List<OutputParamWrapper>? HandleUnsupportedType(object data)
{
AddRuntimeMessage(GH_RuntimeMessageLevel.Error, $"Type cannot be deconstructed: {data.GetType().Name}");
return null;
}
/// <summary>
/// Sets output data for the current iteration, filling missing fields with null values.
/// Uses a lookup dictionary for efficient field matching.
/// </summary>
private void SetOutputData(IGH_DataAccess da, List<OutputParamWrapper> currentOutputs)
{
if (Params.Output.Count == 0)
{
return;
}
// create a lookup for current outputs by field name
var outputLookup = currentOutputs.ToDictionary(o => o.Param.Name, o => o.Value);
// set data for each output parameter
for (int i = 0; i < Params.Output.Count; i++)
{
var outputParam = Params.Output[i];
// set the value if it exists, otherwise set null
object? value = outputLookup.TryGetValue(outputParam.Name, out var fieldValue) ? fieldValue : null;
switch (outputParam.Access)
{
case GH_ParamAccess.item:
da.SetData(i, value);
break;
case GH_ParamAccess.list:
da.SetDataList(i, value as IList ?? new List<object?>());
break;
}
}
}
private List<OutputParamWrapper> ParseSpeckleWrapper(
SpeckleWrapper wrapper,
List<IGH_Goo>? elements = null,
List<IGH_Goo>? displayValue = null
)
private List<OutputParamWrapper> ParseSpeckleWrapper(SpeckleWrapper wrapper, List<IGH_Goo>? collElements = null)
{
Name = string.IsNullOrEmpty(wrapper.Name) ? wrapper.Base.speckle_type : wrapper.Name;
return CreateOutputParamsFromBase(wrapper.Base, elements, displayValue);
return CreateOutputParamsFromBase(wrapper.Base, collElements);
}
private List<OutputParamWrapper> CreateOutputParamsFromBase(
Base @base,
List<IGH_Goo>? elements = null,
List<IGH_Goo>? displayValue = null
)
private List<OutputParamWrapper> CreateOutputParamsFromBase(Base @base, List<IGH_Goo>? collElements = null)
{
List<OutputParamWrapper> result = new();
if (@base == null)
@@ -231,149 +128,121 @@ public class DeconstructSpeckleParam : GH_Component, IGH_VariableParameterCompon
return result;
}
// process each property of the Base object
// cycle through base props
foreach (var prop in @base.GetMembers(DynamicBaseMemberType.Instance | DynamicBaseMemberType.Dynamic))
{
// skip internal dynamic property keys
if (prop.Key == nameof(Base.DynamicPropertyKeys))
// Convert and add to corresponding output structure
var value = prop.Value;
switch (value)
{
continue;
}
case null:
result.Add(CreateOutputParamByKeyValue(prop.Key, null, GH_ParamAccess.item));
break;
var outputParam = CreateOutputParamForProperty(prop, @base, elements, displayValue);
if (outputParam != null)
{
result.Add(outputParam);
case IList list:
List<object> nativeObjects = new();
// override list value if base is a collection and this is the elements prop, since this is empty if coming from a collectionwrapper
if (@base is Collection && prop.Key == "elements" && collElements != null)
{
list = collElements;
}
foreach (var x in list)
{
switch (x)
{
case SpeckleWrapper wrapper:
nativeObjects.Add(wrapper.CreateGoo());
break;
case Base xBase:
nativeObjects.AddRange(ConvertOrCreateWrapper(xBase));
break;
default:
nativeObjects.Add(x);
break;
}
}
result.Add(CreateOutputParamByKeyValue(prop.Key, nativeObjects, GH_ParamAccess.list));
break;
case Dictionary<string, object?> dict: // this should be treated a properties dict
SpecklePropertyGroupGoo propertyGoo = new();
propertyGoo.CastFrom(dict);
result.Add(CreateOutputParamByKeyValue(prop.Key, propertyGoo, GH_ParamAccess.item));
break;
case SpeckleWrapper wrapper:
result.Add(CreateOutputParamByKeyValue(prop.Key, wrapper.CreateGoo(), GH_ParamAccess.item));
break;
case Base baseValue:
result.Add(CreateOutputParamByKeyValue(prop.Key, ConvertOrCreateWrapper(baseValue), GH_ParamAccess.list));
break;
default:
// we don't want to output dynamic property keys
if (prop.Key == nameof(Base.DynamicPropertyKeys))
{
continue;
}
result.Add(CreateOutputParamByKeyValue(prop.Key, prop.Value, GH_ParamAccess.item));
break;
}
}
return result;
}
/// <summary>
/// Creates an output parameter for a single property, handling different value types appropriately.
/// </summary>
private OutputParamWrapper CreateOutputParamForProperty(
KeyValuePair<string, object?> prop,
Base @base,
List<IGH_Goo>? elements,
List<IGH_Goo>? displayValue
) =>
prop.Value switch
{
null => CreateOutputParamByKeyValue(prop.Key, null, GH_ParamAccess.item),
IList list => CreateListOutputParam(prop.Key, list, @base, elements, displayValue),
Dictionary<string, object?> dict => CreateDictionaryOutputParam(prop.Key, dict),
SpeckleWrapper wrapper => CreateOutputParamByKeyValue(prop.Key, wrapper.CreateGoo(), GH_ParamAccess.item),
Base baseValue => CreateOutputParamByKeyValue(prop.Key, ConvertOrCreateWrapper(baseValue), GH_ParamAccess.list),
_ => CreateOutputParamByKeyValue(prop.Key, prop.Value, GH_ParamAccess.item)
};
/// <summary>
/// Creates an output parameter for list properties, with special handling for collection elements and display values.
/// </summary>
private OutputParamWrapper CreateListOutputParam(
string key,
IList list,
Base @base,
List<IGH_Goo>? elements,
List<IGH_Goo>? displayValue
)
{
// override list value for special cases
IList actualList = key switch
{
"elements" when @base is Collection && elements != null => elements,
"displayValue" when @base is Speckle.Objects.Data.DataObject && displayValue != null => displayValue,
_ => list
};
List<object> nativeObjects = new();
foreach (var item in actualList)
{
switch (item)
{
case SpeckleWrapper wrapper:
nativeObjects.Add(wrapper.CreateGoo());
break;
case Base baseItem:
nativeObjects.AddRange(ConvertOrCreateWrapper(baseItem));
break;
default:
nativeObjects.Add(item);
break;
}
}
return CreateOutputParamByKeyValue(key, nativeObjects, GH_ParamAccess.list);
}
/// <summary>
/// Creates an output parameter for dictionary properties, converting them to SpecklePropertyGroupGoo.
/// </summary>
private OutputParamWrapper CreateDictionaryOutputParam(string key, Dictionary<string, object?> dict)
{
SpecklePropertyGroupGoo propertyGoo = new();
propertyGoo.CastFrom(dict);
return CreateOutputParamByKeyValue(key, propertyGoo, GH_ParamAccess.item);
}
/// <summary>
/// Converts a Speckle Base object to host geometry or creates a wrapper if conversion fails.
/// Returns a list of SpeckleGeometryWrapperGoo objects.
/// </summary>
private List<SpeckleGeometryWrapperGoo> ConvertOrCreateWrapper(Base @base)
private List<SpeckleObjectWrapperGoo> ConvertOrCreateWrapper(Base @base)
{
try
{
// attempt conversion to host geometry
List<(object, Base)> convertedBase = SpeckleConversionContext.Current.ConvertToHost(@base);
return convertedBase.Select(CreateGeometryWrapper).ToList();
// convert the base and create a wrapper for each result
List<(GeometryBase, Base)> convertedBase = SpeckleConversionContext.ConvertToHost(@base);
List<SpeckleObjectWrapperGoo> convertedWrappers = new();
foreach ((GeometryBase g, Base b) in convertedBase)
{
SpeckleObjectWrapper convertedWrapper =
new()
{
Base = b,
GeometryBase = g,
Name = b["name"] as string ?? "",
Color = null,
Material = null
};
convertedWrappers.Add(new(convertedWrapper));
}
return convertedWrappers;
}
catch (ConversionException)
{
// fallback: create wrapper without conversion for objects that can't be converted
return new List<SpeckleGeometryWrapperGoo> { CreateFallbackWrapper(@base) };
// some classes, like RawEncoding, have no direct conversion or fallback value.
// when this is the case, wrap it to allow users to further expand the object.
SpeckleObjectWrapper convertedWrapper =
new()
{
Base = @base,
GeometryBase = null,
Name = @base[Constants.NAME_PROP] as string ?? "",
Color = null,
Material = null
};
return new() { new SpeckleObjectWrapperGoo(convertedWrapper) };
}
}
/// <summary>
/// Creates a SpeckleGeometryWrapperGoo from a converted geometry and base object pair.
/// </summary>
private SpeckleGeometryWrapperGoo CreateGeometryWrapper((object geometry, Base @base) converted)
{
SpeckleGeometryWrapper wrapper =
new()
{
Base = converted.@base,
GeometryBase = converted.geometry as GeometryBase,
Name = converted.@base["name"] as string ?? "",
Color = null,
Material = null
};
return new SpeckleGeometryWrapperGoo(wrapper);
}
/// <summary>
/// Creates a fallback wrapper for Base objects that cannot be converted to host geometry.
/// </summary>
private SpeckleGeometryWrapperGoo CreateFallbackWrapper(Base @base)
{
SpeckleGeometryWrapper wrapper =
new()
{
Base = @base,
GeometryBase = null,
Name = @base[Constants.NAME_PROP] as string ?? "",
Color = null,
Material = null
};
return new SpeckleGeometryWrapperGoo(wrapper);
}
private OutputParamWrapper CreateOutputParamByKeyValue(string key, object? value, GH_ParamAccess access)
{
SpeckleOutputParam param =
Param_GenericObject param =
new()
{
Name = key,
@@ -403,20 +272,22 @@ public class DeconstructSpeckleParam : GH_Component, IGH_VariableParameterCompon
return myParam;
}
public bool DestroyParameter(GH_ParameterSide side, int index) => side == GH_ParameterSide.Output;
public bool DestroyParameter(GH_ParameterSide side, int index)
{
return side == GH_ParameterSide.Output;
}
private void CreateOutputs(List<OutputParamWrapper> outputParams)
{
// remove all existing output parameters
// TODO: better, nicer handling of creation/removal
while (Params.Output.Count > 0)
{
Params.UnregisterOutputParameter(Params.Output[^1]);
}
// add new output parameters
foreach (var newParam in outputParams)
{
var param = new SpeckleOutputParam
var param = new Param_GenericObject
{
Name = newParam.Param.Name,
NickName = newParam.Param.NickName,
@@ -426,15 +297,11 @@ public class DeconstructSpeckleParam : GH_Component, IGH_VariableParameterCompon
Params.RegisterOutputParam(param);
}
// notify Grasshopper of parameter changes
Params.OnParametersChanged();
VariableParameterMaintenance();
ExpireSolution(false);
}
/// <summary>
/// Determines if the current output parameter structure differs from the required structure.
/// </summary>
private bool OutputMismatch(List<OutputParamWrapper> outputParams)
{
if (Params.Output.Count != outputParams.Count)
@@ -442,10 +309,10 @@ public class DeconstructSpeckleParam : GH_Component, IGH_VariableParameterCompon
return true;
}
for (int i = 0; i < outputParams.Count; i++)
var count = 0;
foreach (var newParam in outputParams)
{
var newParam = outputParams[i];
var oldParam = Params.Output[i];
var oldParam = Params.Output[count];
if (
oldParam.NickName != newParam.Param.NickName
|| oldParam.Name != newParam.Param.Name
@@ -454,6 +321,7 @@ public class DeconstructSpeckleParam : GH_Component, IGH_VariableParameterCompon
{
return true;
}
count++;
}
return false;
@@ -17,7 +17,7 @@ public class CreateSpeckleProperties : VariableParameterComponentBase
public override Guid ComponentGuid => GetType().GUID;
protected override Bitmap Icon => Resources.speckle_properties_create;
public override GH_Exposure Exposure => GH_Exposure.quarternary;
public override GH_Exposure Exposure => GH_Exposure.tertiary;
public CreateSpeckleProperties()
: base(
@@ -73,10 +73,7 @@ public class CreateSpeckleProperties : VariableParameterComponentBase
continue;
}
ISpecklePropertyGoo? propertyValue =
Params.Input[i].Access == GH_ParamAccess.item
? ExtractPropertyValue(da, i, paramName)
: ExtractPropertyListValue(da, i, paramName);
var propertyValue = ExtractPropertyValue(da, i, paramName);
if (propertyValue != null)
{
@@ -117,26 +114,6 @@ public class CreateSpeckleProperties : VariableParameterComponentBase
return propertyGoo;
}
private ISpecklePropertyGoo? ExtractPropertyListValue(IGH_DataAccess da, int index, string paramName)
{
List<object?> value = new();
da.GetDataList(index, value);
var propertyGoo = new SpecklePropertyGoo();
if (!propertyGoo.CastFrom(value))
{
AddRuntimeMessage(
GH_RuntimeMessageLevel.Error,
$"Parameter '{paramName}' contains invalid data type. Only strings, numbers, and booleans are supported."
);
return null;
}
return propertyGoo;
}
protected override void AppendComponentSpecificMenuItems(ToolStripDropDown menu)
{
Menu_AppendSeparator(menu);
@@ -1,170 +0,0 @@
using System.Collections;
using System.Runtime.InteropServices;
using Grasshopper.Kernel;
using Speckle.Connectors.GrasshopperShared.Parameters;
using Speckle.Connectors.GrasshopperShared.Properties;
namespace Speckle.Connectors.GrasshopperShared.Components.Objects;
// NOTE: Why all this madness? The properties passthrough node is restrictive in output type being uniform
// Properties whose values were lists were not being displayed and couldn't be given back to the user as native
// lists. This was (it seemed) the only viable approach.
// [CNX-2364](https://linear.app/speckle/issue/CNX-2364/grasshopper-properties-passthrough-does-not-handle-list-values)
[Guid("474F4699-D641-444F-BC78-E22AAF40B240")]
public class ExpandSpeckleProperties : GH_Component, IGH_VariableParameterComponent
{
public ExpandSpeckleProperties()
: base(
"Expand Properties",
"eP",
"Expands Speckle Properties into their individual outputs with correct access types",
ComponentCategories.PRIMARY_RIBBON,
ComponentCategories.OBJECTS
) { }
public override Guid ComponentGuid => GetType().GUID;
protected override Bitmap Icon => Resources.speckle_properties_expand;
public override GH_Exposure Exposure => GH_Exposure.secondary;
protected override void RegisterInputParams(GH_InputParamManager pManager)
{
pManager.AddParameter(
new SpecklePropertyGroupParam(),
"Properties",
"P",
"Speckle Properties to expand",
GH_ParamAccess.item
);
}
protected override void RegisterOutputParams(GH_OutputParamManager pManager) { }
protected override void SolveInstance(IGH_DataAccess da)
{
SpecklePropertyGroupGoo? properties = null;
if (!da.GetData(0, ref properties) || properties?.Value == null)
{
return;
}
Name = $"Properties ({properties.Value.Count})";
NickName = Name;
var outputParams = new List<OutputParamWrapper>();
foreach (var key in properties.Value.Keys)
{
ISpecklePropertyGoo value = properties.Value[key];
object? outputValue = value switch
{
SpecklePropertyGoo prop => prop.Value,
SpecklePropertyGroupGoo propGroup => propGroup,
_ => value
};
var param = new SpeckleOutputParam
{
Name = key,
NickName = key,
Access = outputValue is IList ? GH_ParamAccess.list : GH_ParamAccess.item
};
outputParams.Add(new OutputParamWrapper(param, outputValue));
}
// handle parameter creation/update (only on first iteration)
if (da.Iteration == 0 && OutputMismatch(outputParams))
{
OnPingDocument()?.ScheduleSolution(5, _ => CreateOutputs(outputParams));
return; // exit early
}
// only set data if we have the correct parameter structure
if (Params.Output.Count == outputParams.Count)
{
for (int i = 0; i < outputParams.Count; i++)
{
var outputParam = outputParams[i];
switch (outputParam.Param.Access)
{
case GH_ParamAccess.item:
da.SetData(i, outputParam.Value);
break;
case GH_ParamAccess.list:
da.SetDataList(i, outputParam.Value as IList ?? new List<object?>());
break;
}
}
}
}
/// <summary>
/// Creates output parameters based on discovered properties.
/// </summary>
private void CreateOutputs(List<OutputParamWrapper> outputParams)
{
// remove all existing output parameters
while (Params.Output.Count > 0)
{
Params.UnregisterOutputParameter(Params.Output[^1]);
}
// add new output parameters
foreach (var newParam in outputParams)
{
var param = new SpeckleOutputParam
{
Name = newParam.Param.Name,
NickName = newParam.Param.NickName,
MutableNickName = false,
Access = newParam.Param.Access
};
Params.RegisterOutputParam(param);
}
// notify gh of parameter changes
Params.OnParametersChanged();
VariableParameterMaintenance();
ExpireSolution(false);
}
/// <summary>
/// Determines if the current output parameter structure differs from the required structure.
/// </summary>
private bool OutputMismatch(List<OutputParamWrapper> outputParams)
{
if (Params.Output.Count != outputParams.Count)
{
return true;
}
for (int i = 0; i < outputParams.Count; i++)
{
var newParam = outputParams[i];
var oldParam = Params.Output[i];
if (
oldParam.NickName != newParam.Param.NickName
|| oldParam.Name != newParam.Param.Name
|| oldParam.Access != newParam.Param.Access
)
{
return true;
}
}
return false;
}
// IGH_VariableParameterComponent implementation
public bool CanInsertParameter(GH_ParameterSide side, int index) => false;
public bool CanRemoveParameter(GH_ParameterSide side, int index) => false;
public void VariableParameterMaintenance() { }
public IGH_Param CreateParameter(GH_ParameterSide side, int index) => new SpeckleOutputParam();
public bool DestroyParameter(GH_ParameterSide side, int index) => side == GH_ParameterSide.Output;
}
public record OutputParamWrapper(SpeckleOutputParam Param, object? Value);
@@ -85,7 +85,7 @@ public class FilterSpeckleObjects : GH_Component
return;
}
List<SpeckleWrapper?> objects = inputObjects
List<SpeckleObjectWrapper?> objects = inputObjects
.Select(o => o.ToSpeckleObjectWrapper())
.Where(o => o is not null)
.ToList();
@@ -108,11 +108,11 @@ public class FilterSpeckleObjects : GH_Component
string speckleId = "";
dataAccess.GetData(5, ref speckleId);
List<SpeckleWrapper> matchedObjects = new();
List<SpeckleWrapper> removedObjects = new();
List<SpeckleObjectWrapper> matchedObjects = new();
List<SpeckleObjectWrapper> removedObjects = new();
for (int i = 0; i < objects.Count; i++)
{
SpeckleWrapper wrapper = objects[i]!;
SpeckleObjectWrapper wrapper = objects[i]!;
// filter by name
if (!MatchesSearchPattern(name, wrapper.Name))
@@ -129,24 +129,12 @@ public class FilterSpeckleObjects : GH_Component
}
else
{
SpecklePropertyGroupGoo? properties = wrapper is SpeckleDataObjectWrapper dataObjPropWrapper
? dataObjPropWrapper.Properties
: wrapper is SpeckleGeometryWrapper geoPropWrapper
? geoPropWrapper.Properties
: null;
if (properties is not null)
foreach (string key in wrapper.Properties.Value.Keys)
{
// use flattened properties to search ALL nested property keys
// fix for [CNX-2512](https://linear.app/speckle/issue/CNX-2512/filter-objects-material-and-property-key-inputs-dont-work-as-expected)
Dictionary<string, SpecklePropertyGoo> flattenedProps = properties.Flatten();
foreach (string key in flattenedProps.Keys)
if (MatchesSearchPattern(property, key))
{
if (MatchesSearchPattern(property, key))
{
foundProperty = true;
break;
}
foundProperty = true;
break;
}
}
}
@@ -158,26 +146,7 @@ public class FilterSpeckleObjects : GH_Component
}
// filter by material name
bool materialMatches = true;
if (!string.IsNullOrEmpty(material))
{
materialMatches = false;
if (wrapper is SpeckleGeometryWrapper geoWrapper)
{
materialMatches = MatchesSearchPattern(material, geoWrapper.Material?.Name ?? "");
}
else if (wrapper is SpeckleDataObjectWrapper dataObjWrapper)
{
// check if ANY geometry in the data object has a matching material (not sure about this...)
// fix for [CNX-2512](https://linear.app/speckle/issue/CNX-2512/filter-objects-material-and-property-key-inputs-dont-work-as-expected)
materialMatches = dataObjWrapper.Geometries.Any(geo =>
MatchesSearchPattern(material, geo.Material?.Name ?? "")
);
}
}
if (!materialMatches)
if (!MatchesSearchPattern(material, wrapper.Material?.Name ?? ""))
{
removedObjects.Add(wrapper);
continue;
@@ -0,0 +1,179 @@
using System.Runtime.InteropServices;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Parameters;
using Speckle.Connectors.GrasshopperShared.Parameters;
using Speckle.Connectors.GrasshopperShared.Properties;
namespace Speckle.Connectors.GrasshopperShared.Components.Objects;
[Guid("116F08A5-BAA7-45B3-B6C8-469E452C9AC7")]
public class GetObjectProperties : GH_Component, IGH_VariableParameterComponent
{
public override Guid ComponentGuid => GetType().GUID;
protected override Bitmap Icon => Resources.speckle_properties_query;
public override GH_Exposure Exposure => GH_Exposure.tertiary;
public GetObjectProperties()
: base(
"Query Properties",
"qP",
"Retrieves the values of the properties inside Speckle Objects at the specified keys",
ComponentCategories.PRIMARY_RIBBON,
ComponentCategories.OBJECTS
) { }
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
pManager.AddParameter(
new SpeckleObjectParam(),
"Objects",
"O",
"Speckle Objects to retrieve properties",
GH_ParamAccess.item
);
pManager.AddTextParameter("Keys", "K", "Property keys to filter by", GH_ParamAccess.list);
}
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager) { }
protected override void SolveInstance(IGH_DataAccess da)
{
List<string> paths = new();
da.GetDataList(1, paths);
if (paths.Count == 0)
{
return;
}
if (OutputMismatch(paths))
{
OnPingDocument()
.ScheduleSolution(
5,
_ =>
{
CreateOutputs(paths);
}
);
}
else
{
SpeckleObjectWrapperGoo objectWrapperGoo = new();
da.GetData(0, ref objectWrapperGoo);
// flatten object properties, if any
SpecklePropertyGroupGoo properties = objectWrapperGoo.Value.Properties;
if (properties.Value.Count == 0)
{
return;
}
Dictionary<string, SpecklePropertyGoo> flattenedProps = properties.Flatten();
for (int i = 0; i < paths.Count; i++)
{
var name = paths[i];
if (FindProperty(flattenedProps, name) is SpecklePropertyGoo prop)
{
da.SetData(i, prop.Value);
}
else
{
da.SetData(i, null);
}
}
}
}
// attempts to find a property by concatenated key, or returns null if not
private SpecklePropertyGoo? FindProperty(Dictionary<string, SpecklePropertyGoo> props, string unifiedPath)
{
if (!props.TryGetValue(unifiedPath, out SpecklePropertyGoo currentGoo))
{
return null;
}
return currentGoo;
}
private bool OutputMismatch(List<string> outputParams)
{
if (Params.Output.Count != outputParams.Count)
{
return true;
}
var count = 0;
foreach (var newParam in outputParams)
{
var oldParam = Params.Output[count];
if (oldParam.NickName != newParam || oldParam.Name != newParam)
{
return true;
}
count++;
}
return false;
}
private void CreateOutputs(List<string> outputParams)
{
// Ensure we have the required count of output parameters
while (Params.Output.Count != outputParams.Count)
{
if (Params.Output.Count > outputParams.Count) // if too many, unregister
{
Params.UnregisterOutputParameter(Params.Output[^1]);
}
if (Params.Output.Count < outputParams.Count) // if too little, add some
{
var param = new Param_GenericObject
{
Name = "newParam",
NickName = "newParam",
MutableNickName = false,
Access = GH_ParamAccess.item
};
Params.RegisterOutputParam(param);
}
}
// now unify names and nicknames
int index = 0;
foreach (var newParam in outputParams)
{
Params.Output[index].NickName = newParam;
Params.Output[index].Name = newParam;
index++;
}
// now we can update the output params
Params.OnParametersChanged();
VariableParameterMaintenance();
ExpireSolution(false);
}
public bool CanInsertParameter(GH_ParameterSide side, int index) => false;
public bool CanRemoveParameter(GH_ParameterSide side, int index) => false;
public IGH_Param CreateParameter(GH_ParameterSide side, int index)
{
var myParam = new Param_GenericObject
{
Name = GH_ComponentParamServer.InventUniqueNickname("ABCD", Params.Input),
MutableNickName = true,
Optional = true
};
myParam.NickName = myParam.Name;
return myParam;
}
public bool DestroyParameter(GH_ParameterSide side, int index) => side == GH_ParameterSide.Output;
public void VariableParameterMaintenance() { }
}
@@ -4,6 +4,9 @@ using Speckle.Connectors.Common.Extensions;
using Speckle.Connectors.GrasshopperShared.Components.BaseComponents;
using Speckle.Connectors.GrasshopperShared.Parameters;
using Speckle.Connectors.GrasshopperShared.Properties;
#if RHINO8_OR_GREATER
using Grasshopper.Rhinoceros.Model;
#endif
namespace Speckle.Connectors.GrasshopperShared.Components.Objects;
@@ -20,28 +23,35 @@ public class PropertyGroupPathsSelector : ValueSet<IGH_Goo>
public override Guid ComponentGuid => new Guid("8882BE3A-81F1-4416-B420-58D69E4CC8F1");
protected override Bitmap Icon => Resources.speckle_inputs_property;
public override GH_Exposure Exposure => GH_Exposure.quarternary;
public override GH_Exposure Exposure => GH_Exposure.tertiary;
protected override void LoadVolatileData()
{
var propertyGroups = VolatileData
var objectPropertyGroups = VolatileData
.AllData(true)
.Where(goo => goo is SpecklePropertyGroupGoo)
.Select(goo =>
goo switch
{
SpecklePropertyGroupGoo geometryGoo => geometryGoo,
_ => throw new InvalidOperationException("Unexpected goo type")
}
)
.OfType<SpeckleObjectWrapperGoo>()
.Select(goo => goo.Value.Properties)
.ToList();
if (propertyGroups.Count == 0)
#if RHINO8_OR_GREATER
// support model objects direct piping also
if (objectPropertyGroups.Count != VolatileData.DataCount)
{
var modelObjects = VolatileData
.AllData(true)
.OfType<ModelObject>()
.Select(mo => new SpeckleObjectWrapperGoo(mo).Value.Properties)
.ToList();
objectPropertyGroups.AddRange(modelObjects);
}
#endif
if (objectPropertyGroups.Count == 0)
{
return;
}
var paths = GetPropertyPaths(propertyGroups);
var paths = GetPropertyPaths(objectPropertyGroups);
m_data.Clear();
m_data.AppendRange(paths.Select(s => new GH_String(s)));
}
@@ -1,99 +0,0 @@
using System.Runtime.InteropServices;
using Grasshopper.Kernel;
using Speckle.Connectors.GrasshopperShared.Parameters;
using Speckle.Connectors.GrasshopperShared.Properties;
namespace Speckle.Connectors.GrasshopperShared.Components.Objects;
[Guid("116F08A5-BAA7-45B3-B6C8-469E452C9AC7")]
public class QueryProperties : GH_Component
{
public override Guid ComponentGuid => GetType().GUID;
protected override Bitmap Icon => Resources.speckle_properties_query;
public override GH_Exposure Exposure => GH_Exposure.quarternary;
public QueryProperties()
: base(
"Query Properties",
"qP",
"Retrieves the values of the Properties at the specified keys",
ComponentCategories.PRIMARY_RIBBON,
ComponentCategories.OBJECTS
) { }
protected override void RegisterInputParams(GH_InputParamManager pManager)
{
pManager.AddParameter(
new SpecklePropertyGroupParam(),
"Properties",
"P",
"Speckle Properties",
GH_ParamAccess.item
);
pManager.AddTextParameter("Keys", "K", "Property keys to filter by", GH_ParamAccess.list);
}
protected override void RegisterOutputParams(GH_OutputParamManager pManager)
{
pManager.AddGenericParameter("Values", "V", "The values of the specified keys", GH_ParamAccess.list);
}
protected override void SolveInstance(IGH_DataAccess da)
{
SpecklePropertyGroupGoo? properties = null;
if (!da.GetData(0, ref properties))
{
AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, $"Input a Speckle Properties item");
return;
}
List<string> keys = new();
if (!da.GetDataList(1, keys))
{
AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, $"Input a key");
return;
}
if (properties == null || properties.Value.Count == 0 || keys.Count == 0)
{
return;
}
List<object?> values = new();
foreach (string key in keys)
{
ISpecklePropertyGoo? value = GetValueByPath(properties, key);
values.Add(value);
}
da.SetDataList(0, values);
}
public static ISpecklePropertyGoo? GetValueByPath(SpecklePropertyGroupGoo data, string path)
{
string[] keys = path.Split('.');
ISpecklePropertyGoo? current = data;
foreach (var key in keys)
{
if (current is SpecklePropertyGroupGoo dict)
{
if (dict.Value.TryGetValue(key, out ISpecklePropertyGoo? next))
{
current = next;
}
else
{
return null;
}
}
else
{
return null; // Current is not a dictionary, path is invalid
}
}
return current;
}
}
@@ -1,5 +1,7 @@
using System.Runtime.InteropServices;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Parameters;
using Grasshopper.Kernel.Types;
using Rhino.DocObjects;
using Speckle.Connectors.GrasshopperShared.HostApp;
using Speckle.Connectors.GrasshopperShared.Parameters;
@@ -38,8 +40,8 @@ public class QuerySpeckleObjects : GH_Component, IGH_VariableParameterComponent
pManager.AddTextParameter(
"Path",
"P",
"Get the Speckle objects in the sub-collection indicated by this path",
"C",
"Get the Speckle objects in the subcollection indicated by this path",
GH_ParamAccess.item
);
@@ -89,7 +91,7 @@ public class QuerySpeckleObjects : GH_Component, IGH_VariableParameterComponent
private List<int>? _outputFilterIndices;
// Caches the list of all objects by geometrybase type
private readonly Dictionary<ObjectType, List<SpeckleGeometryWrapper>> _filterDict = new();
private readonly Dictionary<ObjectType, List<SpeckleObjectWrapper>> _filterDict = new();
protected override void SolveInstance(IGH_DataAccess dataAccess)
{
@@ -107,7 +109,7 @@ public class QuerySpeckleObjects : GH_Component, IGH_VariableParameterComponent
// filter by collection path
// Note: the collection paths selector will omit the target collection from the path of nested collections.
// the discard ("_objects") will be used to indicate objects found directly in the target collection.
List<SpeckleWrapper> filteredObjects;
List<SpeckleObjectWrapper> filteredObjects;
SpeckleCollectionWrapper? targetCollectionWrapper = null;
if (!string.IsNullOrEmpty(path))
{
@@ -118,45 +120,25 @@ public class QuerySpeckleObjects : GH_Component, IGH_VariableParameterComponent
return;
}
filteredObjects = targetCollectionWrapper.GetAtomicObjects(true).ToList();
filteredObjects = targetCollectionWrapper.Elements.OfType<SpeckleObjectWrapper>().ToList();
}
else
{
filteredObjects = collectionWrapperGoo.Value.GetAtomicObjects(true).ToList();
filteredObjects = GetAllObjectsFromCollection(collectionWrapperGoo.Value).ToList();
}
// sort geometry objects by filters
var geometryObjects = filteredObjects.OfType<SpeckleGeometryWrapper>().ToList();
// sort objects by filters
if (_filterDict.Count == 0)
{
SortObjectsByGeometryBaseType(geometryObjects);
SortObjectsByGeometryBaseType(filteredObjects);
}
// Set output objects
for (int i = 0; i < Params.Output.Count; i++)
{
// determine output values based on parameter type
List<SpeckleWrapper> outputValues;
if (i == 0)
{
outputValues = filteredObjects;
}
else if (
Enum.TryParse(Params.Output[i].Name, out ObjectType filterType)
&& _filterDict.TryGetValue(filterType, out var filteredList)
)
{
outputValues = filteredList.Cast<SpeckleWrapper>().ToList();
}
else
{
outputValues = [];
}
var outputGoos = outputValues.Select(o => o.CreateGoo()).ToList();
// only use topology for the first output when we have a path
if (i == 0 && targetCollectionWrapper?.Topology is string topology && !string.IsNullOrEmpty(topology))
List<SpeckleObjectWrapper> outputValues = i == 0 ? filteredObjects : _filterDict[Filters[i - 1]];
List<IGH_Goo> outputGoos = outputValues.Select(o => o.CreateGoo()).ToList();
if (targetCollectionWrapper?.Topology is string topology && !string.IsNullOrEmpty(topology))
{
var tree = GrasshopperHelpers.CreateDataTreeFromTopologyAndItems(topology, outputGoos);
dataAccess.SetDataTree(i, tree);
@@ -169,7 +151,7 @@ public class QuerySpeckleObjects : GH_Component, IGH_VariableParameterComponent
}
// Sort the input objects by the FilterType enums, based on the type of their geometryBase
private void SortObjectsByGeometryBaseType(List<SpeckleGeometryWrapper> objs)
private void SortObjectsByGeometryBaseType(List<SpeckleObjectWrapper> objs)
{
if (_filterDict.Count > 0)
{
@@ -186,7 +168,7 @@ public class QuerySpeckleObjects : GH_Component, IGH_VariableParameterComponent
{
if (
wrapper.GeometryBase?.ObjectType is ObjectType objType
&& _filterDict.TryGetValue(objType, out List<SpeckleGeometryWrapper>? value)
&& _filterDict.TryGetValue(objType, out List<SpeckleObjectWrapper>? value)
)
{
value.Add(wrapper);
@@ -194,6 +176,25 @@ public class QuerySpeckleObjects : GH_Component, IGH_VariableParameterComponent
}
}
private IEnumerable<SpeckleObjectWrapper> GetAllObjectsFromCollection(SpeckleCollectionWrapper collectionWrapper)
{
foreach (ISpeckleCollectionObject element in collectionWrapper.Elements)
{
switch (element)
{
case SpeckleCollectionWrapper childCollectionWrapper:
foreach (var item in GetAllObjectsFromCollection(childCollectionWrapper))
{
yield return item;
}
break;
case SpeckleObjectWrapper objectWrapper:
yield return objectWrapper;
break;
}
}
}
private SpeckleCollectionWrapper? FindCollectionAtPath(SpeckleCollectionWrapper root, string unifiedPath)
{
// POC: SpeckleCollections now have a full list<string> path prop on them always. Is this easier to use?
@@ -260,7 +261,7 @@ public class QuerySpeckleObjects : GH_Component, IGH_VariableParameterComponent
_outputFilterIndices = null;
ObjectType filter = previousFilterIndex is null ? Filters.First() : Filters[(int)previousFilterIndex + 1];
return new SpeckleOutputParam
return new Param_GenericObject
{
Name = filter.ToString(),
NickName = GetFilterNickName(filter),
@@ -289,8 +290,10 @@ public class QuerySpeckleObjects : GH_Component, IGH_VariableParameterComponent
base.RemovedFromDocument(document);
}
private void OnParameterSourceChanged(object sender, GH_ParamServerEventArgs args) =>
private void OnParameterSourceChanged(object sender, GH_ParamServerEventArgs args)
{
// an empty filter dict will trigger the SortObjectsByGeometryBaseType method.
// we only want to re-sort objects if an input has changed, not on every trigger of solve instance.
_filterDict.Clear();
}
}
@@ -8,18 +8,20 @@ using Speckle.Connectors.GrasshopperShared.Properties;
namespace Speckle.Connectors.GrasshopperShared.Components.Objects;
[Guid("8D2E3F4A-1B5C-4E7F-9A8B-3C6D9E2F1A4B")]
public class SpeckleBlockDefinitionPassthrough()
: SpeckleSolveInstance(
"Speckle Block Definition",
"SBD",
"Create or modify a Speckle Block Definition",
ComponentCategories.PRIMARY_RIBBON,
ComponentCategories.OBJECTS
)
public class SpeckleBlockDefinitionPassthrough : GH_Component
{
public SpeckleBlockDefinitionPassthrough()
: base(
"Speckle Block Definition",
"SBD",
"Create or modify a Speckle Block Definition",
ComponentCategories.PRIMARY_RIBBON,
ComponentCategories.OBJECTS
) { }
public override Guid ComponentGuid => GetType().GUID;
protected override Bitmap Icon => Resources.speckle_objects_block_def;
public override GH_Exposure Exposure => GH_Exposure.tertiary;
public override GH_Exposure Exposure => GH_Exposure.secondary;
protected override void RegisterInputParams(GH_InputParamManager pManager)
{
@@ -33,9 +35,9 @@ public class SpeckleBlockDefinitionPassthrough()
Params.Input[0].Optional = true;
pManager.AddGenericParameter(
"Geometry",
"G",
"Geometry to include in the Block Definition. Speckle geometry and instances or Model objects and instances are accepted.",
"Objects",
"O",
"Objects to include in the Block Definition. Speckle objects and instances or Model objects and instances are accepted.",
GH_ParamAccess.list
);
Params.Input[1].Optional = true;
@@ -54,7 +56,7 @@ public class SpeckleBlockDefinitionPassthrough()
GH_ParamAccess.item
);
pManager.AddGenericParameter("Geometry", "G", "Geometry contained in the Block Definition", GH_ParamAccess.list);
pManager.AddGenericParameter("Objects", "O", "Objects contained in the Block Definition", GH_ParamAccess.list);
pManager.AddTextParameter("Name", "N", "Name of the Block Definition", GH_ParamAccess.item);
}
@@ -69,7 +71,7 @@ public class SpeckleBlockDefinitionPassthrough()
if (inputDefinition == null && inputObjects.Count == 0)
{
AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, $"Pass in a Definition or Geometry.");
AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, $"Pass in a Definition or Objects.");
return;
}
@@ -82,22 +84,20 @@ public class SpeckleBlockDefinitionPassthrough()
return;
}
// keep track of mutation
bool mutated = false;
// process the definition
// deep copy so we don't mutate the object
SpeckleBlockDefinitionWrapperGoo result = new();
if (inputDefinition != null)
{
result = new SpeckleBlockDefinitionWrapperGoo(inputDefinition.Value.DeepCopy());
result.Value.Base.id = null; // ⚠️ TODO: Co-ordinate with SDK. We're having to do this otherwise the serializer won't recompute mutated objects
}
SpeckleBlockDefinitionWrapperGoo result = inputDefinition != null ? new(inputDefinition.Value.DeepCopy()) : new();
// process geometry
if (inputObjects.Count > 0)
{
List<SpeckleGeometryWrapper> processedObjects = new();
List<SpeckleObjectWrapper> processedObjects = new();
foreach (IGH_Goo goo in inputObjects)
{
if (goo.ToSpeckleGeometryWrapper() is SpeckleGeometryWrapper gooWrapper)
if (goo.ToSpeckleObjectWrapper() is SpeckleObjectWrapper gooWrapper)
{
processedObjects.Add(gooWrapper);
}
@@ -109,6 +109,7 @@ public class SpeckleBlockDefinitionPassthrough()
result.Value.Objects = processedObjects;
result.Value.InstanceDefinitionProxy.objects = processedObjects.Select(o => o.ApplicationId!).ToList(); // TODO: this could also be set at the same time as `Objects` on the definition wrapper.
mutated = true;
}
// process name
@@ -121,10 +122,13 @@ public class SpeckleBlockDefinitionPassthrough()
}
result.Value.Name = inputName;
mutated = true;
}
// no need to process application Id.
// New definitions should have a new appID generated in the new() constructor, and we want to preserve old appID otherwise for changetracking.
// process application Id. Use a new appId if mutated, or if this is a new object
result.Value.ApplicationId = mutated
? Guid.NewGuid().ToString()
: result.Value.ApplicationId ?? Guid.NewGuid().ToString();
// set outputs
da.SetData(0, result);
@@ -8,18 +8,20 @@ using Speckle.Connectors.GrasshopperShared.Properties;
namespace Speckle.Connectors.GrasshopperShared.Components.Objects;
[Guid("2F8A9B1C-3D4E-5F6A-7B8C-9D0E1F2A3B4C")]
public class SpeckleBlockInstancePassthrough()
: SpeckleSolveInstance(
"Speckle Block Instance",
"SBI",
"Create or modify a Speckle Block Instance",
ComponentCategories.PRIMARY_RIBBON,
ComponentCategories.OBJECTS
)
public class SpeckleBlockInstancePassthrough : GH_Component
{
public SpeckleBlockInstancePassthrough()
: base(
"Speckle Block Instance",
"SBI",
"Create or modify a Speckle Block Instance",
ComponentCategories.PRIMARY_RIBBON,
ComponentCategories.OBJECTS
) { }
public override Guid ComponentGuid => GetType().GUID;
protected override Bitmap Icon => Resources.speckle_objects_block_inst;
public override GH_Exposure Exposure => GH_Exposure.tertiary;
public override GH_Exposure Exposure => GH_Exposure.secondary;
protected override void RegisterInputParams(GH_InputParamManager pManager)
{
@@ -149,19 +151,20 @@ public class SpeckleBlockInstancePassthrough()
SpeckleMaterialWrapperGoo? inputMaterial = null;
da.GetData(6, ref inputMaterial);
// keep track of mutation
// poc: we should not mark mutations on color or material, as this shouldn't affect the appId of the object, and will allow original display values to stay intact on send.
bool mutated = false;
// process the instance
// deep copy so we don't mutate the incoming object
SpeckleBlockInstanceWrapperGoo result = new();
if (inputInstance != null)
{
result = new SpeckleBlockInstanceWrapperGoo((SpeckleBlockInstanceWrapper)inputInstance.Value.DeepCopy());
result.Value.Base.id = null; // ⚠️ TODO: Co-ordinate with SDK. We're having to do this otherwise the serializer won't recompute mutated objects
}
// deep copy so we don't mutate the object
SpeckleBlockInstanceWrapperGoo result =
inputInstance != null ? new((SpeckleBlockInstanceWrapper)inputInstance.Value.DeepCopy()) : new();
// process definition
if (inputDefinition != null)
{
result.Value.Definition = inputDefinition.Value;
mutated = true;
}
// Process transform
@@ -171,6 +174,7 @@ public class SpeckleBlockInstancePassthrough()
if (extractedTransform.HasValue)
{
result.Value.Transform = extractedTransform.Value;
mutated = true;
}
else
{
@@ -186,12 +190,14 @@ public class SpeckleBlockInstancePassthrough()
if (inputName != null)
{
result.Value.Name = inputName;
mutated = true;
}
// Process properties
if (inputProperties != null)
{
result.Value.Properties = inputProperties;
mutated = true;
}
// process color (no mutation)
@@ -206,8 +212,10 @@ public class SpeckleBlockInstancePassthrough()
result.Value.Material = inputMaterial.Value;
}
// no need to process application id.
// new appids are generated if this is a new object, otherwise the input object appID should be preserved for change tracking.
// Generate new ApplicationId if mutated
result.Value.ApplicationId = mutated
? Guid.NewGuid().ToString()
: result.Value.ApplicationId ?? Guid.NewGuid().ToString();
// Set outputs
da.SetData(0, result);
@@ -1,173 +0,0 @@
using System.Runtime.InteropServices;
using Grasshopper.Kernel;
using Speckle.Connectors.GrasshopperShared.HostApp;
using Speckle.Connectors.GrasshopperShared.Parameters;
using Speckle.Connectors.GrasshopperShared.Properties;
namespace Speckle.Connectors.GrasshopperShared.Components.Objects;
[Guid("5CE8AA40-7706-4893-853D-4C77604548FA")]
public class SpeckleDataObjectPassthrough()
: SpeckleSolveInstance(
"Speckle Data Object",
"SDO",
"Create or modify a Speckle Data Object",
ComponentCategories.PRIMARY_RIBBON,
ComponentCategories.OBJECTS
)
{
public override Guid ComponentGuid => GetType().GUID;
protected override Bitmap Icon => Resources.speckle_objects_dataobject;
public override GH_Exposure Exposure => GH_Exposure.secondary;
protected override void RegisterInputParams(GH_InputParamManager pManager)
{
int objIndex = pManager.AddParameter(
new SpeckleDataObjectParam(),
"Speckle Data Object",
"SDO",
"Input Speckle DataObject. Model Objects are also accepted.",
GH_ParamAccess.item
);
Params.Input[objIndex].Optional = true;
int geoIndex = pManager.AddParameter(
new SpeckleGeometryWrapperParam(),
"Geometries",
"G",
"Geometries of the Speckle Data Object. Speckle Geometry and Grasshopper geometry are accepted.",
GH_ParamAccess.list
);
Params.Input[geoIndex].Optional = true;
int nameIndex = pManager.AddTextParameter("Name", "N", "Name of the Speckle Data Object", GH_ParamAccess.item);
Params.Input[nameIndex].Optional = true;
int propIndex = pManager.AddParameter(
new SpecklePropertyGroupParam(),
"Properties",
"P",
"The properties of the Speckle Data Object. Speckle Properties and User Content are accepted.",
GH_ParamAccess.item
);
Params.Input[propIndex].Optional = true;
}
protected override void RegisterOutputParams(GH_OutputParamManager pManager)
{
pManager.AddParameter(
new SpeckleDataObjectParam(),
"Speckle Data Object",
"SDO",
"Speckle Data Object",
GH_ParamAccess.item
);
pManager.AddParameter(
new SpeckleGeometryWrapperParam(),
"Geometries",
"G",
"Geometries of the Speckle Data Object.",
GH_ParamAccess.list
);
pManager.AddTextParameter("Name", "N", "Name of the Speckle Data Object", GH_ParamAccess.item);
pManager.AddParameter(
new SpecklePropertyGroupParam(),
"Properties",
"P",
"The properties of the Speckle Data Object",
GH_ParamAccess.item
);
pManager.AddTextParameter(
"Path",
"p",
$"The Collection Path of the Speckle Geometry, delimited with `{Constants.LAYER_PATH_DELIMITER}`",
GH_ParamAccess.item
);
}
protected override void SolveInstance(IGH_DataAccess da)
{
// process the object
// deep copy so we don't mutate the object
SpeckleDataObjectWrapperGoo inputObject = new();
SpeckleDataObjectWrapper? result = null;
if (da.GetData(0, ref inputObject))
{
result = inputObject.Value.DeepCopy();
result.Base.id = null; // ⚠️ TODO: Co-ordinate with SDK. We're having to do this otherwise the serializer won't recompute mutated objects
}
List<SpeckleGeometryWrapperGoo> inputGeometry = new();
if (!da.GetDataList(1, inputGeometry) && result == null)
{
AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, $"Pass in a Speckle DataObject or Geometries.");
return;
}
foreach (var inputGeo in inputGeometry)
{
if (inputGeo.Value is SpeckleBlockInstanceWrapper)
{
AddRuntimeMessage(GH_RuntimeMessageLevel.Error, $"DataObjects cannot contain Block Instances.");
return;
}
}
string? inputName = null;
da.GetData(2, ref inputName);
SpecklePropertyGroupGoo? inputProperties = null;
da.GetData(3, ref inputProperties);
// process geometry
if (result == null)
{
result = new SpeckleDataObjectWrapperGoo().Value;
}
if (inputGeometry.Count > 0)
{
result.Geometries.Clear();
foreach (var inputGeo in inputGeometry)
{
// deep copy so we don't mutate the input geo which may be speckle geometry
SpeckleGeometryWrapper mutatingGeo = inputGeo.Value.DeepCopy();
// assign fields before adding, otherwise they will be out of sync with wrapper
mutatingGeo.Base[Constants.NAME_PROP] = result.Name;
mutatingGeo.Properties = result.Properties;
mutatingGeo.Parent = result.Parent;
mutatingGeo.Path = result.Path;
result.Geometries.Add(mutatingGeo);
}
}
// process name
if (inputName != null)
{
result.Name = inputName;
}
// process properties
if (inputProperties != null)
{
result.Properties = inputProperties;
}
// get the path
string? path =
result.Path.Count > 1 ? string.Join(Constants.LAYER_PATH_DELIMITER, result.Path) : result.Path.FirstOrDefault();
// set all the data
da.SetData(0, result.CreateGoo());
da.SetDataList(1, result.Geometries);
da.SetData(2, result.Name);
da.SetData(3, result.Properties);
da.SetData(4, path);
}
}
@@ -4,30 +4,31 @@ using Grasshopper.Kernel.Types;
using Speckle.Connectors.GrasshopperShared.HostApp;
using Speckle.Connectors.GrasshopperShared.Parameters;
using Speckle.Connectors.GrasshopperShared.Properties;
using Speckle.Sdk.Common;
namespace Speckle.Connectors.GrasshopperShared.Components.Objects;
[Guid("F9418610-ACAE-4417-B010-19EBEA6A121F")]
public class SpeckleGeometryPassthrough()
: SpeckleSolveInstance(
"Speckle Geometry",
"SG",
"Create or modify a Speckle Geometry",
ComponentCategories.PRIMARY_RIBBON,
ComponentCategories.OBJECTS
)
public class SpeckleObjectPassthrough : GH_Component
{
public SpeckleObjectPassthrough()
: base(
"Speckle Object",
"SO",
"Create or modify a Speckle Object",
ComponentCategories.PRIMARY_RIBBON,
ComponentCategories.OBJECTS
) { }
public override Guid ComponentGuid => GetType().GUID;
protected override Bitmap Icon => Resources.speckle_objects_geometry;
public override GH_Exposure Exposure => GH_Exposure.secondary;
protected override Bitmap Icon => Resources.speckle_objects_object;
public override GH_Exposure Exposure => GH_Exposure.primary;
protected override void RegisterInputParams(GH_InputParamManager pManager)
{
int objIndex = pManager.AddGenericParameter(
"Speckle Geometry",
"SG",
"Input Speckle Geometry. Model Objects are also accepted.",
"Object",
"O",
"Input Object. Speckle Objects and Model Objects are accepted.",
GH_ParamAccess.item
);
Params.Input[objIndex].Optional = true;
@@ -35,36 +36,31 @@ public class SpeckleGeometryPassthrough()
int geoIndex = pManager.AddGeometryParameter(
"Geometry",
"G",
"Geometry of the Speckle Geometry.",
"Geometry of the Speckle Object.",
GH_ParamAccess.item
);
Params.Input[geoIndex].Optional = true;
int nameIndex = pManager.AddTextParameter("Name", "N", "Name of the Speckle Geometry", GH_ParamAccess.item);
int nameIndex = pManager.AddTextParameter("Name", "N", "Name of the Speckle Object", GH_ParamAccess.item);
Params.Input[nameIndex].Optional = true;
int propIndex = pManager.AddParameter(
new SpecklePropertyGroupParam(),
"Properties",
"P",
"The properties of the Speckle Geometry. Speckle Properties and User Content are accepted.",
"The properties of the Speckle Object. Speckle Properties and User Content are accepted.",
GH_ParamAccess.item
);
Params.Input[propIndex].Optional = true;
int colorIndex = pManager.AddColourParameter(
"Color",
"c",
"The color of the Speckle Geometry",
GH_ParamAccess.item
);
int colorIndex = pManager.AddColourParameter("Color", "c", "The color of the Speckle Object", GH_ParamAccess.item);
Params.Input[colorIndex].Optional = true;
int matIndex = pManager.AddParameter(
new SpeckleMaterialParam(),
"Material",
"m",
"The material of the Speckle Geometry. Display Materials, Model Materials, and Speckle Materials are accepted.",
"The material of the Speckle Object. Display Materials, Model Materials, and Speckle Materials are accepted.",
GH_ParamAccess.item
);
Params.Input[matIndex].Optional = true;
@@ -82,34 +78,39 @@ public class SpeckleGeometryPassthrough()
protected override void RegisterOutputParams(GH_OutputParamManager pManager)
{
pManager.AddGenericParameter("Speckle Geometry", "SG", "Speckle Geometry", GH_ParamAccess.item);
pManager.AddGenericParameter("Object", "O", "Speckle Object", GH_ParamAccess.item);
pManager.AddGeometryParameter("Geometry", "G", "Geometry of the Speckle Geometry.", GH_ParamAccess.item);
pManager.AddGeometryParameter(
"Geometry",
"G",
"Geometry of the Speckle Object. GeometryBase in Grasshopper includes text entities.",
GH_ParamAccess.item
);
pManager.AddTextParameter("Name", "N", "Name of the Speckle Geometry", GH_ParamAccess.item);
pManager.AddTextParameter("Name", "N", "Name of the Speckle Object", GH_ParamAccess.item);
pManager.AddParameter(
new SpecklePropertyGroupParam(),
"Properties",
"P",
"The properties of the Speckle Geometry",
"The properties of the Speckle Object",
GH_ParamAccess.item
);
pManager.AddColourParameter("Color", "c", "The color of the Speckle Geometry", GH_ParamAccess.item);
pManager.AddColourParameter("Color", "c", "The color of the Speckle Object", GH_ParamAccess.item);
pManager.AddParameter(
new SpeckleMaterialParam(),
"Material",
"M",
"The material of the Speckle Geometry.",
"The material of the Speckle Object.",
GH_ParamAccess.item
);
pManager.AddTextParameter(
"Path",
"p",
$"The Collection Path of the Speckle Geometry, delimited with `{Constants.LAYER_PATH_DELIMITER}`",
$"The Collection Path of the Speckle Object, delimited with `{Constants.LAYER_PATH_DELIMITER}`",
GH_ParamAccess.item
);
}
@@ -119,13 +120,12 @@ public class SpeckleGeometryPassthrough()
// process the object
// deep copy so we don't mutate the object
IGH_Goo? inputObject = null;
SpeckleGeometryWrapper? result = null;
SpeckleObjectWrapper? result = null;
if (da.GetData(0, ref inputObject))
{
if (inputObject?.ToSpeckleGeometryWrapper() is SpeckleGeometryWrapper gooWrapper)
if (inputObject?.ToSpeckleObjectWrapper() is SpeckleObjectWrapper gooWrapper)
{
result = gooWrapper.DeepCopy();
result.Base.id = null; // ⚠️ TODO: Co-ordinate with SDK. We're having to do this otherwise the serializer won't recompute mutated objects
}
else
{
@@ -139,7 +139,7 @@ public class SpeckleGeometryPassthrough()
if (result == null && inputGeometry == null)
{
AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, $"Pass in a Speckle Geometry or Geometry.");
AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, $"Pass in an Object or Geometry.");
return;
}
@@ -155,13 +155,17 @@ public class SpeckleGeometryPassthrough()
SpeckleMaterialWrapperGoo? inputMaterial = null;
da.GetData(5, ref inputMaterial);
// keep track of mutation
// poc: we should not mark mutations on color or material, as this shouldn't affect the appId of the object, and will allow original display values to stay intact on send.
bool mutated = false;
// process geometry
// deep copy so we don't mutate the input geo which may be speckle objects
if (inputGeometry != null)
{
if (inputGeometry.ToSpeckleGeometryWrapper() is SpeckleGeometryWrapper geoWrapper)
if (inputGeometry.ToSpeckleObjectWrapper() is SpeckleObjectWrapper geoWrapper)
{
SpeckleGeometryWrapper mutatingGeo = geoWrapper.DeepCopy();
SpeckleObjectWrapper mutatingGeo = geoWrapper.DeepCopy();
if (result is null)
{
result = mutatingGeo;
@@ -185,48 +189,53 @@ public class SpeckleGeometryPassthrough()
result.Base = mutatingGeo.Base;
result.GeometryBase = mutatingGeo.GeometryBase;
}
mutated = true;
}
else
{
AddRuntimeMessage(
GH_RuntimeMessageLevel.Error,
$"{inputGeometry.TypeName} is not a valid type for Speckle Geometry."
$"{inputGeometry.TypeName} is not a valid type for Speckle Objects."
);
return;
}
}
result.NotNull();
// process name
if (inputName != null)
{
result.Name = inputName;
result!.Name = inputName;
mutated = true;
}
// process properties
if (inputProperties != null)
{
result.Properties = inputProperties;
result!.Properties = inputProperties;
mutated = true;
}
// process color (no mutation)
if (inputColor != null)
{
result.Color = inputColor;
result!.Color = inputColor;
}
// process material (no mutation)
if (inputMaterial != null)
{
result.Material = inputMaterial.Value;
result!.Material = inputMaterial.Value;
}
// no need to process application Id.
// New definitions should have a new appID generated in the new() constructor, and we want to preserve old appID otherwise for changetracking.
// process application Id. Use a new appId if mutated, or if this is a new object
result!.ApplicationId = mutated ? Guid.NewGuid().ToString() : result!.ApplicationId ?? Guid.NewGuid().ToString();
// get the path
string? path =
result.Path.Count > 1 ? string.Join(Constants.LAYER_PATH_DELIMITER, result.Path) : result.Path.FirstOrDefault();
string path =
result!.Path.Count > 1
? string.Join(Constants.LAYER_PATH_DELIMITER, result!.Path)
: result!.Path.FirstOrDefault();
// set all the data
da.SetData(0, result.CreateGoo());
@@ -239,7 +248,7 @@ public class SpeckleGeometryPassthrough()
}
// keeps the geometry and wrapped base the same while assigning all other props from the inut wrapper
private void MatchNonGeometryProps(SpeckleGeometryWrapper wrapper, SpeckleGeometryWrapper wrapperToMatch)
private void MatchNonGeometryProps(SpeckleObjectWrapper wrapper, SpeckleObjectWrapper wrapperToMatch)
{
wrapper.Name = wrapperToMatch.Name;
wrapper.ApplicationId = wrapperToMatch.ApplicationId;
@@ -10,23 +10,11 @@ namespace Speckle.Connectors.GrasshopperShared.Components.Objects;
/// CreateSpeckleProperties passthrough component by key value pairs
/// </summary>
[Guid("FED2298C-0D2B-4868-94B5-B8D17F9385A5")]
public class SpecklePropertiesPassthrough : SpeckleSolveInstance
public class SpecklePropertiesPassthrough : GH_Component
{
public override Guid ComponentGuid => GetType().GUID;
protected override Bitmap Icon => Resources.speckle_properties_properties;
public override GH_Exposure Exposure => GH_Exposure.quarternary;
public SpecklePropertiesPassthrough()
: base(
"Speckle Properties",
"SP",
"Creates or modifies a set of properties for Speckle objects by keyvalue",
ComponentCategories.PRIMARY_RIBBON,
ComponentCategories.OBJECTS
)
{
Message = Mode.ToString();
}
public override GH_Exposure Exposure => GH_Exposure.tertiary;
private enum PropertyMode
{
@@ -50,6 +38,18 @@ public class SpecklePropertiesPassthrough : SpeckleSolveInstance
}
}
public SpecklePropertiesPassthrough()
: base(
"Speckle Properties",
"SP",
"Creates or modifies a set of properties for Speckle objects by keyvalue",
ComponentCategories.PRIMARY_RIBBON,
ComponentCategories.OBJECTS
)
{
Message = Mode.ToString();
}
protected override void RegisterInputParams(GH_InputParamManager pManager)
{
pManager.AddParameter(new SpecklePropertyGroupParam(), "Properties", "P", "Input properties", GH_ParamAccess.item);
@@ -95,16 +95,10 @@ public class SpecklePropertiesPassthrough : SpeckleSolveInstance
return;
}
// validate that keys and values are of valid length
if ((Mode == PropertyMode.Merge || Mode == PropertyMode.Replace) && inputKeys.Count != inputValues.Count)
// validate that keys and values are of same length
if (inputKeys.Count != inputValues.Count)
{
AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Keys and values are mismatched in length");
return;
}
if (Mode == PropertyMode.Remove && (inputKeys.Count == 0 || inputValues.Count > 0))
{
AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Only input keys to remove");
AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, $"Keys and values are mismatched in length");
return;
}
@@ -132,7 +126,7 @@ public class SpecklePropertiesPassthrough : SpeckleSolveInstance
for (int i = 0; i < inputKeys.Count; i++)
{
string key = inputKeys[i];
object? value = Mode == PropertyMode.Remove ? null : inputValues[i];
object? value = inputValues[i];
ISpecklePropertyGoo? convertedValue = null;
switch (value)
{
@@ -148,7 +142,7 @@ public class SpecklePropertiesPassthrough : SpeckleSolveInstance
{
AddRuntimeMessage(
GH_RuntimeMessageLevel.Error,
$"Values contain an invalid data type. Only strings, numbers, booleans, planes, vectors, intervals, and other Speckle properties are supported."
$"Values contain an invalid data type. Only strings, numbers, booleans, and other Speckle properties are supported."
);
return;
}
@@ -173,7 +167,13 @@ public class SpecklePropertiesPassthrough : SpeckleSolveInstance
result.Add(key, convertedValue);
break;
case PropertyMode.Remove:
result.Remove(key);
if (result.TryGetValue(key, out ISpecklePropertyGoo existingValue))
{
if (existingValue.Equals(convertedValue))
{
result.Remove(key);
}
}
break;
}
}
@@ -203,7 +203,8 @@ public class SpecklePropertiesPassthrough : SpeckleSolveInstance
modeItem.ToolTipText = "Existing properties will be cleared and replaced by input keyvalue pairs.";
break;
case PropertyMode.Remove:
modeItem.ToolTipText = "Existing keyvalue pairs that match the input keys will be removed from properties.";
modeItem.ToolTipText =
"Existing keyvalue pairs that match the input keyvalue pairs will be removed from properties.";
break;
}
}
@@ -1,188 +0,0 @@
using System.Diagnostics;
using Grasshopper.Kernel;
using Microsoft.Extensions.DependencyInjection;
using Speckle.Connectors.GrasshopperShared.Properties;
using Speckle.Connectors.GrasshopperShared.Registration;
using Speckle.Sdk;
using Speckle.Sdk.Credentials;
using Timer = System.Timers.Timer;
namespace Speckle.Connectors.GrasshopperShared.Components.Operations;
public class AccountManagerComponent : GH_Component, IDisposable
{
private bool _disposed;
private bool _isAddingAccount;
private Timer _timeoutTimer;
private Timer? _accountCheckerTimer;
private List<Account>? Accounts { get; set; }
private string? CustomUrlInput { get; set; }
private readonly IAccountManager _accountManager;
public override Guid ComponentGuid => new("c8ede281-acdf-49bf-8611-e9579be1bd41");
protected override Bitmap Icon => Resources.speckle_operations_account;
public override GH_Exposure Exposure => GH_Exposure.primary;
public GhContextMenuButton SignInButton { get; }
public AccountManagerComponent()
: base(
"Sign In",
"SI",
"Sign in to a Speckle Account",
ComponentCategories.PRIMARY_RIBBON,
ComponentCategories.OPERATIONS
)
{
Attributes = new AccountManagerComponentAttributes(this);
_accountManager = PriorityLoader.Container.GetRequiredService<IAccountManager>();
Accounts = _accountManager.GetAccounts().ToList();
SignInButton = new GhContextMenuButton("Sign In", "Sign In", "Click to sign into Speckle account.", AuthFlow);
}
private bool AuthFlow(ToolStripDropDown menu)
{
_isAddingAccount = true;
ResumeAccountChecker();
string url = string.IsNullOrEmpty(CustomUrlInput)
? "http://localhost:29364/auth/add-account"
: $"http://localhost:29364/auth/add-account?serverUrl={new Uri(CustomUrlInput).GetLeftPart(UriPartial.Authority)}";
// Open the auth URL in the default browser
try
{
Process.Start(new ProcessStartInfo { FileName = url, UseShellExecute = true });
}
catch (Exception ex) when (!ex.IsFatal())
{
AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, $"Sign in failed: {ex.Message}");
_isAddingAccount = false;
return false;
}
_timeoutTimer = new Timer(30_000);
_timeoutTimer.Elapsed += (s, e) =>
{
_timeoutTimer.Stop();
if (_isAddingAccount)
{
_isAddingAccount = false;
PauseAccountChecker();
AddRuntimeMessage(
GH_RuntimeMessageLevel.Warning,
"Sign in timed out. This may have happened because you tried adding an existing account."
);
}
};
_timeoutTimer.Start();
return true;
}
private bool CheckIfAccountAdded()
{
var previousAccountCount = Accounts?.Count ?? 0;
Accounts = _accountManager.GetAccounts().ToList();
return previousAccountCount < Accounts.Count;
}
private void PauseAccountChecker()
{
_accountCheckerTimer?.Stop();
_accountCheckerTimer?.Dispose();
_accountCheckerTimer = null;
}
private void ResumeAccountChecker()
{
_accountCheckerTimer?.Dispose();
_accountCheckerTimer = new Timer(1000); // check every 1 second
_accountCheckerTimer.Elapsed += (s, e) =>
{
bool accountAdded = CheckIfAccountAdded();
if (accountAdded)
{
_accountCheckerTimer.Stop();
_isAddingAccount = false;
// Optionally cancel timeout timer
_timeoutTimer?.Stop();
OnPingDocument()
?.ScheduleSolution(
100,
doc =>
{
ExpireSolution(true);
AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, "Account added successfully!");
}
);
}
};
_accountCheckerTimer.Start();
}
protected override void RegisterInputParams(GH_InputParamManager pManager)
{
var urlIndex = pManager.AddTextParameter(
"Server Url",
"Url",
"Optional URL for signing into a self deployed Speckle server.",
GH_ParamAccess.item
);
pManager[urlIndex].Optional = true;
}
protected override void RegisterOutputParams(GH_OutputParamManager pManager)
{
pManager.AddTextParameter($"Accounts", "Accounts", "List of available accounts", GH_ParamAccess.list);
}
protected override void SolveInstance(IGH_DataAccess da)
{
string? urlInput = null;
if (da.GetData(0, ref urlInput))
{
CustomUrlInput = urlInput;
}
if (Accounts != null)
{
da.SetDataList(0, Accounts);
}
else
{
da.SetDataList(0, new List<Account>());
}
}
public override void ExpirePreview(bool redraw)
{
SignInButton.ExpirePreview(redraw);
base.ExpirePreview(redraw);
}
protected virtual void Dispose(bool disposing)
{
if (!_disposed)
{
if (disposing)
{
_timeoutTimer?.Dispose();
_accountManager.Dispose();
_accountCheckerTimer?.Dispose();
}
_disposed = true;
}
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
}
@@ -1,54 +0,0 @@
using Grasshopper.GUI.Canvas;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Attributes;
namespace Speckle.Connectors.GrasshopperShared.Components.Operations;
public class AccountManagerComponentAttributes : GH_ComponentAttributes
{
private readonly AccountManagerComponent _typedOwner;
public AccountManagerComponentAttributes(IGH_Component component)
: base(component)
{
_typedOwner = (AccountManagerComponent)component;
}
public override void AppendToAttributeTree(List<IGH_Attributes> attributes)
{
base.AppendToAttributeTree(attributes);
_typedOwner.SignInButton.Attributes?.AppendToAttributeTree(attributes);
}
private void InitialiseAttributes()
{
_typedOwner.SignInButton.Attributes ??= new GhContextMenuButtonAttributes(_typedOwner.SignInButton)
{
Parent = this,
};
}
protected override void Layout()
{
base.Layout();
var baseRec = GH_Convert.ToRectangle(Bounds);
baseRec.Height += 26;
var btnRec = baseRec;
btnRec.Y = baseRec.Bottom - 26;
btnRec.Height = 26;
btnRec.Inflate(-2, -2);
Bounds = baseRec;
InitialiseAttributes();
_typedOwner.SignInButton.Attributes.Pivot = btnRec.Location;
_typedOwner.SignInButton.Attributes.Bounds = btnRec;
}
protected override void Render(GH_Canvas canvas, Graphics graphics, GH_CanvasChannel channel)
{
base.Render(canvas, graphics, channel);
_typedOwner.SignInButton.Attributes.RenderToCanvas(canvas, channel);
}
}
@@ -37,8 +37,6 @@ public class ReceiveAsyncComponent : GH_AsyncComponent<ReceiveAsyncComponent>
public override Guid ComponentGuid => GetType().GUID;
protected override Bitmap Icon => Resources.speckle_operations_load;
public override GH_Exposure Exposure => GH_Exposure.secondary;
public string InputType { get; set; }
public bool AutoReceive { get; set; }
public string ReceivedVersionId { get; set; }
@@ -271,7 +269,7 @@ public class ReceiveAsyncComponent : GH_AsyncComponent<ReceiveAsyncComponent>
ResetApiClient(UrlModelResource);
}
private void ApiClient_OnVersionCreated(object? sender, ProjectVersionsUpdatedMessage e)
private void ApiClient_OnVersionCreated(object sender, ProjectVersionsUpdatedMessage e)
{
HandleNewCommit();
}
@@ -25,6 +25,9 @@ namespace Speckle.Connectors.GrasshopperShared.Components.Operations.Send;
[Guid("52481972-7867-404F-8D9F-E1481183F355")]
public class SendAsyncComponent : GH_AsyncComponent<SendAsyncComponent>
{
public GhContextMenuButton ProjectContextMenuButton { get; set; }
public GhContextMenuButton ModelContextMenuButton { get; set; }
public SendAsyncComponent()
: base(
"Publish",
@@ -41,7 +44,6 @@ public class SendAsyncComponent : GH_AsyncComponent<SendAsyncComponent>
public override Guid ComponentGuid => GetType().GUID;
protected override Bitmap Icon => Resources.speckle_operations_publish;
public override GH_Exposure Exposure => GH_Exposure.secondary;
public ComponentState CurrentComponentState { get; set; } = ComponentState.NeedsInput;
public bool AutoSend { get; set; }
@@ -54,8 +56,6 @@ public class SendAsyncComponent : GH_AsyncComponent<SendAsyncComponent>
public SpeckleUrlModelResource? OutputParam { get; set; }
public bool HasMultipleInputs { get; set; }
public string? VersionMessage { get; private set; }
protected override void RegisterInputParams(GH_InputParamManager pManager)
{
pManager.AddParameter(new SpeckleUrlModelResourceParam());
@@ -66,8 +66,6 @@ public class SendAsyncComponent : GH_AsyncComponent<SendAsyncComponent>
"The collection model object to send",
GH_ParamAccess.item
);
pManager.AddTextParameter("Version Message", "versionMessage", "The version message", GH_ParamAccess.item);
pManager[2].Optional = true;
}
protected override void RegisterOutputParams(GH_OutputParamManager pManager)
@@ -276,10 +274,6 @@ public class SendAsyncComponent : GH_AsyncComponent<SendAsyncComponent>
return;
}
RootCollectionWrapper = rootCollectionWrapper;
string? versionMessage = null;
da.GetData(2, ref versionMessage);
VersionMessage = versionMessage;
}
}
@@ -407,13 +401,7 @@ public class SendComponentWorker : WorkerInstance<SendAsyncComponent>
using var scope = PriorityLoader.CreateScopeForActiveDocument();
var sendOperation = scope.ServiceProvider.GetRequiredService<SendOperation<SpeckleCollectionWrapperGoo>>();
SendOperationResult? result = await sendOperation
.Execute(
new List<SpeckleCollectionWrapperGoo>() { rootCollectionWrapper },
sendInfo,
Parent.VersionMessage,
progress,
CancellationToken
)
.Execute(new List<SpeckleCollectionWrapperGoo>() { rootCollectionWrapper }, sendInfo, progress, CancellationToken)
.ConfigureAwait(false);
// TODO: If we have NodeRun events later, better to have `ComponentTracker` to use across components
@@ -49,8 +49,6 @@ public class SendComponent : SpeckleTaskCapableComponent<SendComponentInput, Sen
public string? Url { get; private set; }
public string? VersionMessage { get; private set; }
protected override Bitmap Icon => Resources.speckle_operations_syncpublish;
protected override void RegisterInputParams(GH_InputParamManager pManager)
@@ -63,8 +61,7 @@ public class SendComponent : SpeckleTaskCapableComponent<SendComponentInput, Sen
"The model collection to publish",
GH_ParamAccess.item
);
pManager.AddTextParameter("Version Message", "versionMessage", "The version message", GH_ParamAccess.item);
pManager[2].Optional = true;
pManager.AddBooleanParameter("Run", "r", "Run the publish operation", GH_ParamAccess.item);
}
@@ -89,12 +86,8 @@ public class SendComponent : SpeckleTaskCapableComponent<SendComponentInput, Sen
SpeckleCollectionWrapperGoo rootCollectionWrapper = new();
da.GetData(1, ref rootCollectionWrapper);
string? versionMessage = null;
da.GetData(2, ref versionMessage);
VersionMessage = versionMessage;
bool run = false;
da.GetData(3, ref run);
da.GetData(2, ref run);
return new SendComponentInput(resource.NotNull(), rootCollectionWrapper, run);
}
@@ -184,14 +177,8 @@ public class SendComponent : SpeckleTaskCapableComponent<SendComponentInput, Sen
using var client = clientFactory.Create(account);
var sendInfo = await input.Resource.GetSendInfo(client, cancellationToken).ConfigureAwait(false);
await sendOperation
.Execute(
new List<SpeckleCollectionWrapperGoo>() { input.Input },
sendInfo,
VersionMessage,
progress,
cancellationToken
)
var result = await sendOperation
.Execute(new List<SpeckleCollectionWrapperGoo>() { input.Input }, sendInfo, progress, cancellationToken)
.ConfigureAwait(false);
// TODO: If we have NodeRun events later, better to have `ComponentTracker` to use across components
@@ -32,12 +32,10 @@ public class SpeckleSelectModelComponent : GH_Component
protected override Bitmap Icon => Resources.speckle_inputs_model;
public override GH_Exposure Exposure => GH_Exposure.primary;
public SpeckleSelectModelComponent()
: base(
"Speckle Model",
"SM",
"Speckle Model URL",
"URL",
"User selectable model from Speckle",
ComponentCategories.PRIMARY_RIBBON,
ComponentCategories.OPERATIONS
@@ -1,5 +1,3 @@
using Speckle.Sdk.Common;
namespace Speckle.Connectors.GrasshopperShared.Components.Operations.Wizard;
public class SearchToolStripMenuItem
@@ -126,7 +124,7 @@ public class SearchToolStripMenuItem
ParentDropDown.ItemClicked += (sender, args) =>
{
// we are not closing the dropdown only if user clicked the first item of the dropdown which is TextBox that we use for search
if (args.ClickedItem.NotNull().Name == SearchItemId)
if (args.ClickedItem.Name == SearchItemId)
{
return;
}
@@ -22,7 +22,7 @@ public class SpeckleOperationWizard
public Account? SelectedAccount { get; private set; }
public List<Account>? Accounts { get; }
public LimitedWorkspace? SelectedWorkspace { get; private set; }
public Workspace? SelectedWorkspace { get; private set; }
public Project? SelectedProject { get; private set; }
public Model? SelectedModel { get; private set; }
public Version? SelectedVersion { get; private set; }
@@ -416,42 +416,38 @@ public class SpeckleOperationWizard
{
return;
}
using IClient client = _clientFactory.Create(SelectedAccount);
var activeWorkspace = client.ActiveUser.GetActiveWorkspace().Result;
LimitedWorkspace? selectedWorkspace =
Workspace? selectedWorkspace =
SelectedWorkspace
?? activeWorkspace
?? (WorkspaceMenuHandler.Workspaces?.items.Count > 0 ? WorkspaceMenuHandler.Workspaces?.items[0] : null);
SelectedWorkspace = selectedWorkspace;
WorkspaceMenuHandler.RedrawMenuButton(SelectedWorkspace);
}
private void OnWorkspaceSelected(object? sender, WorkspaceSelectedEventArgs e)
private void OnWorkspaceSelected(object sender, WorkspaceSelectedEventArgs e)
{
SelectedWorkspace = e.SelectedWorkspace;
ResetProjects();
_refreshComponent.Invoke();
}
private void OnProjectSelected(object? sender, ProjectSelectedEventArgs e)
private void OnProjectSelected(object sender, ProjectSelectedEventArgs e)
{
SelectedProject = e.SelectedProject;
ResetModels();
_refreshComponent.Invoke();
}
private void OnModelSelected(object? sender, ModelSelectedEventArgs e)
private void OnModelSelected(object sender, ModelSelectedEventArgs e)
{
SelectedModel = e.SelectedModel;
ResetVersions(true);
_refreshComponent.Invoke();
}
private void OnVersionSelected(object? sender, VersionSelectedEventArgs e)
private void OnVersionSelected(object sender, VersionSelectedEventArgs e)
{
SelectedVersion = e.SelectedVersion;
IsLatestVersion = e.IsLatest;
@@ -3,9 +3,9 @@ using Speckle.Sdk.Api.GraphQL.Models;
namespace Speckle.Connectors.GrasshopperShared.Components.Operations.Wizard;
public class WorkspaceSelectedEventArgs(LimitedWorkspace? model) : EventArgs
public class WorkspaceSelectedEventArgs(Workspace? model) : EventArgs
{
public LimitedWorkspace? SelectedWorkspace { get; } = model;
public Workspace? SelectedWorkspace { get; } = model;
}
public class WorkspaceMenuHandler
@@ -15,7 +15,7 @@ public class WorkspaceMenuHandler
public bool IsPersonalProjects { get; set; }
private SearchToolStripMenuItem? _searchItem;
private readonly Func<Task> _createWorkspace;
private LimitedWorkspace? SelectedWorkspace { get; set; }
private Workspace? SelectedWorkspace { get; set; }
public ResourceCollection<Workspace>? Workspaces { get; set; }
public Bitmap? Logo { get; private set; }
@@ -103,7 +103,7 @@ public class WorkspaceMenuHandler
);
}
private void OnWorkspaceSelected(LimitedWorkspace? workspace)
private void OnWorkspaceSelected(Workspace? workspace)
{
IsPersonalProjects = workspace == null;
_menu?.Close();
@@ -112,7 +112,7 @@ public class WorkspaceMenuHandler
WorkspaceSelected?.Invoke(this, new WorkspaceSelectedEventArgs(workspace));
}
public void RedrawMenuButton(LimitedWorkspace? workspace)
public void RedrawMenuButton(Workspace? workspace)
{
var suffix = WorkspaceContextMenuButton.Enabled
? "Left-click to select another workspace."
@@ -1,19 +0,0 @@
using Grasshopper.Kernel;
using Speckle.Connectors.GrasshopperShared.HostApp;
namespace Speckle.Connectors.GrasshopperShared.Components;
public abstract class SpeckleSolveInstance(
string name,
string nickname,
string description,
string category,
string subCategory
) : GH_Component(name, nickname, description, category, subCategory)
{
protected override void BeforeSolveInstance() => SpeckleConversionContext.SetupCurrent();
protected override void AfterSolveInstance() => SpeckleConversionContext.EndCurrent();
protected abstract override void SolveInstance(IGH_DataAccess da);
}
@@ -1,11 +0,0 @@
using Grasshopper.Kernel;
using Speckle.Connectors.GrasshopperShared.Properties;
namespace Speckle.Connectors.GrasshopperShared.HostApp.Extras;
public class ListAccessStateTag : GH_StateTag
{
public override string Description => "This parameter is set to List access";
public override string Name => "List Access";
public override Bitmap Icon => Resources.speckle_state_access;
}
@@ -128,45 +128,12 @@ public static class GrasshopperHelpers
}
/// <summary>
/// Gets all of the atomic objects inside a collection wrapper.
/// </summary>
/// <param name="coll"></param>
/// <param name="recurse">Will recurse into sub collections to get atomic objects</param>
/// <returns></returns>
public static IEnumerable<SpeckleWrapper> GetAtomicObjects(this SpeckleCollectionWrapper coll, bool recurse = false)
{
foreach (var element in coll.Elements)
{
switch (element)
{
case SpeckleDataObjectWrapper dataObject:
yield return dataObject;
break;
case SpeckleGeometryWrapper geo: // covers both instances and geo
yield return geo;
break;
case SpeckleCollectionWrapper subColl:
if (recurse)
{
foreach (var subElement in subColl.GetAtomicObjects(recurse))
{
yield return subElement;
}
}
break;
default:
break;
}
}
}
/// <summary>
/// Attempts to cast an IGH_Goo to a Speckle Geometry Wrapper
/// Attempts to cast an IGH_Goo to a Speckle Object Wrapper
/// </summary>
/// <param name="goo"></param>
/// <returns>A reference to the Speckle Geometry Wrapper from the goo, if any</returns>
/// <returns>A reference to the Speckle Object Wrapper from the goo, if any</returns>
/// <remarks>This method **does not** deep copy the return value</remarks>
public static SpeckleGeometryWrapper? ToSpeckleGeometryWrapper(this IGH_Goo goo)
public static SpeckleObjectWrapper? ToSpeckleObjectWrapper(this IGH_Goo goo)
{
SpeckleBlockInstanceWrapperGoo instanceGoo = new();
if (instanceGoo.CastFrom(goo))
@@ -175,35 +142,7 @@ public static class GrasshopperHelpers
}
else
{
SpeckleGeometryWrapperGoo objGoo = new();
return objGoo.CastFrom(goo) ? objGoo.Value : null;
}
}
/// <summary>
/// Attempts to cast an IGH_Goo to a Speckle Geometry or DataObject Wrapper
/// </summary>
/// <param name="goo"></param>
/// <returns>A reference to the Speckle Wrapper from the goo, if any</returns>
/// <remarks>This method **does not** deep copy the return value</remarks>
public static SpeckleWrapper? ToSpeckleObjectWrapper(this IGH_Goo goo)
{
// first preserve data objects as they are
// this is processed first because data objects with 1 display value can be cast to geometry wrappers
if (goo is SpeckleDataObjectWrapperGoo dataObject)
{
return dataObject.Value;
}
// then try to process as geometry
SpeckleBlockInstanceWrapperGoo instanceGoo = new();
if (instanceGoo.CastFrom(goo))
{
return instanceGoo.Value;
}
else
{
SpeckleGeometryWrapperGoo objGoo = new();
SpeckleObjectWrapperGoo objGoo = new();
return objGoo.CastFrom(goo) ? objGoo.Value : null;
}
}
@@ -3,7 +3,6 @@ using Rhino.Geometry;
using Speckle.Connectors.GrasshopperShared.Registration;
using Speckle.Converters.Common;
using Speckle.Sdk;
using Speckle.Sdk.Common;
using Speckle.Sdk.Models;
namespace Speckle.Connectors.GrasshopperShared.HostApp;
@@ -11,59 +10,25 @@ namespace Speckle.Connectors.GrasshopperShared.HostApp;
/// <summary>
/// Handles grasshopper wide converters. We don't need new converters, unless the document changes - this class should handle this (untested).
/// </summary>
public class SpeckleConversionContext(IRootToSpeckleConverter speckleConverter, IRootToHostConverter hostConverter)
public static class SpeckleConversionContext
{
private static IServiceScope? s_scope;
private static SpeckleConversionContext? s_currentContext;
public static SpeckleConversionContext Current
public static Base ConvertToSpeckle(GeometryBase geo)
{
get
{
if (s_currentContext == null)
{
SetupCurrent();
}
return s_currentContext.NotNull();
}
using var scope = PriorityLoader.CreateScopeForActiveDocument();
return scope.ServiceProvider.GetRequiredService<IRootToSpeckleConverter>().Convert(geo);
}
public static void SetupCurrent()
public static List<(GeometryBase, Base)> ConvertToHost(Base input)
{
if (s_currentContext != null)
{
return;
}
s_scope = PriorityLoader.CreateScopeForActiveDocument();
s_currentContext = s_scope.Get<SpeckleConversionContext>();
}
public static void EndCurrent()
{
if (s_currentContext == null)
{
return;
}
s_currentContext = null;
s_scope?.Dispose();
s_scope = null;
}
public Base ConvertToSpeckle(object geo) => speckleConverter.Convert(geo);
public List<(object, Base)> ConvertToHost(Base input)
{
var result = hostConverter.Convert(input);
using var scope = PriorityLoader.CreateScopeForActiveDocument();
var result = scope.ServiceProvider.GetRequiredService<IRootToHostConverter>().Convert(input);
return result switch
{
GeometryBase geometry => [(geometry, input)],
List<GeometryBase> geometryList => geometryList.Select(o => ((object)o, input)).ToList(),
IEnumerable<(GeometryBase, Base)> fallbackConversionResult
=> fallbackConversionResult.Select(o => ((object)o.Item1, o.Item2)).ToList(),
object obj => [(obj, input)],
_ => throw new SpeckleException("Failed to convert input to grasshopper")
List<GeometryBase> geometryList => geometryList.Select(o => (o, input)).ToList(),
IEnumerable<(GeometryBase, Base)> fallbackConversionResult => fallbackConversionResult.ToList(),
_ => throw new SpeckleException("Failed to convert input to rhino")
};
}
}
@@ -40,7 +40,7 @@ internal sealed class GrasshopperBlockUnpacker
public HashSet<string> UnpackBlocks(
IReadOnlyCollection<TraversalContext> blockComponents,
IReadOnlyCollection<InstanceDefinitionProxy>? definitionProxies,
Dictionary<string, SpeckleGeometryWrapper> convertedObjectsMap,
Dictionary<string, SpeckleObjectWrapper> convertedObjectsMap,
GrasshopperCollectionRebuilder collectionRebuilder
)
{
@@ -95,7 +95,7 @@ internal sealed class GrasshopperBlockUnpacker
/// </summary>
private void CreateBlocksInDependencyOrder(
List<(Collection[] path, IInstanceComponent component)> sortedComponents,
Dictionary<string, SpeckleGeometryWrapper> convertedObjectsMap,
Dictionary<string, SpeckleObjectWrapper> convertedObjectsMap,
GrasshopperCollectionRebuilder collectionRebuilder,
HashSet<string> consumedObjectIds
)
@@ -159,11 +159,11 @@ internal sealed class GrasshopperBlockUnpacker
private SpeckleBlockDefinitionWrapper? CreateBlockDefinitionWrapper(
InstanceDefinitionProxy definitionProxy,
string definitionId,
Dictionary<string, SpeckleGeometryWrapper> convertedObjectsMap,
Dictionary<string, SpeckleObjectWrapper> convertedObjectsMap,
HashSet<string> consumedObjectIds
)
{
var definitionObjects = new List<SpeckleGeometryWrapper>();
var definitionObjects = new List<SpeckleObjectWrapper>();
var currentDefinitionObjectIds = new HashSet<string>();
foreach (var objectId in definitionProxy.objects)
@@ -25,7 +25,7 @@ internal sealed class GrasshopperCollectionRebuilder
}
public void AppendSpeckleGrasshopperObject(
ISpeckleCollectionObject speckleGrasshopperObjectWrapper,
SpeckleObjectWrapper speckleGrasshopperObjectWrapper,
List<Collection> collectionPath,
GrasshopperColorUnpacker colorUnpacker,
GrasshopperMaterialUnpacker materialUnpacker
@@ -43,7 +43,7 @@ internal sealed class GrasshopperCollectionRebuilder
{
// first check if cache already has this collection
string fullPath = string.Concat(path);
if (_cache.TryGetValue(fullPath, out SpeckleCollectionWrapper? col))
if (_cache.TryGetValue(fullPath, out SpeckleCollectionWrapper col))
{
return col;
}
@@ -58,7 +58,7 @@ internal sealed class GrasshopperCollectionRebuilder
string key = string.Concat(currentLayerPath);
// check cache
if (_cache.TryGetValue(key, out SpeckleCollectionWrapper? currentCol))
if (_cache.TryGetValue(key, out SpeckleCollectionWrapper currentCol))
{
previousCollectionWrapper = currentCol;
continue;
@@ -118,9 +118,7 @@ internal sealed class GrasshopperCollectionRebuilder
{
// Remove consumed objects from this level
collection.Elements.RemoveAll(element =>
element is SpeckleGeometryWrapper obj
&& obj.ApplicationId != null
&& consumedObjectIds.Contains(obj.ApplicationId)
element is SpeckleObjectWrapper obj && obj.ApplicationId != null && consumedObjectIds.Contains(obj.ApplicationId)
);
// Recurse into child collections
@@ -1,5 +1,5 @@
using Speckle.Connectors.Common.Extensions;
using Speckle.Connectors.Common.Operations;
using Speckle.Connectors.Logging;
using Speckle.Sdk.Api;
using Speckle.Sdk.Logging;
using Speckle.Sdk.Models;
@@ -41,8 +41,7 @@ public class GrasshopperReceiveOperation
// 2 - Check account exist
var account = receiveInfo.Account;
using IClient apiClient = _clientFactory.Create(account);
using var userScope = UserActivityScope.AddUserScope(account);
using var userScope = ActivityScope.SetTag(Consts.USER_ID, account.GetHashedEmail());
Speckle.Sdk.Api.GraphQL.Models.Version? version = await apiClient
.Version.Get(receiveInfo.SelectedVersionId, receiveInfo.ProjectId, cancellationToken)
@@ -18,7 +18,7 @@ using Speckle.Sdk.Models.Instances;
/// </remarks>
internal sealed class LocalToGlobalMapHandler
{
public Dictionary<string, SpeckleGeometryWrapper> ConvertedObjectsMap { get; } = new();
public Dictionary<string, SpeckleObjectWrapper> ConvertedObjectsMap { get; } = new();
public readonly GrasshopperCollectionRebuilder CollectionRebuilder;
private readonly TraversalContextUnpacker _traversalContextUnpacker;
@@ -53,7 +53,7 @@ internal sealed class LocalToGlobalMapHandler
try
{
List<(object, Base)> converted = SpeckleConversionContext.Current.ConvertToHost(obj);
List<(GeometryBase, Base)> converted = SpeckleConversionContext.ConvertToHost(obj);
if (converted.Count == 0)
{
@@ -69,102 +69,51 @@ internal sealed class LocalToGlobalMapHandler
_materialUnpacker
);
// Extract name and properties
SpecklePropertyGroupGoo propertyGroup = new();
string name = "";
if (obj is Speckle.Objects.Data.DataObject dataObject)
{
// get color and mat on dataobject first
Color? dataObjColor = _colorUnpacker.Cache.TryGetValue(
dataObject.applicationId ?? "",
out var cachedDataObjColor
)
? cachedDataObjColor
: null;
SpeckleMaterialWrapper? dataObjMat = _materialUnpacker.Cache.TryGetValue(
dataObject.applicationId ?? "",
out var cachedDataObjMaterial
)
? cachedDataObjMaterial
: null;
// get geometries
List<SpeckleGeometryWrapper> geometries = new();
foreach ((object convertedObj, Base original) in converted)
{
if (convertedObj is GeometryBase geometryBase)
{
SpeckleGeometryWrapper wrapper =
new()
{
Base = original,
GeometryBase = geometryBase,
Color = _colorUnpacker.Cache.TryGetValue(original.applicationId ?? "", out var cachedObjColor)
? cachedObjColor
: dataObjColor,
Material = _materialUnpacker.Cache.TryGetValue(original.applicationId ?? "", out var cachedObjMaterial)
? cachedObjMaterial
: dataObjMat,
};
geometries.Add(wrapper);
}
}
SpecklePropertyGroupGoo propertyGroup = new();
propertyGroup.CastFrom(dataObject.properties);
// remove the displayvalue of the original dataobject since these are now processed and stored on the wrapper
// to prevent storing of duplicate Base
dataObject.displayValue.Clear();
var dataObjectWrapper = new SpeckleDataObjectWrapper()
{
Base = dataObject,
Geometries = geometries,
Path = path.Select(p => p.name).ToList(),
Parent = objectCollection,
Name = dataObject.name,
Properties = propertyGroup,
ApplicationId = dataObject.applicationId,
};
// Add to collections (not to map since these won't be definition objects)
CollectionRebuilder.AppendSpeckleGrasshopperObject(dataObjectWrapper, path, _colorUnpacker, _materialUnpacker);
name = dataObject.name;
}
else
{
SpecklePropertyGroupGoo propertyGroup = new();
if (obj[Constants.PROPERTIES_PROP] is Dictionary<string, object?> props)
{
propertyGroup.CastFrom(props);
}
foreach ((object convertedObj, Base original) in converted)
if (obj[Constants.NAME_PROP] is string objName)
{
if (convertedObj is GeometryBase geometryBase)
{
var wrapper = new SpeckleGeometryWrapper()
{
Base = original,
Path = path.Select(p => p.name).ToList(),
Parent = objectCollection,
GeometryBase = geometryBase,
Properties = propertyGroup,
Name = obj[Constants.NAME_PROP] as string ?? "",
Color = _colorUnpacker.Cache.TryGetValue(original.applicationId ?? "", out var cachedObjColor)
? cachedObjColor
: null,
Material = _materialUnpacker.Cache.TryGetValue(original.applicationId ?? "", out var cachedObjMaterial)
? cachedObjMaterial
: null,
ApplicationId = objId
};
// Always add to both map and collections
ConvertedObjectsMap[objId] = wrapper;
CollectionRebuilder.AppendSpeckleGrasshopperObject(wrapper, path, _colorUnpacker, _materialUnpacker);
}
name = objName;
}
}
foreach ((GeometryBase geometryBase, Base original) in converted)
{
var wrapper = new SpeckleObjectWrapper()
{
Base = original,
Path = path.Select(p => p.name).ToList(),
Parent = objectCollection,
GeometryBase = geometryBase,
Properties = propertyGroup,
Name = name,
Color = _colorUnpacker.Cache.TryGetValue(original.applicationId ?? "", out var cachedObjColor)
? cachedObjColor
: null,
Material = _materialUnpacker.Cache.TryGetValue(original.applicationId ?? "", out var cachedObjMaterial)
? cachedObjMaterial
: null,
ApplicationId = objId
};
// Always add to both map and collections
ConvertedObjectsMap[objId] = wrapper;
CollectionRebuilder.AppendSpeckleGrasshopperObject(wrapper, path, _colorUnpacker, _materialUnpacker);
}
}
catch (Exception ex) when (!ex.IsFatal())
{
@@ -10,9 +10,9 @@ namespace Speckle.Connectors.GrasshopperShared.Operations.Send;
/// </summary>
internal sealed class GrasshopperBlockPacker
{
private readonly IInstanceObjectsManager<SpeckleGeometryWrapper, List<string>> _instanceObjectsManager;
private readonly IInstanceObjectsManager<SpeckleObjectWrapper, List<string>> _instanceObjectsManager;
public GrasshopperBlockPacker(IInstanceObjectsManager<SpeckleGeometryWrapper, List<string>> instanceObjectsManager)
public GrasshopperBlockPacker(IInstanceObjectsManager<SpeckleObjectWrapper, List<string>> instanceObjectsManager)
{
_instanceObjectsManager = instanceObjectsManager;
}
@@ -31,7 +31,7 @@ internal sealed class GrasshopperBlockPacker
/// </summary>
/// <param name="blockInstance">The block instance to process</param>
/// <param name="depth">Current nesting depth (0 = top level, increases for nested instances)</param>
public List<SpeckleGeometryWrapper>? ProcessInstance(SpeckleBlockInstanceWrapper? blockInstance, int depth = 0)
public List<SpeckleObjectWrapper>? ProcessInstance(SpeckleBlockInstanceWrapper? blockInstance, int depth = 0)
{
if (blockInstance?.Definition == null)
{
@@ -51,7 +51,7 @@ internal sealed class GrasshopperBlockPacker
/// Processes a block definition, adding it and its objects to InstanceObjectsManager.
/// Updates maxDepth for existing definitions when encountered at greater depths.
/// </summary>
private List<SpeckleGeometryWrapper>? ProcessDefinition(SpeckleBlockDefinitionWrapper definition, int depth = 0)
private List<SpeckleObjectWrapper>? ProcessDefinition(SpeckleBlockDefinitionWrapper definition, int depth = 0)
{
// Use wrapper's id as definitive identifier. Create if empty.
definition.ApplicationId ??= Guid.NewGuid().ToString();
@@ -73,7 +73,7 @@ internal sealed class GrasshopperBlockPacker
}
// Process objects recursively
var objectsToAdd = new List<SpeckleGeometryWrapper>();
var objectsToAdd = new List<SpeckleObjectWrapper>();
var currentObjectIds = new List<string>(); // Track current object IDs for proxy update
foreach (var obj in definition.Objects)
@@ -5,17 +5,16 @@ using Speckle.Connectors.GrasshopperShared.HostApp;
using Speckle.Connectors.GrasshopperShared.Parameters;
using Speckle.Sdk.Models;
using Speckle.Sdk.Models.Collections;
using DataObject = Speckle.Objects.Data.DataObject;
namespace Speckle.Connectors.GrasshopperShared.Operations.Send;
public class GrasshopperRootObjectBuilder : IRootObjectBuilder<SpeckleCollectionWrapperGoo>
{
private readonly IInstanceObjectsManager<SpeckleGeometryWrapper, List<string>> _instanceObjectsManager;
private readonly IInstanceObjectsManager<SpeckleObjectWrapper, List<string>> _instanceObjectsManager;
// each Build() call gets a fresh scoped IInstanceObjectsManager
public GrasshopperRootObjectBuilder(
IInstanceObjectsManager<SpeckleGeometryWrapper, List<string>> instanceObjectsManager
IInstanceObjectsManager<SpeckleObjectWrapper, List<string>> instanceObjectsManager
)
{
_instanceObjectsManager = instanceObjectsManager;
@@ -30,11 +29,14 @@ public class GrasshopperRootObjectBuilder : IRootObjectBuilder<SpeckleCollection
public Task<RootObjectBuilderResult> Build(
IReadOnlyList<SpeckleCollectionWrapperGoo> input,
string projectId,
SendInfo sendInfo,
IProgress<CardProgress> onOperationProgressed,
CancellationToken ct = default
)
{
// TODO: Send info is used in other connectors to get the project ID to populate the SendConversionCache
Console.WriteLine($"Send Info {sendInfo}");
// deep copy input (to not mutate input) and set the input collection name to "Grasshopper Model"
var inputCollectionGoo = (SpeckleCollectionWrapperGoo)input[0].Duplicate();
inputCollectionGoo.Value.Name = "Grasshopper Model";
@@ -88,9 +90,9 @@ public class GrasshopperRootObjectBuilder : IRootObjectBuilder<SpeckleCollection
Unwrap(collWrapper, colorPacker, materialPacker, blockPacker);
break;
case SpeckleGeometryWrapper so: // handles both SpeckleObjectWrapper and SpeckleBlockInstanceWrapper (inheritance)
case SpeckleObjectWrapper so: // handles both SpeckleObjectWrapper and SpeckleBlockInstanceWrapper (inheritance)
// convert wrapper to base and add to collection - common for all object wrappers
Base objectBase = UnwrapGeometry(so);
Base objectBase = Unwrap(so);
string applicationId = objectBase.applicationId!;
currentColl.elements.Add(objectBase);
@@ -104,14 +106,6 @@ public class GrasshopperRootObjectBuilder : IRootObjectBuilder<SpeckleCollection
colorPacker.ProcessColor(applicationId, so.Color);
materialPacker.ProcessMaterial(applicationId, so.Material);
break;
case SpeckleDataObjectWrapper dataObjectWrapper:
// convert wrapper to DataObject and add to collection
// UnwrapDataObject will unwrap underlying geometry and handle color and material
// arguably doing too much, but I'm apprehensive looping twice without good reason
DataObject dataObject = UnwrapDataObject(dataObjectWrapper, colorPacker, materialPacker);
currentColl.elements.Add(dataObject);
break;
}
}
@@ -131,12 +125,12 @@ public class GrasshopperRootObjectBuilder : IRootObjectBuilder<SpeckleCollection
}
/// <summary>
/// Converts a <see cref="SpeckleGeometryWrapper"/> to underlying Base object with dynamically attached properties.
/// Converts a <see cref="SpeckleObjectWrapper"/> to underlying Base object with dynamically attached properties.
/// </summary>
/// <remarks>
/// POC: if we move properties assignment to auto set the wrapped base, we can get rid of this entirely!
/// </remarks>
private Base UnwrapGeometry(SpeckleGeometryWrapper wrapper)
private Base Unwrap(SpeckleObjectWrapper wrapper)
{
Dictionary<string, object?> props = [];
Base baseObject = wrapper.Base;
@@ -170,7 +164,7 @@ public class GrasshopperRootObjectBuilder : IRootObjectBuilder<SpeckleCollection
{
foreach (var definitionObject in definitionObjects)
{
Base defObjectBase = UnwrapGeometry(definitionObject);
Base defObjectBase = Unwrap(definitionObject);
string applicationId = defObjectBase.applicationId!;
// just add to current collection for now
@@ -182,40 +176,6 @@ public class GrasshopperRootObjectBuilder : IRootObjectBuilder<SpeckleCollection
}
}
/// <summary>
/// Converts a <see cref="SpeckleDataObjectWrapper"/> to underlying DataObject with properly configured displayValue.
/// Processes colors and materials for each individual geometry during conversion.
/// </summary>
private DataObject UnwrapDataObject(
SpeckleDataObjectWrapper wrapper,
GrasshopperColorPacker colorPacker,
GrasshopperMaterialPacker materialPacker
)
{
DataObject dataObject = wrapper.DataObject;
// Convert geometries back to Base objects for displayValue
var displayValue = new List<Base>();
foreach (var geometryWrapper in wrapper.Geometries)
{
Base geometryBase = UnwrapGeometry(geometryWrapper);
displayValue.Add(geometryBase);
// process color and material for each geometry while we're iterating
// this could be in the switch statements (like SpeckleGeometryWrapper) but then we're unnecessarily looping twice
if (geometryWrapper.ApplicationId != null)
{
colorPacker.ProcessColor(geometryWrapper.ApplicationId, geometryWrapper.Color);
materialPacker.ProcessMaterial(geometryWrapper.ApplicationId, geometryWrapper.Material);
}
}
// Update the DataObject's displayValue
dataObject.displayValue = displayValue;
return dataObject;
}
/*
// will cache the object wrappers and group them by similarity.
private void ProcessObjectWrapper(SpeckleObjectWrapper objectWrapper, ref HashSet<string> processedIds)
@@ -1,69 +0,0 @@
using GH_IO.Serialization;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Attributes;
using Grasshopper.Kernel.Parameters;
namespace Speckle.Connectors.GrasshopperShared.Parameters;
/// <summary>
/// Simple extension of Param_GenericObject that adds "Extract parameter" functionality.
/// Follows the existing v3 codebase patterns.
/// </summary>
public class SpeckleOutputParam : Param_GenericObject
{
public override Guid ComponentGuid => new("D2B4713D-FE8B-4EF0-8445-B6096DB15B24");
public override void AppendAdditionalMenuItems(ToolStripDropDown menu)
{
base.AppendAdditionalMenuItems(menu);
// only show extract parameter option for output parameters that have no connections
if (Kind == GH_ParamKind.output && Recipients.Count == 0)
{
Menu_AppendSeparator(menu);
Menu_AppendItem(menu, "Extract parameter", Menu_ExtractOutputParameterClicked, true);
}
}
/// <summary>
/// Extract parameter implementation - taken from v2 legacy and simplified for v3.
/// </summary>
private void Menu_ExtractOutputParameterClicked(object sender, EventArgs e)
{
var archive = new GH_Archive();
if (!archive.AppendObject(this, "Parameter"))
{
return;
}
var newParam = new SpeckleOutputParam();
newParam.CreateAttributes();
if (!archive.ExtractObject(newParam, "Parameter"))
{
return;
}
newParam.NewInstanceGuid();
newParam.Attributes.Selected = false;
newParam.Attributes.PerformLayout();
newParam.Attributes.Pivot = new PointF(
Attributes.Parent.Bounds.Right + newParam.Attributes.Bounds.Width * 0.5f + 15,
Attributes.Pivot.Y
);
newParam.MutableNickName = true;
if (newParam.Attributes is GH_FloatingParamAttributes floating)
{
floating.PerformLayout();
}
var document = OnPingDocument();
if (document != null)
{
document.AddObject(newParam, false);
newParam.AddSource(this);
newParam.ExpireSolution(true);
}
}
}
@@ -1,8 +1,5 @@
using Grasshopper.Documentation;
using Grasshopper.Kernel.Types;
using Speckle.Connectors.GrasshopperShared.HostApp;
using Speckle.Sdk;
using Speckle.Sdk.Models;
namespace Speckle.Connectors.GrasshopperShared.Parameters;
@@ -35,44 +32,9 @@ public class SpecklePropertyGoo : GH_Goo<object>, ISpecklePropertyGoo
{
switch (source)
{
case List<object?> list:
List<object?> castedItems = new();
foreach (var item in list)
{
SpecklePropertyGoo itemGoo = new();
if (itemGoo.CastFrom(item))
{
castedItems.Add(itemGoo.Value);
}
else
{
return false;
}
}
Value = castedItems;
return true;
case SpecklePropertyGoo speckleProperty:
Value = speckleProperty.Value;
return true;
case Base @base: // this would capture cases of planes, vectors, and intervals from GH
try
{
Value = SpeckleConversionContext.Current.ConvertToHost(@base!).First().Item1;
return true;
}
catch (SpeckleException)
{
return false;
}
case GH_Plane plane:
Value = plane.Value;
return true;
case GH_Vector vector:
Value = vector.Value;
return true;
case GH_Interval interval:
Value = interval.Value;
return true;
case double d:
Value = d;
return true;
@@ -127,27 +89,6 @@ public class SpecklePropertyGoo : GH_Goo<object>, ISpecklePropertyGoo
return true;
}
if (type.IsAssignableFrom(typeof(GH_Plane)))
{
object ptr = new GH_Plane((Rhino.Geometry.Plane)Value);
target = (T)ptr;
return true;
}
if (type.IsAssignableFrom(typeof(GH_Vector)))
{
object ptr = new GH_Vector((Rhino.Geometry.Vector3d)Value);
target = (T)ptr;
return true;
}
if (type.IsAssignableFrom(typeof(GH_Interval)))
{
object ptr = new GH_Interval((Rhino.Geometry.Interval)Value);
target = (T)ptr;
return true;
}
if (type.IsAssignableFrom(typeof(GH_Integer)))
{
object ptr = new GH_Integer((int)Value);
@@ -185,15 +126,8 @@ public class SpecklePropertyGoo : GH_Goo<object>, ISpecklePropertyGoo
{
return false;
}
switch (Value)
{
case Rhino.Geometry.Plane plane:
return prop.Value is Rhino.Geometry.Plane otherPlane && plane.Equals(otherPlane);
case Rhino.Geometry.Vector3d vector:
return prop.Value is Rhino.Geometry.Vector3d otherVector && vector.Equals(otherVector);
case Rhino.Geometry.Interval interval:
return prop.Value is Rhino.Geometry.Interval otherInterval && interval.Equals(otherInterval);
case string s:
return s == prop.Value.ToString();
case bool b:
@@ -22,51 +22,21 @@ public partial class SpecklePropertyGroupGoo : GH_Goo<Dictionary<string, ISpeckl
return CastFromModelObject(modelObject.UserText);
case ModelUserText userText:
var processedDictionary = ConvertToNested(userText.ToDictionary(o => o.Key, o => (object)o.Value));
return CastFrom(processedDictionary);
Dictionary<string, ISpecklePropertyGoo> dictionary = new();
foreach (KeyValuePair<string, string> entry in userText)
{
SpecklePropertyGoo value = new() { Value = entry.Value };
dictionary.Add(entry.Key, value);
}
Value = dictionary;
return true;
default:
return false;
}
}
// Property keys may already be concatenated with the `.` char, eg if baked from grasshopper.
public Dictionary<string, object> ConvertToNested(Dictionary<string, object> flatDict)
{
var nestedDict = new Dictionary<string, object>();
foreach (string keyPath in flatDict.Keys)
{
var keys = keyPath.Split('.');
var current = nestedDict;
for (int i = 0; i < keys.Length; i++)
{
var key = keys[i];
if (i == keys.Length - 1)
{
current[key] = flatDict[keyPath];
}
else
{
if (!current.TryGetValue(key, out var next))
{
var newDict = new Dictionary<string, object>();
current[key] = newDict;
current = newDict;
}
else
{
current = (Dictionary<string, object>)next;
}
}
}
}
return nestedDict;
}
private bool CastToModelObject<T>(ref T target)
{
var type = typeof(T);
@@ -1,6 +1,9 @@
using Grasshopper.Kernel;
using Grasshopper.Kernel.Types;
using Rhino.DocObjects;
using Speckle.Connectors.GrasshopperShared.Components;
using Speckle.Connectors.GrasshopperShared.HostApp;
using Speckle.Connectors.GrasshopperShared.Properties;
namespace Speckle.Connectors.GrasshopperShared.Parameters;
@@ -88,7 +91,7 @@ public partial class SpecklePropertyGroupGoo : GH_Goo<Dictionary<string, ISpeckl
var otherProps = propGroup.Flatten();
foreach (var entry in thisProps)
{
if (!otherProps.TryGetValue(entry.Key, out SpecklePropertyGoo? otherValue) || !entry.Value.Equals(otherValue))
if (!otherProps.TryGetValue(entry.Key, out SpecklePropertyGoo otherValue) || !entry.Value.Equals(otherValue))
{
return false;
}
@@ -186,27 +189,11 @@ public partial class SpecklePropertyGroupGoo : GH_Goo<Dictionary<string, ISpeckl
Dictionary<string, object?> dict = new();
foreach (var kvp in properties)
{
object? val = null;
switch (kvp.Value)
{
case SpecklePropertyGroupGoo propertyGroup:
val = UnwrapWorker(propertyGroup.Value);
break;
case SpecklePropertyGoo property:
switch (property.Value)
{
case Rhino.Geometry.Plane:
case Rhino.Geometry.Vector3d:
case Rhino.Geometry.Interval:
val = SpeckleConversionContext.Current.ConvertToSpeckle(property.Value);
break;
default:
val = property.Value;
break;
}
break;
}
object? val = kvp.Value is SpecklePropertyGroupGoo propertyGroup
? UnwrapWorker(propertyGroup.Value)
: kvp.Value is SpecklePropertyGoo property
? property.Value
: null;
dict.Add(kvp.Key, val);
}
@@ -215,3 +202,29 @@ public partial class SpecklePropertyGroupGoo : GH_Goo<Dictionary<string, ISpeckl
public override int GetHashCode() => base.GetHashCode();
}
public class SpecklePropertyGroupParam : GH_Param<SpecklePropertyGroupGoo>
{
public override Guid ComponentGuid => new("AF4757C3-BA33-4ACD-A92B-C80356043129");
protected override Bitmap Icon => Resources.speckle_param_properties;
public override GH_Exposure Exposure => GH_Exposure.secondary;
public SpecklePropertyGroupParam()
: this(GH_ParamAccess.item) { }
public SpecklePropertyGroupParam(IGH_InstanceDescription tag)
: base(tag) { }
public SpecklePropertyGroupParam(IGH_InstanceDescription tag, GH_ParamAccess access)
: base(tag, access) { }
public SpecklePropertyGroupParam(GH_ParamAccess access)
: base(
"Speckle Properties",
"SP",
"Represents a set of Speckle Properties",
ComponentCategories.PRIMARY_RIBBON,
ComponentCategories.PARAMETERS,
access
) { }
}

Some files were not shown because too many files have changed in this diff Show More