-
Notifications
You must be signed in to change notification settings - Fork 334
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding rhino3dm ReadTextEntity sample
- Loading branch information
Showing
7 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
rhino3dm/cs/SampleCSReadTextEntities/SampleCSTextEntitiesRead.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.6.0-beta" /> | ||
</ItemGroup> | ||
|
||
</Project> |
22 changes: 22 additions & 0 deletions
22
rhino3dm/cs/SampleCSReadTextEntities/SampleCSTextEntitiesRead.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import * as fs from 'fs' | ||
import rhino3dm from 'rhino3dm' | ||
|
||
const rhino = await rhino3dm() | ||
console.log('Loaded rhino3dm.') | ||
|
||
// read model | ||
const model = '../../../models/textEntities_r8.3dm' | ||
|
||
const buffer = fs.readFileSync(model) | ||
const arr = new Uint8Array(buffer) | ||
const doc = rhino.File3dm.fromByteArray(arr) | ||
const objects = doc.objects() | ||
|
||
for ( let i = 0; i < objects.count; i ++ ) { | ||
const ro = objects.get(i) | ||
const geometry = ro.geometry() | ||
console.log('-------------------') | ||
console.log(geometry.plainText) | ||
console.log(geometry.plainTextWithFields) | ||
console.log(geometry.richText) | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "sampletextentities", | ||
"version": "0.0.1", | ||
"description": "", | ||
"main": "index.js", | ||
"type": "module", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "", | ||
"license": "MIT", | ||
"dependencies": { | ||
"rhino3dm": "^8.6.0-dev" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# requires rhino3dm.py ^8.6.0b0 | ||
import rhino3dm | ||
model = rhino3dm.File3dm.Read('../models/textEntities_r8.3dm') | ||
objects = model.Objects | ||
for obj in objects: | ||
geo = obj.Geometry | ||
print(geo.ObjectType) | ||
print(geo.PlainText) | ||
print(geo.RichText) | ||
print(geo.PlainTextWithFields) |