C++ 2010 NX8.5
Annotations::TableSection *nullAnnotations_TableSection(NULL);
Annotations::TableSectionBuilder *tableSectionBuilder1;
tableSectionBuilder1 = workPart->Annotations()->TableSections()->CreateTableSectionBuilder(nullAnnotations_TableSection);
tableSectionBuilder1->Origin()->Plane()->SetPlaneMethod(Annotations::PlaneBuilder::PlaneMethodTypeXyPlane);
tableSectionBuilder1->Origin()->SetInferRelativeToGeometry(true);
tableSectionBuilder1->SetNumberOfColumns(8);//设置列数
tableSectionBuilder1->SetNumberOfRows(5);//设置行数
tableSectionBuilder1->SetColumnWidth(20.0);//设置列宽
tableSectionBuilder1->SetRowHeight(7.0);//设置行高
tableSectionBuilder1->Style()->TableSectionStyle()->SetAlignmentPosition(Annotations::TableSectionStyleBuilder::AlignmentPositionTypeTopLeft);
tableSectionBuilder1->Origin()->Plane()->SetPlaneMethod(Annotations::PlaneBuilder::PlaneMethodTypeXyPlane);
tableSectionBuilder1->Origin()->SetInferRelativeToGeometry(true);
Annotations::LeaderData *leaderData1;
leaderData1 = workPart->Annotations()->CreateLeaderData();
leaderData1->SetStubSize(2.0);
tableSectionBuilder1->Leader()->Leaders()->Append(leaderData1);
leaderData1->SetStubSide(Annotations::LeaderSideInferred);
tableSectionBuilder1->Origin()->SetInferRelativeToGeometry(true);
tableSectionBuilder1->Origin()->SetInferRelativeToGeometry(true);
Annotations::Annotation::AssociativeOriginData assocOrigin1;
assocOrigin1.OriginType = Annotations::AssociativeOriginTypeDrag;
View *nullView(NULL);
assocOrigin1.View = nullView;
assocOrigin1.ViewOfGeometry = nullView;
Point *nullPoint(NULL);
assocOrigin1.PointOnGeometry = nullPoint;
assocOrigin1.VertAnnotation = NULL;
assocOrigin1.VertAlignmentPosition = Annotations::AlignmentPositionTopLeft;
assocOrigin1.HorizAnnotation = NULL;
assocOrigin1.HorizAlignmentPosition = Annotations::AlignmentPositionTopLeft;
assocOrigin1.AlignedAnnotation = NULL;
assocOrigin1.DimensionLine = 0;
assocOrigin1.AssociatedView = nullView;
assocOrigin1.AssociatedPoint = nullPoint;
assocOrigin1.OffsetAnnotation = NULL;
assocOrigin1.OffsetAlignmentPosition = Annotations::AlignmentPositionTopLeft;
assocOrigin1.XOffsetFactor = 0.0;
assocOrigin1.YOffsetFactor = 0.0;
assocOrigin1.StackAlignmentPosition = Annotations::StackAlignmentPositionAbove;
tableSectionBuilder1->Origin()->SetAssociativeOrigin(assocOrigin1);
Point3d point1(100, 150, 0.0);//定义点
tableSectionBuilder1->Origin()->Origin()->SetValue(NULL, nullView, point1);//设置表放置位置
tableSectionBuilder1->Origin()->SetInferRelativeToGeometry(true);
NXObject *nXObject1;
nXObject1 = tableSectionBuilder1->Commit();
std::vector<NXObject *> objects1;
objects1 = tableSectionBuilder1->GetCommittedObjects();
tableSectionBuilder1->Destroy();
原文:https://www.cnblogs.com/hqsalanhuang/p/14587808.html