Skip to content

Commit

Permalink
Add text entity read sample
Browse files Browse the repository at this point in the history
  • Loading branch information
fraguada committed Feb 20, 2024
1 parent e18ebb5 commit 6364a63
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
29 changes: 29 additions & 0 deletions rhino3dm/cs/SampleCSTextEntitiesRead/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Rhino.FileIO;

Console.WriteLine("---Sample: Read Text Entities from file---");

var path = Directory.GetCurrentDirectory();

Console.WriteLine("Current Directory: {0}",path);

File3dm file3dm = new File3dm();

//the path will be different whether you are using dotnet run or debugging
if(path.Contains("net7.0")){
file3dm = File3dm.Read("../../../../../models/textEntities_r8.3dm");
} else{
file3dm = File3dm.Read("../../models/textEntities_r8.3dm");
}

Console.WriteLine("Number of objects in file {0}", file3dm.Objects.Count);

foreach( var ro in file3dm.Objects )
{
var te = ro.Geometry as Rhino.Geometry.TextEntity;
if( te != null) {
Console.WriteLine("-----------");
Console.WriteLine("Plain text: {0}", te.PlainText);
Console.WriteLine("Rich text: {0}", te.RichText);
Console.WriteLine("Plain text with fields: {0}", te.PlainTextWithFields);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Rhino3dm" Version="8.4.0" />
</ItemGroup>

</Project>
22 changes: 22 additions & 0 deletions rhino3dm/cs/SampleCSTextEntitiesRead/SampleCSTextEntitiesRead.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleCSTextEntitiesRead", "SampleCSTextEntitiesRead.csproj", "{94766DA2-2B87-413E-95E3-AFAF81E4542A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{94766DA2-2B87-413E-95E3-AFAF81E4542A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{94766DA2-2B87-413E-95E3-AFAF81E4542A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{94766DA2-2B87-413E-95E3-AFAF81E4542A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{94766DA2-2B87-413E-95E3-AFAF81E4542A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

0 comments on commit 6364a63

Please sign in to comment.