add docfx samples.
This commit is contained in:
parent
fc4063516d
commit
1cb5f05ba4
@ -5,8 +5,7 @@ using Hi.Mech.Topo;
|
||||
namespace Sample.Geom
|
||||
{
|
||||
/// <remarks>
|
||||
/// ## Source Code
|
||||
///
|
||||
/// ### Source Code
|
||||
/// [!code-csharp[SampleCode](~/../Hi.Sample/Geom/DemoBuildGeom.cs)]
|
||||
/// </remarks>
|
||||
public static class DemoBuildGeom
|
||||
|
24
Geom/DemoIExpandToBox3d.cs
Normal file
24
Geom/DemoIExpandToBox3d.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using Hi.Geom;
|
||||
using System;
|
||||
|
||||
namespace Sample.Geom
|
||||
{
|
||||
/// <remarks>
|
||||
/// ### Source Code
|
||||
/// [!code-csharp[SampleCode](~/../Hi.Sample/Geom/DemoIExpandToBox3d.cs)]
|
||||
/// </remarks>
|
||||
public static class DemoIExpandToBox3d
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
#region DocSite.CountBoundingBox
|
||||
Box3d objA = new Box3d(0, 0, 0, 1, 1, 1);
|
||||
Box3d objB = new Box3d(-1, -2, -3, 3, 2, 1);
|
||||
Vec3d objC = new Vec3d(-2, 3, -5);
|
||||
|
||||
Box3d boundingbox = new Box3d(objA, objB, objC);
|
||||
Console.WriteLine("boundingbox: " + boundingbox);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
30
HelloHiAPI.cs
Normal file
30
HelloHiAPI.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using Hi.Disp;
|
||||
using Hi.Licenses;
|
||||
using Hi.MongoUtils;
|
||||
using System;
|
||||
|
||||
namespace Sample
|
||||
{
|
||||
public static class HelloHiAPI
|
||||
{
|
||||
static int Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("HiAPI starting.");
|
||||
License.LogInAll();
|
||||
DispEngine.Init();
|
||||
MongoServer.Default = MongoServer.Run(new MongoRunnerOptions()
|
||||
{
|
||||
MongoPort = 28100
|
||||
});
|
||||
|
||||
Console.WriteLine("Hello World! HiAPI.");
|
||||
|
||||
MongoServer.Default.Dispose();
|
||||
DispEngine.FinishDisp();
|
||||
License.LogOutAll();
|
||||
Console.WriteLine("HiAPI exited.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@
|
||||
<Description>
|
||||
HiAPI samples.
|
||||
</Description>
|
||||
<Configurations>Demo;Maintenance</Configurations>
|
||||
<Configurations>Debug;Release</Configurations>
|
||||
<VersionBuild>0</VersionBuild>
|
||||
<VersionPrefix>1.4.$(VersionBuild)</VersionPrefix>
|
||||
<Product>$(AssemblyName)</Product>
|
||||
@ -18,9 +18,11 @@
|
||||
<Company>Tech Coordinate Co., Ltd.</Company>
|
||||
<Authors>Tech Coordinate Co., Ltd.</Authors>
|
||||
<OutputPath>bin\$(Platform).$(Configuration)\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<StartupObject>Sample.Mech.DemoTopo1</StartupObject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(Configuration)'=='Maintenance'">
|
||||
<ItemGroup Condition="'$(Configuration)'=='Debug'">
|
||||
<ProjectReference Include="..\HiLicense\HiLicense.csproj" />
|
||||
<ProjectReference Include="..\HiGeom\HiGeom.csproj" />
|
||||
<ProjectReference Include="..\HiDisp\HiDisp.csproj" />
|
||||
@ -29,14 +31,8 @@
|
||||
<ProjectReference Include="..\HiUniNc\HiUniNc.csproj" />
|
||||
<ProjectReference Include="..\HiNc\HiNc.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(Configuration)'=='Demo'">
|
||||
<ItemGroup Condition="'$(Configuration)'=='Release'">
|
||||
<PackageReference Include="HiNc" Version="1.4.*" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<StartupObject>Sample.Machining.DemoUseMachiningProject</StartupObject>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
</Project>
|
@ -18,8 +18,7 @@ namespace Sample.MachineTool
|
||||
/// Provides access to the PMC-B1 machine tool model.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// ## Source Code
|
||||
///
|
||||
/// ### Source Code
|
||||
/// [!code-csharp[SampleCode](~/../Hi.Sample/MachineTool/DemoBuildMachineTool.cs)]
|
||||
/// </remarks>
|
||||
public class DemoBuildMachineTool : IGetCodeXyzabcMachineTool
|
||||
|
@ -9,8 +9,7 @@ namespace Sample.MachineTool
|
||||
/// Demo Build Machine Tool without gemetries setting.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// ## Source Code
|
||||
///
|
||||
/// ### Source Code
|
||||
/// [!code-csharp[SampleCode](~/../Hi.Sample/MachineTool/DemoBuildMachineToolWithoutGeometrys.cs)]
|
||||
/// </remarks>
|
||||
public static class DemoBuildMachineToolWithoutGeometrys
|
||||
@ -27,17 +26,5 @@ namespace Sample.MachineTool
|
||||
CodeXyzabcMachineTool xyzabcMachineTool = new CodeXyzabcMachineTool(chain);
|
||||
return xyzabcMachineTool;
|
||||
}
|
||||
/// <summary>
|
||||
/// Generates and saves an empty machine tool URI to a file.
|
||||
/// </summary>
|
||||
/// <param name="baseDirectory">The base directory to save the machine tool file.</param>
|
||||
/// <returns>The machine tool URI object that was created and saved.</returns>
|
||||
public static CodeXyzabcMachineToolUri GenEmptyMachineToolUri(string baseDirectory)
|
||||
{
|
||||
CodeXyzabcMachineToolUri machineToolUri = new CodeXyzabcMachineToolUri(@"Samples/EmpytMachineTool.mt",
|
||||
GenEmptyMachineTool());
|
||||
machineToolUri.SaveToUri(baseDirectory);
|
||||
return machineToolUri;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,12 +22,13 @@ using System.IO;
|
||||
|
||||
namespace Sample.Machining
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// This example demonstrates how to create a complete machining project from scratch using HiAPI. It shows the step-by-step process of building all necessary components, including defining custom milling cutters with specific parameters (helix angle, rake angle, etc.), configuring tool holders, setting up a machining tool house with multiple tools, defining the fixture and workpiece geometry, and configuring the machine chain. The sample also demonstrates how to set workpiece material properties and generate the final project XML file. This example is particularly valuable for developers who need to programmatically create complete machining projects without using the HiNC GUI.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// ### Source Code
|
||||
///
|
||||
/// [!code-csharp[SampleCode](~/../Hi.Sample/Machining/DemoBuildMachiningProject.cs)]
|
||||
/// </remarks>
|
||||
public static class DemoBuildMachiningProject
|
||||
|
@ -12,7 +12,6 @@ namespace Sample.Machining
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// ### Source Code
|
||||
///
|
||||
/// [!code-csharp[SampleCode](~/../Hi.Sample/Machining/DemoUseMachiningProject.cs)]
|
||||
/// </remarks>
|
||||
public static class DemoUseMachiningProject
|
||||
|
81
Mech/DemoTopo1.cs
Normal file
81
Mech/DemoTopo1.cs
Normal file
@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Hi.Disp;
|
||||
using Hi.Geom;
|
||||
using Hi.Mech.Topo;
|
||||
|
||||
namespace Sample.Mech
|
||||
{
|
||||
public class Test : IDisplayee
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void Display(Bind bind)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
/// <inheritdoc/>
|
||||
public void ExpandToBox3d(Box3d dst)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// ### Source Code
|
||||
/// [!code-csharp[SampleCode](~/../Hi.Sample/Mech/DemoTopo1.cs)]
|
||||
/// </remarks>
|
||||
public static class DemoTopo1
|
||||
{
|
||||
public static (Asmb asmb,Anchor root) GetDemoAsmb()
|
||||
{
|
||||
#region DocSite.DemoTopo1
|
||||
//build coordinate systems and the assembly.
|
||||
Asmb asmb = new Asmb { Name = "Mech" };
|
||||
Anchor O = new Anchor(asmb, "O");
|
||||
Anchor O1 = new Anchor(asmb, "O1");
|
||||
Anchor X = new Anchor(asmb, "X");
|
||||
Anchor Z = new Anchor(asmb, "Z");
|
||||
Anchor B = new Anchor(asmb, "B");
|
||||
|
||||
//build kinematic link
|
||||
Branch.Attach(O, O1, new StaticTranslation(new Vec3d(0, 0, 80)));
|
||||
Branch brnX = Branch.Attach(O1, X, new DynamicTranslation(new Vec3d(1, 0, 0)));
|
||||
Branch brnZ = Branch.Attach(X, Z, new DynamicTranslation(new Vec3d(0, 0, 1)));
|
||||
Branch brnB = Branch.Attach(Z, B, new DynamicRotation(new Vec3d(0, 1, 0), 0, new Vec3d(-100, 0, 0)));
|
||||
|
||||
//drive the dynamic transformation by single value for each branch.
|
||||
brnX.Step = 200;
|
||||
brnZ.Step = 100;
|
||||
brnB.Step = MathUtil.ToRad(-60);
|
||||
|
||||
//Get and show the transform matrices relative to O.
|
||||
Dictionary<Anchor, Mat4d> matMap = asmb.GetMat4dMap(O);
|
||||
Console.WriteLine("Transform Matrix relative to O:");
|
||||
foreach (KeyValuePair<Anchor, Mat4d> keyValue in matMap)
|
||||
Console.WriteLine($"{keyValue.Key.Name} : {keyValue.Value}");
|
||||
#endregion
|
||||
|
||||
return (asmb,O);
|
||||
}
|
||||
public static void SnapshotToFile((Asmb asmb, Anchor root) src)
|
||||
{
|
||||
//all the drawing function has to call DispEngine.Init() before using.
|
||||
DispEngine.Init();
|
||||
DispEngine.EnableSuppressDefaultLogo = true;
|
||||
|
||||
using (DispEngine dispEngine = new DispEngine(
|
||||
src.asmb.GetAsmbDraw(src.root)))
|
||||
{
|
||||
dispEngine.SetViewToIsometricView();
|
||||
dispEngine.Snapshot("DemoTopo1.bmp", 680, 480);
|
||||
}
|
||||
Console.WriteLine("Snapshot file output.");
|
||||
|
||||
DispEngine.FinishDisp();
|
||||
}
|
||||
static void Main()
|
||||
{
|
||||
SnapshotToFile(GetDemoAsmb());
|
||||
}
|
||||
}
|
||||
}
|
@ -6,7 +6,8 @@
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "https://localhost:52376;http://localhost:52377"
|
||||
"applicationUrl": "https://localhost:52376;http://localhost:52377",
|
||||
"nativeDebugging": true
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user