forked from frankfralick/DynamoInventor
/
InvWorkPoint.cs
135 lines (113 loc) · 4.01 KB
/
InvWorkPoint.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using Inventor;
using Autodesk.DesignScript.Geometry;
using Autodesk.DesignScript.Interfaces;
using DSNodeServices;
using Dynamo.Models;
using Dynamo.Utilities;
using DSInventorNodes.GeometryConversion;
using InventorServices.Persistence;
using Point = Autodesk.DesignScript.Geometry.Point;
namespace DSInventorNodes.GeometryObjects
{
[RegisterForTrace]
[ShortName("workPt")]
public class InvWorkPoint : AbstractGeometryObject
{
#region Internal properties
internal WorkPoint InternalWorkPoint { get; private set; }
//public override ComponentOccurrence InternalOccurrence
//{
// get { return InternalWorkPoint.; }
//}
#endregion
#region Private constructors
private InvWorkPoint(Inventor.WorkPoint workPt)
{
InternalWorkPoint = workPt;
}
private InvWorkPoint(double x, double y, double z)
{
//this.VerifyContextSettings();
AssemblyDocument assDoc = InventorPersistenceManager.ActiveAssemblyDoc;
AssemblyComponentDefinition compDef = (AssemblyComponentDefinition)assDoc.ComponentDefinition;
Inventor.Point point = InventorPersistenceManager.InventorApplication.TransientGeometry.CreatePoint(x, y, z);
Inventor.WorkPoint wp = compDef.WorkPoints.AddFixed(point, false);
byte[] refKey = new byte[] { };
//wp.GetReferenceKey(ref refKey, (int)InventorSettings.KeyContext);
//wp.GetReferenceKey(ref refKey, (int)ReferenceManager.KeyContext);
//ComponentOccurrenceKeys.Add(refKey);
//return wp;
InternalSetWorkPoint(wp);
}
#endregion
#region Private mutators
private void InternalSetPosition(double x, double y, double z)
{
Inventor.Point newLocation = InventorPersistenceManager.InventorApplication.TransientGeometry.CreatePoint(x, y, z);
AssemblyWorkPointDef wpDef = (AssemblyWorkPointDef)InternalWorkPoint.Definition;
wpDef.Point = newLocation;
}
private void InternalSetWorkPoint(Inventor.WorkPoint p)
{
InternalWorkPoint = p;
}
#endregion
#region Public properties
public double X
{
get { return InternalWorkPoint.Point.X; }
set { InternalSetPosition(value, Y, Z); }
}
public double Y
{
get { return InternalWorkPoint.Point.Y; }
set { InternalSetPosition(X, value, Z); }
}
public double Z
{
get { return InternalWorkPoint.Point.Z; }
set { InternalSetPosition(X, Y, value); }
}
public Point Point
{
get
{
return InternalWorkPoint.Point.ToPoint();
}
}
#endregion
#region Public static constructors
public static InvWorkPoint ByCoordinates(double x, double y, double z)
{
return new InvWorkPoint(x, y, z);
}
public static InvWorkPoint ByPoint(Point pt)
{
if (pt == null)
{
throw new ArgumentNullException("pt");
}
return new InvWorkPoint(pt.X, pt.Y, pt.Z);
}
#endregion
#region Internal static constructors
internal static InvWorkPoint FromExisting(Inventor.WorkPoint pt)
{
return new InvWorkPoint(pt);
}
#endregion
#region Tesselation
#endregion
//private static void MoveWorkPoint(double x, double y, double z, Inventor.WorkPoint wp)
//{
// Inventor.Point newLocation = DocumentManager.InventorApplication.TransientGeometry.CreatePoint(x, y, z);
// AssemblyWorkPointDef wpDef = (AssemblyWorkPointDef)wp.Definition;
// wpDef.Point = newLocation;
//}
}
}