Grasshopper connector T4 template removed?

Hi @AlanRynne,

I noticed that when merging the Rhino and Grasshopper connectors the TextTemplatingFileGenerator for the Grasshopper SchemaBuilder components has been removed. Has this been done intentionally and are you planning to add it again, or has it been replaced by a different feature?

See RH-GH: Unified Rhino/Gh solution. by AlanRynne · Pull Request #1385 · specklesystems/speckle-sharp (github.com)

Thanks!
Kelvin

Hi Kevin, sorry I missed the reply on this one. I removed it due to some troubles we were having getting the setup right in different machines from the get-go.

I usually just rebuild the nodes before every release directly from the IDE, which works fine… but I’d agree that the rebuild option was neater… we can re-evaluate this decision for sure! :+1:t3:

1 Like

Hi @AlanRynne,

Indeed, I’ve also been experiencing some issues. Any chance you have encountered following error already when compiling the template and know how to fix it?

System.IO.FileNotFoundException: Could not load file or assembly 'SpeckleCore2, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'SpeckleCore2, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null'
   at ConnectorGrasshopperUtils.CSOUtils.ListAvailableTypes(Boolean includeDeprecated)

Thanks!

Hi @AlanRynne,

FYI, I noticed a bug for the SchemaBuilderComponents.
The MaterialSchemaComponent class for the first SchemaInfo method of object Objects.Structural.Materials.Material is missing in file SchemaBuilderGen.cs, as it is being overwritten by the MaterialSchemaComponent of the RevitMaterial object.

Still curious to hear whether you know a solution to my FileNotFoundException issue above.

Thanks!
Kelvin

Hey! Not sure about the missing DLL thing, but usually a clean + rebuild should get it back in track. Make sure the GrasshopperUtils project does build, as that is being used in the TT template.

As for the naming, not sure if you’re referring to these 2:

There is an issue with the “Structural Material” that needs to be renamed because it overlaps with the normal Material naming, maybe that’s the one you’re referring to? That one is a bit of a breaking change so we haven’t gotten to that yet.

I’ll poke @Reynold_Chan to see if he can get to it :smiley:

2 Likes

Didn’t work, it seems that it is looking for the SpeckleCore assembly in the wrong folders, perhaps an issue with my template generator settings. Thanks for the tip though!


It’s basically the first one in the screenshot above of the Structural Materials that doesn’t appear in the SchemaBuilderGen.cs file, while in the past it did. Indeed, there is a component naming overlap with the normal/Revit Material schema object.

Thanks for the follow up!

1 Like

While we fix this… you can still access all available schemas with the generic Schema Builder node :wink: They should all show up in the pop-up window

1 Like

I’m guessing you’re using VS for this right? I use Rider so I’d have to check in VS, I’ll get back to you in a bit with this

1 Like

hey @kelvin,

If you don’t mind, I’m going to use you as a test subject for a bit :angel:t3:

I just pushed some changes to this branch, that contains:

  • A full rename of Structure.Material to StructuralMaterial
  • A small change in the t4 template generator (+ i enabled it on project rebuild)

Could you pull this branch and check if that fixes your issues? :slight_smile: If so, as soon as @Reynold_Chan approves it I’ll merge it in, and should be released for 2.9 :partying_face:

1 Like

Hi @AlanRynne,

Don’t mind at all, seeing as it would help me a lot to get this fixed :wink:

Correct.

The issues persist when generating the template. It seems that my generator is looking for assemblies in the wrong locations.
Initially it can’t find the ConnectorGrasshopperUtils.dll:

Error An exception was thrown while trying to compile the transformation code. The following Exception was thrown:
System.IO.FileNotFoundException: Could not find a part of the path ‘C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\ConnectorGrasshopperUtils\bin\ConnectorGrasshopperUtils.dll’.
File name: ‘…\ConnectorGrasshopperUtils\bin\ConnectorGrasshopperUtils.dll’ —> System.IO.DirectoryNotFoundException: Could not find a part of the path ‘C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\ConnectorGrasshopperUtils\bin\ConnectorGrasshopperUtils.dll’.

This I solved by changing line 4 in the template .tt file:
<#@ assembly name="..\ConnectorGrasshopperUtils\bin\ConnectorGrasshopperUtils.dll" #>
becomes
<#@ assembly name="$(SolutionDir)\ConnectorGrasshopperUtils\bin\ConnectorGrasshopperUtils.dll" #>
But then of course it starts having trouble finding the SpeckleCore2 assembly.

Error Running transformation: System.IO.FileNotFoundException: Could not load file or assembly ‘SpeckleCore2, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null’ or one of its dependencies. The system cannot find the file specified.
File name: ‘SpeckleCore2, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null’
at ConnectorGrasshopperUtils.CSOUtils.ListAvailableTypes(Boolean includeDeprecated)

Specifying the location of the SpeckleCore2 by adding the following line does not solve it:
<#@ assembly name="$(SolutionDir)\ConnectorGrasshopperUtils\bin\SpeckleCore2.dll" #>
I guess additional dependencies will have to be added this way, or do you know a more elegant solution?

Once the T4 template works I’ll check whether the Material object issue is solved.

1 Like

Yup, i got those too initially when trying to get it to auto-generate on build, but with the dotnet t4 approach it should be working, as we’re passing in the -P flag, which let’s the generator know were else to find the assemblies.

Is the error you’re getting also being generated on the dotnet t4 step? This would only happen on rebuild

You should see something like this if it’s working:

Here’s the raw command i’m running, could you test that on your side? You’ll need to change the paths to match wherever your speckle-sharp repo is:

dotnet t4 -o Y:\Documents\Speckle\speckle-sharp\ConnectorGrasshopper\ConnectorGrasshopper\SchemaBuilder\SchemaBuilderGen.cs Y:\Documents\Speckle\speckle-sharp\ConnectorGrasshopper\ConnectorGrasshopper\SchemaBuilder\SchemaBuilderGen.tt -P=Y:\Documents\Speckle\speckle-sharp\ConnectorGrasshopper\ConnectorGrasshopper\

If you installed the t4 tool globally, you can omit the initial dotnet

As for swapping it to $(SolutionDir), I’ll look into it since it seems a neater approach.

Final edit :sweat_smile:

Make sure your csproj is not adding automatically the <AutoGen>true</AutoGen> flag to the tt file, as it would continue to try and regenerate on build (even when told not to on TransformOnBuild)

1 Like

Yes! Thanks @AlanRynne, it works now. :partying_face:
As you mentioned, all of the Visual Studio features for the T4 templates fail, but the dotnet command with -P flag did the trick.
Then it was a matter of cleaning and rebuilding all projects (to make sure the Material objects are correctly changed to StructuralMaterial objects; this didn’t give errors when running the command in PowerShell, but it did during VS build). Everything builds nicely now, and the overlap for the Material SchemaBuilder components seems to be fixed as well.

2 Likes

Awesome news! :slight_smile:

Glad my changes got it working! This will be merged into our release/2.9 branch, and will make it’s way into main when we release the next stable version.

Don’t hesitate to let us know if you need anything else, or if you have any ideas on how to improve this (PR’s are welcome too, but let us know beforehand so we can coordinate) :wink:

1 Like