创建注释

 1 static void aa()
 2 {
 3     NXOpen::Session* theSession = NXOpen::Session::GetSession();
 4     NXOpen::Part* workPart(theSession->Parts()->Work());
 5     NXOpen::Part* displayPart(theSession->Parts()->Display());
 6     NXOpen::ModelingView* modelingView1(dynamic_cast<NXOpen::ModelingView*>(workPart->ModelingViews()->FindObject("Trimetric")));
 7     NXOpen::Matrix3x3 matrix1;
 8     matrix1.Xx = 1.0;
 9     matrix1.Xy = 0.0;
10     matrix1.Xz = 0.0;
11     matrix1.Yx = 0.0;
12     matrix1.Yy = 1.0;
13     matrix1.Yz = 0.0;
14     matrix1.Zx = 0.0;
15     matrix1.Zy = 0.0;
16     matrix1.Zz = 1.0;
17     modelingView1->Orient(matrix1);
18     // ----------------------------------------------
19     //   Menu: 插入(S)->注释(A)->注释(N)...
20     // ----------------------------------------------
21     NXOpen::Annotations::SimpleDraftingAid* nullNXOpen_Annotations_SimpleDraftingAid(NULL);
22     NXOpen::Annotations::DraftingNoteBuilder* draftingNoteBuilder1;
23     draftingNoteBuilder1 = workPart->Annotations()->CreateDraftingNoteBuilder(nullNXOpen_Annotations_SimpleDraftingAid);
24     draftingNoteBuilder1->Origin()->SetInferRelativeToGeometry(true);
25     draftingNoteBuilder1->Origin()->SetAnchor(NXOpen::Annotations::OriginBuilder::AlignmentPositionMidCenter);
26     std::vector<NXOpen::NXString> text1(1);
27     text1[0] = "a";
28     draftingNoteBuilder1->Text()->TextBlock()->SetText(text1);
29     draftingNoteBuilder1->Origin()->Plane()->SetPlaneMethod(NXOpen::Annotations::PlaneBuilder::PlaneMethodTypeXyPlane);
30     draftingNoteBuilder1->Origin()->SetInferRelativeToGeometry(true);
31     NXOpen::Annotations::LeaderData* leaderData1;
32     leaderData1 = workPart->Annotations()->CreateLeaderData();
33     leaderData1->SetArrowhead(NXOpen::Annotations::LeaderData::ArrowheadTypeFilledArrow);
34     leaderData1->SetVerticalAttachment(NXOpen::Annotations::LeaderVerticalAttachmentCenter);
35     draftingNoteBuilder1->Leader()->Leaders()->Append(leaderData1);
36     leaderData1->SetArrowhead(NXOpen::Annotations::LeaderData::ArrowheadTypeClosedArrow);
37     leaderData1->SetStubSide(NXOpen::Annotations::LeaderSideInferred);
38     leaderData1->SetStubSize(6.3499999999999996);
39     double symbolscale1;
40     symbolscale1 = draftingNoteBuilder1->Text()->TextBlock()->SymbolScale();
41     double symbolaspectratio1;
42     symbolaspectratio1 = draftingNoteBuilder1->Text()->TextBlock()->SymbolAspectRatio();
43     draftingNoteBuilder1->Origin()->SetInferRelativeToGeometry(true);
44     // ----------------------------------------------
45     //   Dialog Begin 注释设置
46     // ----------------------------------------------
47     int fontIndex1;
48     fontIndex1 = workPart->Fonts()->AddFont("hershey-sans", NXOpen::FontCollection::TypeNx);
49     draftingNoteBuilder1->Style()->LetteringStyle()->SetGeneralTextFont(9);
50     int fontIndex2;
51     fontIndex2 = workPart->Fonts()->AddFont("hershey-sans", NXOpen::FontCollection::TypeNx);
52     draftingNoteBuilder1->Style()->LetteringStyle()->SetGeneralTextLineWidth(NXOpen::Annotations::LineWidthThick);
53     draftingNoteBuilder1->Style()->LetteringStyle()->SetGeneralTextSize(3.0);
54     draftingNoteBuilder1->Style()->LetteringStyle()->SetGeneralTextCharSpaceFactor(0.1);
55     draftingNoteBuilder1->Style()->LetteringStyle()->SetGeneralTextAspectRatio(0.6);
56     NXOpen::Annotations::Annotation::AssociativeOriginData assocOrigin1;
57     assocOrigin1.OriginType = NXOpen::Annotations::AssociativeOriginTypeDrag;
58     NXOpen::View* nullNXOpen_View(NULL);
59     assocOrigin1.View = nullNXOpen_View;
60     assocOrigin1.ViewOfGeometry = nullNXOpen_View;
61     NXOpen::Point* nullNXOpen_Point(NULL);
62     assocOrigin1.PointOnGeometry = nullNXOpen_Point;
63     NXOpen::Annotations::Annotation* nullNXOpen_Annotations_Annotation(NULL);
64     assocOrigin1.VertAnnotation = nullNXOpen_Annotations_Annotation;
65     assocOrigin1.VertAlignmentPosition = NXOpen::Annotations::AlignmentPositionTopLeft;
66     assocOrigin1.HorizAnnotation = nullNXOpen_Annotations_Annotation;
67     assocOrigin1.HorizAlignmentPosition = NXOpen::Annotations::AlignmentPositionTopLeft;
68     assocOrigin1.AlignedAnnotation = nullNXOpen_Annotations_Annotation;
69     assocOrigin1.DimensionLine = 0;
70     assocOrigin1.AssociatedView = nullNXOpen_View;
71     assocOrigin1.AssociatedPoint = nullNXOpen_Point;
72     assocOrigin1.OffsetAnnotation = nullNXOpen_Annotations_Annotation;
73     assocOrigin1.OffsetAlignmentPosition = NXOpen::Annotations::AlignmentPositionTopLeft;
74     assocOrigin1.XOffsetFactor = 0.0;
75     assocOrigin1.YOffsetFactor = 0.0;
76     assocOrigin1.StackAlignmentPosition = NXOpen::Annotations::StackAlignmentPositionAbove;
77     draftingNoteBuilder1->Origin()->SetAssociativeOrigin(assocOrigin1);
78     NXOpen::Point3d point1(0.0, 0.0, 0.0);
79     draftingNoteBuilder1->Origin()->Origin()->SetValue(NULL, nullNXOpen_View, point1);
80     draftingNoteBuilder1->Origin()->SetInferRelativeToGeometry(true);
81     NXOpen::NXObject* nXObject1;
82     nXObject1 = draftingNoteBuilder1->Commit();
83     draftingNoteBuilder1->Destroy();
84 }

 

posted @ 2020-08-27 17:42  老婆饼里有老婆  阅读(315)  评论(3编辑  收藏  举报