Skip to content
This repository has been archived by the owner on Aug 28, 2021. It is now read-only.

fixes #308 #309

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion SpeckleGrasshopper/ObjectCreation/SchemaBuilderComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
using GH_IO.Serialization;
using Grasshopper.Kernel.Special;
using System.Drawing;
using System.Linq.Expressions;
using System.CodeDom;

namespace SpeckleGrasshopper.UserDataUtils
{
Expand Down Expand Up @@ -120,7 +122,7 @@ public override void AppendAdditionalMenuItems(ToolStripDropDown menu)
{
subMenus[type.Assembly].Items.Add(type.Name, null, (sender, e) => SwitchToType(type));
}

}
catch (Exception e)
{
Expand Down Expand Up @@ -394,6 +396,35 @@ protected override void SolveInstance(IGH_DataAccess DA)
}
catch { }

try
{
var conv = Convert.ChangeType(innerValue, prop.PropertyType);
prop.SetValue(outputObject, conv);
continue;
}
catch { }

//issues with nullable types, lazy solution below
try
{
if (prop.PropertyType == typeof(int?)){
prop.SetValue(outputObject, (int?)innerValue);
continue;
}
else if (prop.PropertyType == typeof(double?) && innerValue.GetType() == typeof(int))
{
prop.SetValue(outputObject, (double?)(int)innerValue);
continue;
}
else if (prop.PropertyType == typeof(double?))
{
prop.SetValue(outputObject, (double?)innerValue);
continue;
}

}
catch { }

this.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Unable to set " + Params.Input[i].Name + ".");
}

Expand Down
38 changes: 25 additions & 13 deletions SpeckleGrasshopper/SpeckleGrasshopper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -159,20 +159,32 @@
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target> -->

<Target Name="AfterBuild">
<Copy SourceFiles="$(TargetPath)" DestinationFiles="$(TargetDir)\$(ProjectName).gha" />
<Delete Files="$(TargetPath)" />
<ItemGroup>
<MySourceFiles Include="$(ProjectDir)bin\$(ConfigurationName)\**\*.*" />
</ItemGroup>
<Copy SourceFiles="@(MySourceFiles)" DestinationFiles="@(MySourceFiles->'$(SolutionDir)\$(ConfigurationName)\%(RecursiveDir)%(Filename)%(Extension)')">
<Output TaskParameter="CopiedFiles" ItemName="SuccessfullyCopiedFiles" />
</Copy>
</Target>
<CallTarget Condition="'$(Configuration)' == 'Debug'" Targets="AfterBuildDebug"/>
<CallTarget Condition="'$(Configuration)' == 'Release'" Targets="AfterBuildRelease"/>
</Target>
<Target Name="AfterBuildDebug">
<Copy SourceFiles="$(TargetPath)" DestinationFiles="$(TargetDir)\$(ProjectName).gha" />
<Delete Files="$(TargetPath)" />
<ItemGroup>
<MySourceFiles Include="$(ProjectDir)bin\$(ConfigurationName)\**\*.*" />
</ItemGroup>
<Copy SourceFiles="@(MySourceFiles)" DestinationFolder="$(AppData)\McNeel\Rhinoceros\6.0\Plug-ins\Speckle Rhino Plugin (512d9705-6f92-49ca-a606-d6d5c1ac6aa2)">
<Output TaskParameter="CopiedFiles" ItemName="SuccessfullyCopiedFiles" />
</Copy>
</Target>
<Target Name="AfterBuildRelease">
<Copy SourceFiles="$(TargetPath)" DestinationFiles="$(TargetDir)\$(ProjectName).gha" />
<Delete Files="$(TargetPath)" />
<ItemGroup>
<MySourceFiles Include="$(ProjectDir)bin\$(ConfigurationName)\**\*.*" />
</ItemGroup>
<Copy SourceFiles="@(MySourceFiles)" DestinationFiles="@(MySourceFiles->'$(SolutionDir)\$(ConfigurationName)\%(RecursiveDir)%(Filename)%(Extension)')">
<Output TaskParameter="CopiedFiles" ItemName="SuccessfullyCopiedFiles" />
</Copy>
</Target>

<PropertyGroup>
<FallbackCulture>en-US</FallbackCulture>
</PropertyGroup>
Expand Down