本文整理汇总了C#中Inventor类的典型用法代码示例。如果您正苦于以下问题:C# Inventor类的具体用法?C# Inventor怎么用?C# Inventor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Inventor类属于命名空间,在下文中一共展示了Inventor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CSimpleInteraction
public CSimpleInteraction(Inventor.Application oApplication)
{
mApplication = oApplication;
//Initialize events
mInteractionEvents = mApplication.CommandManager.CreateInteractionEvents();
mSelectEvents = mInteractionEvents.SelectEvents;
//Set event handler VB.Net Style
mSelectEvents.OnSelect += new Inventor.SelectEventsSink_OnSelectEventHandler(this.mSelectEvents_OnSelect);
mInteractionEvents.OnTerminate += new Inventor.InteractionEventsSink_OnTerminateEventHandler(this.mInteractionEvents_OnTerminate);
//Clear filter and set new ones if needed
mSelectEvents.ClearSelectionFilter();
//Always Disable mouse move if not needed for performances
mSelectEvents.MouseMoveEnabled = false;
mSelectEvents.Enabled = true;
mSelectEvents.SingleSelectEnabled = true;
//Remember to Start/Stop the interaction event
mInteractionEvents.Start();
}
示例2: CreateExtrudeFeature
public void CreateExtrudeFeature(Inventor.Application ThisApplication)
{
PartDocument partDoc;
partDoc = (PartDocument)ThisApplication.Documents.Add(DocumentTypeEnum.kPartDocumentObject,
ThisApplication.GetTemplateFile(DocumentTypeEnum.kPartDocumentObject, SystemOfMeasureEnum.kDefaultSystemOfMeasure, DraftingStandardEnum.kGB_DraftingStandard, null), true);
PlanarSketch sketch;
sketch = partDoc.ComponentDefinition.Sketches.Add(partDoc.ComponentDefinition.WorkPlanes[3], false);
TransientGeometry transGeom;
transGeom = ThisApplication.TransientGeometry;
SketchPoints skPnts;
skPnts = sketch.SketchPoints;
skPnts.Add(transGeom.CreatePoint2d(0, 0), false);
skPnts.Add(transGeom.CreatePoint2d(1, 0), false);
skPnts.Add(transGeom.CreatePoint2d(1, 1), false);
SketchLines lines;
lines = sketch.SketchLines;
System.Array Line = System.Array.CreateInstance(typeof(SketchLine), 3);
SketchLine[] line = Line as SketchLine[];
line[0] = lines.AddByTwoPoints(skPnts[1], skPnts[2]);
line[1] = lines.AddByTwoPoints(skPnts[2], skPnts[3]);
line[2] = lines.AddByTwoPoints(skPnts[3], skPnts[1]);
Profile profile;
profile = sketch.Profiles.AddForSolid(true, null, null);
ExtrudeFeature extFeature;
extFeature = partDoc.ComponentDefinition.Features.ExtrudeFeatures.AddByDistanceExtent(
profile,1.0, PartFeatureExtentDirectionEnum.kPositiveExtentDirection,PartFeatureOperationEnum.kJoinOperation,null);
ThisApplication.ActiveView.Fit(true);
}
示例3: ContextNarrowing
public void ContextNarrowing()
{
Inventor context = new Inventor("Nikola Tesla", new DateTime(1856, 7, 9), "Serbian");
ConditionValidator cv1 = new ConditionValidator("DOB.Year == 1856", null);
ConditionValidator cv2 = new ConditionValidator("Year == 1856", null);
StaticListableObjectFactory factory = new StaticListableObjectFactory();
factory.AddObject("cv1", cv1);
factory.AddObject("cv2", cv2);
ValidatorReference v1 = new ValidatorReference();
v1.ObjectFactory = factory;
v1.Name = "cv1";
IValidationErrors errors = new ValidationErrors();
Assert.IsTrue(v1.Validate(context, null, errors));
Assert.IsTrue(v1.Validate(context, errors));
ValidatorReference v2 = new ValidatorReference();
v2.ObjectFactory = factory;
v2.Name = "cv2";
v2.Context = Expression.Parse("DOB");
Assert.IsTrue(v2.Validate(context, null, errors));
Assert.IsTrue(v2.Validate(context, errors));
ValidatorReference v3 = new ValidatorReference("false");
v3.ObjectFactory = factory;
v3.Name = "cv2";
v3.Context = Expression.Parse("DOB");
Assert.IsTrue(v3.Validate(null, errors));
}
示例4: CreateDrawing
public void CreateDrawing(Inventor.Application ThisApplication)
{
DrawingDocument drawingDoc;
drawingDoc = (DrawingDocument)ThisApplication.ActiveDocument;
Sheet sheet;
sheet = drawingDoc.Sheets[1];
Point2d point1;
point1 = ThisApplication.TransientGeometry.CreatePoint2d(5, 5);
_Document partDoc;
partDoc = ThisApplication.Documents.Open("c:\\testpart.ipt", false);
DrawingView view1;
view1 = sheet.DrawingViews.AddBaseView(partDoc, point1, 1, ViewOrientationTypeEnum.kBottomViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle, "", null, null);
partDoc.Close(true);
Point2d point2;
point2 = ThisApplication.TransientGeometry.CreatePoint2d(15, 40);
DrawingSketch drawingSketch;
drawingSketch = sheet.Sketches.Add();
drawingSketch.Edit();
SketchLine sketchLine;
sketchLine = drawingSketch.SketchLines.AddByTwoPoints(point1, point2);
drawingSketch.ExitEdit();
SectionDrawingView view2;
view2 = sheet.DrawingViews.AddSectionView(view1, drawingSketch, point2, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle,
1, true, "", false, true, null);
drawingSketch.Visible = false;
}
示例5: ChangeBalloons
public void ChangeBalloons(Inventor.Application ThisApplication)
{
DrawingDocument drawDoc;
drawDoc = (DrawingDocument)ThisApplication.ActiveDocument;
Sheet sheet;
sheet = drawDoc.ActiveSheet;
long balloonCount;
balloonCount = 1;
foreach(Balloon balloon in sheet.Balloons)
{
balloon.SetBalloonType(BalloonTypeEnum.kHexagonBalloonType, null);
balloon.PlacementDirection = BalloonDirectionEnum.kBottomDirection;
long valueSetCount;
valueSetCount = 1;
foreach(BalloonValueSet balloonValueSet in balloon.BalloonValueSets)
{
balloonValueSet.OverrideValue = string.Format("Balloon {0} : ValueSet {1}", balloonCount, valueSetCount);
valueSetCount = valueSetCount + 1;
}
balloonCount = balloonCount + 1;
}
}
示例6: WithoutTypeConversion
public void WithoutTypeConversion()
{
Hashtable source = new Hashtable();
Inventor target = new Inventor();
source["name"] = "Nikola Tesla";
source["dob"] = new DateTime(1856, 7, 9);
// I know this is pupin's graduation year but I need a date here
source["dateofgraduation"] = new DateTime(1883,1,1);
source["inventions"] = new string[] {"One", "Two"};
mgr.BindSourceToTarget(source, target, null);
Assert.IsTrue(mgr.HasBindings);
Assert.AreEqual("Nikola Tesla", target.Name);
Assert.AreEqual(new DateTime(1856, 7, 9), target.DOB);
Assert.AreEqual(new string[] {"One", "Two"}, target.Inventions);
Assert.IsNull(target.PlaceOfBirth.City);
Assert.IsNull(target.PlaceOfBirth.Country);
target.Name = "Tesla, Nikola";
target.DOB = DateTime.Today;
target.PlaceOfBirth.City = "Smiljan";
target.PlaceOfBirth.Country = "Lika";
mgr.BindTargetToSource(source, target, null);
Assert.AreEqual("Tesla, Nikola", source["name"]);
Assert.AreEqual(DateTime.Today, source["dob"]);
Assert.AreEqual("One", ((string[]) source["inventions"])[0]);
Assert.AreEqual("Smiljan", source["cityOfBirth"]);
Assert.AreEqual("Lika", source["countryOfBirth"]);
}
示例7: ShowSurfaceArea
public void ShowSurfaceArea(Inventor.Application ThisApplication)
{
//���õ������ĵ���ѡ������
SelectSet selectSet;
selectSet = ThisApplication.ActiveDocument.SelectSet;
//ȷ��ֻѡ����һ��ͼԪ
if(selectSet.Count == 1)
{
//ȷ��ѡ����һ������
if (selectSet[1].GetType() is Face == false)
{
//���õ���ѡ���������
Face face;
face = (Face)selectSet[1];
//��ʾ��ѡ��������
MessageBox.Show(string.Format("Surface area: {0} cm^2", face.Evaluator.Area));
}
else
{
MessageBox.Show("You must select a single face.");
}
}
else
{
MessageBox.Show("You must select a single face.");
}
}
示例8: Form1
public Form1(Inventor.Application oApp)
{
// This call is required by the Windows Form Designer.
InitializeComponent();
// Add any initialization after the InitializeComponent() call.
_macros = new Macros(oApp);
MemberInfo[] methods = _macros.GetType().GetMembers();
foreach (MemberInfo member in methods)
{
if (member.DeclaringType.Name == "Macros" && member.MemberType == MemberTypes.Method)
{
ComboBoxMacros.Items.Add(member.Name);
}
}
if (ComboBoxMacros.Items.Count > 0)
{
ComboBoxMacros.SelectedIndex = 0;
Button1.Enabled = true;
}
}
示例9: CreateRevolveFeature
public void CreateRevolveFeature(Inventor.Application ThisApplication)
{
PartDocument partDoc;
partDoc = (PartDocument)ThisApplication.Documents.Add(DocumentTypeEnum.kPartDocumentObject,
ThisApplication.GetTemplateFile(DocumentTypeEnum.kPartDocumentObject, SystemOfMeasureEnum.kDefaultSystemOfMeasure, DraftingStandardEnum.kGB_DraftingStandard, null), true);
PlanarSketch sketch;
sketch = partDoc.ComponentDefinition.Sketches.Add(partDoc.ComponentDefinition.WorkPlanes[3], false);
TransientGeometry transGeom;
transGeom = ThisApplication.TransientGeometry;
SketchPoints skPnts;
skPnts = sketch.SketchPoints;
skPnts.Add(transGeom.CreatePoint2d(0, 0), false);
skPnts.Add(transGeom.CreatePoint2d(1, 0), false);
skPnts.Add(transGeom.CreatePoint2d(1, 1), false);
SketchLines lines;
lines = sketch.SketchLines;
SketchLine line;
line = lines.AddByTwoPoints(skPnts[1], skPnts[2]);
SketchCircles circs;
circs = sketch.SketchCircles;
SketchCircle circ;
circ = circs.AddByCenterRadius(skPnts[3], 0.5);
Profile profile;
profile = sketch.Profiles.AddForSolid(true, null, null);
RevolveFeature revFeature;
revFeature = partDoc.ComponentDefinition.Features.RevolveFeatures.AddFull(profile, line, PartFeatureOperationEnum.kJoinOperation);
ThisApplication.ActiveView.Fit(true);
}
示例10: QubeItToolsChangeProcessor
public QubeItToolsChangeProcessor(Inventor.Application inventorApplication, IChangeProcessorParent parentClass, string internalName,
string commandName, string clientID)
{
_inventorApplication = inventorApplication;
_parentClass = parentClass;
_clientID = clientID;
_changeDefInternalName = internalName;
_changeDefCommandName = commandName;
}
示例11: Form1
public Form1(Inventor.Application oApplication)
{
// This call is required by the Windows Form Designer.
InitializeComponent();
// Add any initialization after the InitializeComponent() call.
mApplication = oApplication;
}
示例12: CreateSketchWithCons
public void CreateSketchWithCons(Inventor.Application ThisApplication)
{
PartDocument partDoc;
partDoc = (PartDocument)ThisApplication.Documents.Add(DocumentTypeEnum.kPartDocumentObject,
ThisApplication.GetTemplateFile(DocumentTypeEnum.kPartDocumentObject, SystemOfMeasureEnum.kDefaultSystemOfMeasure, DraftingStandardEnum.kGB_DraftingStandard, null),true);
PlanarSketch sketch;
sketch = partDoc.ComponentDefinition.Sketches.Add(partDoc.ComponentDefinition.WorkPlanes[3], false);
TransientGeometry transGeom;
transGeom = ThisApplication.TransientGeometry;
SketchPoints skPnts;
skPnts = sketch.SketchPoints;
skPnts.Add(transGeom.CreatePoint2d(0, 0), false);
skPnts.Add(transGeom.CreatePoint2d(1.0, 0), false);
skPnts.Add(transGeom.CreatePoint2d(1.0, 0.5), false);
skPnts.Add(transGeom.CreatePoint2d(2.2, 0.5), false);
skPnts.Add(transGeom.CreatePoint2d(0.5, 1.5), false);
skPnts.Add(transGeom.CreatePoint2d(0, 1.0), false);
skPnts.Add(transGeom.CreatePoint2d(2.7, 1.5), false);
skPnts.Add(transGeom.CreatePoint2d(0.5, 1.0), false);
SketchLines lines;
lines = sketch.SketchLines;
System.Array Line = System.Array.CreateInstance(typeof(SketchLine), 6);
SketchLine[] line = Line as SketchLine[];
line[0] = lines.AddByTwoPoints(skPnts[1], skPnts[2]);
line[1] = lines.AddByTwoPoints(skPnts[2], skPnts[3]);
line[2] = lines.AddByTwoPoints(skPnts[3], skPnts[4]);
line[3] = lines.AddByTwoPoints(skPnts[4], skPnts[7]);
line[4] = lines.AddByTwoPoints(skPnts[7], skPnts[5]);
line[5] = lines.AddByTwoPoints(skPnts[6], skPnts[1]);
SketchArcs arcs;
arcs = sketch.SketchArcs;
SketchArc arc;
arc = arcs.AddByCenterStartEndPoint(skPnts[8], skPnts[5], skPnts[6], true);
sketch.GeometricConstraints.AddPerpendicular((SketchEntity)line[3], (SketchEntity)line[4], true, true);
ThisApplication.ActiveView.Update();
sketch.GeometricConstraints.AddTangent((SketchEntity)line[4], (SketchEntity)arc, null);
sketch.GeometricConstraints.AddTangent((SketchEntity)line[5], (SketchEntity)arc, null);
ThisApplication.ActiveView.Update();
sketch.GeometricConstraints.AddParallel((SketchEntity)line[2], (SketchEntity)line[4], true, true);
ThisApplication.ActiveView.Update();
sketch.GeometricConstraints.AddHorizontal((SketchEntity)line[4], true);
ThisApplication.ActiveView.Update();
}
示例13: Activate
public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
{
m_inventorApplication = addInSiteObject.Application;
m_ApplicationEvents = m_inventorApplication.ApplicationEvents;
m_ApplicationEvents.OnOpenDocument += this.m_ApplicationEvents_OnOpenDocument;
mControlForm = new Form1(m_inventorApplication);
mControlForm.ShowModeless();
}
示例14: WhenInvalid
public void WhenInvalid()
{
Inventor context = new Inventor("Nikola Tesla", new DateTime(1856, 7, 9), "Serbian");
IValidationErrors errors = new ValidationErrors();
ErrorMessageAction action = new ErrorMessageAction("{0}, {1}", "errors");
action.Parameters = new IExpression[] {Expression.Parse("Name"), Expression.Parse("Nationality")};
action.Execute(false, context, null, errors);
Assert.IsFalse(errors.IsEmpty);
Assert.AreEqual(1, errors.GetErrors("errors").Count);
Assert.AreEqual(context.Name + ", " + context.Nationality, errors.GetResolvedErrors("errors", new NullMessageSource())[0]);
}
示例15: Activate
public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
{
// This method is called by Inventor when it loads the addin.
// The AddInSiteObject provides access to the Inventor Application object.
// The FirstTime flag indicates if the addin is loaded for the first time.
// Initialize AddIn members.
m_inventorApplication = addInSiteObject.Application;
// TODO: Add ApplicationAddInServer.Activate implementation.
// e.g. event initialization, command creation etc.
System.Windows.Forms.MessageBox.Show("I am loaded!!", "Hello World AddIn");
}