-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
1,153 additions
and
1,032 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
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
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
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,82 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using NXOpen.UserDefinedObjects; | ||
using static NXOpen.Extensions.Globals; | ||
using NXOpen.Extensions; | ||
using NXOpen; | ||
|
||
namespace RhinoInside.NX.Core | ||
{ | ||
public class GH_UserDefinedObject | ||
{ | ||
static UserDefinedClass GHFeatureClass; | ||
|
||
static GH_UserDefinedObject() | ||
{ | ||
try | ||
{ | ||
Console.WriteLine("注册"); | ||
|
||
// Define your custom UDO class | ||
GHFeatureClass = TheSession.UserDefinedClassManager.CreateUserDefinedObjectClass | ||
("GHFeature", "Object Created From Grasshopper"); | ||
// Setup properties on the custom UDO class | ||
GHFeatureClass.AllowQueryClassFromName = UserDefinedClass.AllowQueryClass.On; | ||
// Register callbacks for the UDO class | ||
// GHFeature.AddDisplayHandler(new UserDefinedClass.DisplayCallback(Program.myDisplayCB)); | ||
// GHFeature.AddAttentionPointHandler(new UserDefinedClass.DisplayCallback(Program.myDisplayCB)); | ||
// GHFeature.AddFitHandler(new UserDefinedClass.DisplayCallback | ||
//(Program.myDisplayCB)); | ||
// GHFeature.AddSelectionHandler(new | ||
//UserDefinedClass.DisplayCallback(Program.myDisplayCB)); | ||
// GHFeature.AddEditHandler(new UserDefinedClass.GenericCallback(Program.myEditCB)); | ||
// GHFeature.AddInformationHandler(new | ||
//UserDefinedClass.GenericCallback(Program.myInfoCB)); | ||
// Add this class to the list of object types available for selection in NX. | ||
// If you skip this step you won't be able to select UDO's of this class, | ||
// even though you registered a selection callback. | ||
TheUI.SelectionManager.SetSelectionStatusOfUserDefinedClass(GHFeatureClass, true); | ||
} | ||
catch (NXOpen.NXException ex) | ||
{ | ||
// ---- Enter your exception handling code here ----- | ||
TheUI.NXMessageBox.Show("Caught exception", NXMessageBox.DialogType.Error, ex.Message); | ||
throw ex; | ||
} | ||
} | ||
|
||
public static UserDefinedObject CreateGHFeatureObject() | ||
{ | ||
var ghFeatureObj = WorkPart.UserDefinedObjectManager.CreateUserDefinedObject(GHFeatureClass); | ||
|
||
ghFeatureObj.Color = 36; | ||
|
||
View myView = null; | ||
Point3d myCursor; | ||
myCursor.X = 0; | ||
myCursor.Y = 0; | ||
myCursor.Z = 0; | ||
// ask the user to select an origin for this UDO | ||
Selection.DialogResponse myResponse = | ||
TheUI.SelectionManager.SelectScreenPosition("Select Origin of C# UDO", out myView, out myCursor); | ||
|
||
double[] myUDOdoubles = new double[3]; | ||
myUDOdoubles[0] = myCursor.X; | ||
myUDOdoubles[1] = myCursor.Y; | ||
myUDOdoubles[2] = myCursor.Z; | ||
ghFeatureObj.SetDoubles(myUDOdoubles); | ||
|
||
TheUfSession.Disp.AddItemToDisplay(ghFeatureObj.Tag); | ||
|
||
NXOpen.Features.UserDefinedObjectFeatureBuilder fb = WorkPart.Features.CreateUserDefinedObjectFeatureBuilder(null); | ||
fb.UserDefinedObject = ghFeatureObj; | ||
fb.Commit(); | ||
fb.Destroy(); | ||
|
||
return ghFeatureObj; | ||
} | ||
} | ||
} |
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
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
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
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
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 @@ | ||
using Grasshopper.Kernel; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace RhinoInside.NX.GH.TestComponents | ||
{ | ||
public abstract class TestComponent : GH_Component | ||
{ | ||
public override Guid ComponentGuid | ||
{ | ||
get { return Guid.NewGuid(); } | ||
} | ||
|
||
public TestComponent(string name) : base(name, name, name, "NX", "Test") | ||
{ | ||
|
||
} | ||
} | ||
} |
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,44 @@ | ||
using Grasshopper.Kernel; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using RhinoInside.NX.Core; | ||
|
||
namespace RhinoInside.NX.GH.TestComponents | ||
{ | ||
public class UDOTest : TestComponent | ||
{ | ||
public UDOTest() : base("UDO Test") | ||
{ | ||
|
||
} | ||
|
||
/// <summary> | ||
/// Registers all the input parameters for this component. | ||
/// </summary> | ||
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager) | ||
{ | ||
pManager.AddGenericParameter("Geometry", "G", "Geometry that want to Created In NX", GH_ParamAccess.item); | ||
} | ||
|
||
/// <summary> | ||
/// Registers all the output parameters for this component. | ||
/// </summary> | ||
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager) | ||
{ | ||
pManager.AddGenericParameter("NX Geonetry", "G", "Geometry Created In NX", GH_ParamAccess.item); | ||
} | ||
|
||
/// <summary> | ||
/// This is the method that actually does the work. | ||
/// </summary> | ||
/// <param name="DA">The DA object can be used to retrieve data from input parameters and | ||
/// to store data in output parameters.</param> | ||
protected override void SolveInstance(IGH_DataAccess DA) | ||
{ | ||
GH_UserDefinedObject.CreateGHFeatureObject(); | ||
} | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.