wzyhust 发表于 2018-3-19 10:55:03

创建PMI注释

初学NXOpenC++,需要创建PMI注释,根据录制编写代码,但运行到pmiNoteBuilder->Text()->TextBlock()->SetText( strArrText ); 总是出错,提示:存储管理器中错误的内存定位请求大小(内存出错)。很简单的代码,不知道为什么会有这样的问题,请教各位大神,谢谢!

附代码:

      NXOpen::Session *theSession = NXOpen::Session::GetSession();

       NXOpen::Part *workPart = NULL;
       workPart = theSession->Parts()->Work();

         NXOpen::Annotations::PmiNoteBuilder *pmiNoteBuilder      = NULL;
       NXOpen::Annotations::SimpleDraftingAid *simpleDraftingAid = NULL;
       pmiNoteBuilder = workPart->Annotations()->CreatePmiNoteBuilder( simpleDraftingAid);

       pmiNoteBuilder->Origin()->Plane()->SetPlaneMethod( NXOpen::Annotations::PlaneBuilder::PlaneMethodTypeXyPlane );
       pmiNoteBuilder->Origin()->SetInferRelativeToGeometry(false);

       NXOpen::Annotations::OriginBuilder::AlignmentPosition setAnchor = NXOpen::Annotations::OriginBuilder::AlignmentPositionMidCenter ;
       pmiNoteBuilder->Origin()->SetAnchor( setAnchor );

       std::vector< NXOpen::NXString >strArrText(6);
         strArrText = NXOpen::NXString( "JianCeDian 1", NXOpen::NXString::Locale );
         strArrText = NXOpen::NXString( "LiLunZhi: (X)-72.836(Y)47.835(Z)0.000", NXOpen::NXString::Locale );
         strArrText = NXOpen::NXString( "ShiCeZhi: (X)-72.836(Y)47.835(Z)0.000", NXOpen::NXString::Locale );
         strArrText = NXOpen::NXString( "ZhouXiangPianChaZhi: (X)0.0054   (Y)0.2154(Z)0.0254", NXOpen::NXString::Locale );
         strArrText = NXOpen::NXString( "ZongHeWuChaZhi: 0.005 (NG)", NXOpen::NXString::Locale );
       strArrText = "";

       pmiNoteBuilder->Text()->TextBlock()->SetText( strArrText );



------------------------------------------------------

#include <NXOpen/Session.hxx>
#include <NXOpen/Part.hxx>
#include <NXOpen/Features_BlockFeatureBuilder.hxx>
#include <NXOpen/Features_Block.hxx>
#include <NXOpen/PartCollection.hxx>
#include <NXOpen/Features_FeatureCollection.hxx>
#include <NXOpen/UI.hxx>
#include <NXOpen/NXMessageBox.hxx>
#include <NXOPEN/NXString.hxx>

#include <NXOpen/NXException.hxx>
#include <NXOpen/Session.hxx>
#include <NXOpen/Annotations_AnnotationManager.hxx>
#include <NXOpen/Annotations_AssociatedObjectsBuilder.hxx>
#include <NXOpen/Annotations_DimensionStyleBuilder.hxx>
#include <NXOpen/Annotations_DraftingNoteBuilder.hxx>
#include <NXOpen/Annotations_FrameBarElementStyleBuilder.hxx>
#include <NXOpen/Annotations_FrameBarStyleBuilder.hxx>
#include <NXOpen/Annotations_HatchStyleBuilder.hxx>
#include <NXOpen/Annotations_LeaderBuilder.hxx>
#include <NXOpen/Annotations_LeaderData.hxx>
#include <NXOpen/Annotations_LeaderDataList.hxx>
#include <NXOpen/Annotations_LetteringStyleBuilder.hxx>
#include <NXOpen/Annotations_LineArrowStyleBuilder.hxx>
#include <NXOpen/Annotations_OrdinateStyleBuilder.hxx>
#include <NXOpen/Annotations_OriginBuilder.hxx>
#include <NXOpen/Annotations_PlaneBuilder.hxx>
#include <NXOpen/Annotations_PmiNoteBuilder.hxx>
#include <NXOpen/Annotations_RadialStyleBuilder.hxx>
#include <NXOpen/Annotations_StyleBuilder.hxx>
#include <NXOpen/Annotations_SymbolStyleBuilder.hxx>
#include <NXOpen/Annotations_TextWithEditControlsBuilder.hxx>
#include <NXOpen/Annotations_TextWithSymbolsBuilder.hxx>
#include <NXOpen/Annotations_UnitsStyleBuilder.hxx>
#include <NXOpen/Builder.hxx>
#include <NXOpen/Drawings_SelectDraftingView.hxx>
#include <NXOpen/ModelingView.hxx>
#include <NXOpen/ModelingViewCollection.hxx>
#include <NXOpen/NXObject.hxx>
#include <NXOpen/ObjectList.hxx>
#include <NXOpen/Part.hxx>
#include <NXOpen/PartCollection.hxx>
#include <NXOpen/Point.hxx>
#include <NXOpen/PointCollection.hxx>
#include <NXOpen/SelectDisplayableObject.hxx>
#include <NXOpen/SelectDisplayableObjectList.hxx>
#include <NXOpen/SelectObject.hxx>
#include <NXOpen/SelectObjectList.hxx>
#include <NXOpen/Session.hxx>
#include <NXOpen/TaggedObject.hxx>
#include <NXOpen/Xform.hxx>

//

WhosDady 发表于 2019-5-16 17:33:43

内存问题应该是电脑缓存的问题,删除temp下缓存文件
页: [1]
查看完整版本: 创建PMI注释