iCAx开思网
标题:
请高手帮忙调试_看哪里出问题了
[打印本页]
作者:
zxzx
时间:
2011-1-11 12:04
标题:
请高手帮忙调试_看哪里出问题了
运行编译后的DLL时,当选择实体边时就会出错。
请高手帮忙查看哪里出问题了,用NX6.0库和NX6.0里运行。
以下附件是源码和.界面文件
作者:
zxzx
时间:
2011-1-11 12:04
//==============================================================================
// WARNING!! This file is overwritten by the UIStyler each time the Styler
// file is saved.
//
// Filename: UIStylerSelectionExample.hxx
//
// This file was generated by the NX User Interface Styler
// Created by: jawale
// Version: NX 5
// Date: 12-13-2006
// Time: 11:56
//
// This template file is overwritten each time the UIStyler dialog is
// saved. Any modifications to this file will be lost.
//==============================================================================
#ifndef UISTYLERSELECTIONEXAMPLE_H_INCLUDED
#define UISTYLERSELECTIONEXAMPLE_H_INCLUDED
//------------------------------------------------------------------------------
// These includes are needed for the following template code
//------------------------------------------------------------------------------
#include <uf_defs.h>
#include <iostream>
#include <NXOpen/Session.hxx>
#include <NXOpen/UI.hxx>
#include <NXOpen/Callback.hxx>
#include <NXOpen/NXException.hxx>
#include <NXOpen/UIStyler_Dialog.hxx>
#include <NXOpen/UIStyler_StylerEvent.hxx>
#include <NXOpen/NXMessageBox.hxx>
#include <NXOpen/UIStyler_BitMap.hxx>
#include <NXOpen/UIStyler_CollapsibleGroup.hxx>
#include <NXOpen/UIStyler_DialogItem.hxx>
#include <NXOpen/UIStyler_GroupBox.hxx>
#include <NXOpen/UIStyler_LabelItem.hxx>
#include <NXOpen/UIStyler_RealItem.hxx>
#include <NXOpen/UIStyler_StringItem.hxx>
#include <NXOpen/UIStyler_Toggle.hxx>
//------------------------------------------------------------------------------
// Namespaces needed for following template
//------------------------------------------------------------------------------
using namespace std;
using namespace NXOpen;
using namespace NXOpen::UIStyler;
//------------------------------------------------------------------------------
// Forward declaration for Class
//------------------------------------------------------------------------------
class UIStylerSelectionExample;
//------------------------------------------------------------------------------
// Declaration of global variables
//------------------------------------------------------------------------------
extern UIStylerSelectionExample *theUIStylerSelectionExample;
class UIStylerSelectionExample
{
// class members
public:
static Session *theSession;
static UI *theUI;
static bool isDisposeCalled;
UIStylerSelectionExample();
~UIStylerSelectionExample();
void Dispose();
NXOpen::UIStyler::DialogResponse Show();
void RegisterWithUiMenu();
//------------------------- UIStyler Callback Prototypes -----------------------
// The following member function prototypes define the callbacks
// specified in your UIStyler built dialog. You are REQUIRED to
// create the associated function for each prototype. You must
// use the same function name and parameter list when creating
// your callback function.
//------------------------------------------------------------------------------
NXOpen::UIStyler::DialogState apply_cb(NXOpen::UIStyler::StylerEvent* eventObject);
NXOpen::UIStyler::DialogState bend_radius_cb(NXOpen::UIStyler::StylerEvent* eventObject);
NXOpen::UIStyler::DialogState constructor_cb(NXOpen::UIStyler::StylerEvent* eventObject);
NXOpen::UIStyler::DialogState ok_cb(NXOpen::UIStyler::StylerEvent* eventObject);
NXOpen::UIStyler::DialogState remove_surface_self_intersections_cb(NXOpen::UIStyler::StylerEvent* eventObject);
NXOpen::UIStyler::DialogState tolerance_cb(NXOpen::UIStyler::StylerEvent* eventObject);
NXOpen::UIStyler::LabelItem *GetChangeLabel1();
private:
NXOpen::UIStyler::Dialog *theDialog;
NXOpen::UIStyler::DialogItem *changeDialog;
NXOpen::UIStyler::GroupBox *changeGrBeg1;
NXOpen::UIStyler::BitMap *changeBitmap1;
NXOpen::UIStyler::LabelItem *changeLabel1;
NXOpen::UIStyler::StringItem *changeStr0;
NXOpen::UIStyler::CollapsibleGroup *changeCgBeg5;
NXOpen::UIStyler::Toggle *changeToggle6;
NXOpen::UIStyler::RealItem *changeReal6;
void InitializeUIStylerDialog();
};
#endif // UIStylerSelectionExample_H_INCLUDED
复制代码
本帖最后由 zxzx 于 2011-1-11 12:07 编辑
作者:
zxzx
时间:
2011-1-11 12:12
// Filename: UIStylerSelectionExample.cxx
//------------------------------------------------------------------------------
// These includes are needed for the following template code
//------------------------------------------------------------------------------
#include <map>
#include <algorithm>
#include <NXOpen/UI.hxx>
#include <NXOpen/UIStyler_Styler.hxx>
#include <NXOpen/Selection.hxx>
#include <NXOpen/NXObject.hxx>
#include <NXOpen/UIStyler_LabelItem.hxx>
#include <uf_defs.h>
#include <NXOpen/Builder.hxx>
#include <NXOpen/Edge.hxx>
#include <NXOpen/EdgeMultipleSeedTangentRule.hxx>
#include <NXOpen/Features_Block.hxx>
#include <NXOpen/Features_EdgeBlendBuilder.hxx>
#include <NXOpen/Features_Feature.hxx>
#include <NXOpen/Features_FeatureBuilder.hxx>
#include <NXOpen/Features_FeatureCollection.hxx>
#include <NXOpen/GeometricUtilities_BlendLimitsData.hxx>
#include <NXOpen/ObjectList.hxx>
#include <NXOpen/Part.hxx>
#include <NXOpen/PartCollection.hxx>
#include <NXOpen/ScCollector.hxx>
#include <NXOpen/ScCollectorCollection.hxx>
#include <NXOpen/ScRuleFactory.hxx>
#include <NXOpen/SelectionIntentRule.hxx>
#include <NXOpen/Session.hxx>
#include <NXOpen/TaggedObjectList.hxx>
#include <uf_object_types.h>
#include <uf_ui_types.h>
#include "UIStylerSelectionExample.hxx"
using namespace NXOpen;
std::map<const char*, NXOpen::NXObject*> htEdges;
std::map<const char*, NXOpen::NXObject*>::iterator htEdgesIterator;
//------------------------------------------------------------------------------
// Initialize static variables
//------------------------------------------------------------------------------
Session *(UIStylerSelectionExample::theSession) = NULL;
UI *(UIStylerSelectionExample::theUI) = NULL;
bool UIStylerSelectionExample::isDisposeCalled = false;
//------------------------------------------------------------------------------
// Declaration of global variables
//------------------------------------------------------------------------------
UIStylerSelectionExample *theUIStylerSelectionExample;
//------------------------------------------------------------------------------
// Constructor for NX Styler class
//------------------------------------------------------------------------------
UIStylerSelectionExample::UIStylerSelectionExample()
{
try
{
// Initialize the NX Open C++ API environment
UIStylerSelectionExample::theSession = NXOpen::Session::GetSession();
UIStylerSelectionExample::theUI = UI::GetUI();
// Initialize the Open C API environment
UIStylerSelectionExample::isDisposeCalled = false;
NXOpen::UIStyler::Styler* theStyler = theUI->Styler();
theDialog = theStyler->CreateStylerDialog("UIStylerSelectionExample.dlg");
InitializeUIStylerDialog();
}
catch (const NXOpen::NXException& ex)
{
// ---- Enter your exception handling code here -----
UIStylerSelectionExample::theUI->NXMessageBox()->Show("UI Styler", NXOpen::NXMessageBox::DialogTypeError, ex.Message());
}
return;
}
//------------------------------------------------------------------------------
// This method is required for UI styler dialog creation
//------------------------------------------------------------------------------
void UIStylerSelectionExample::InitializeUIStylerDialog()
{
try
{
changeDialog = (NXOpen::UIStyler::DialogItem*)theDialog->GetStylerItem("UF_STYLER_DIALOG_INDEX", NXOpen::UIStyler::Dialog::ItemTypeDialogItem);
changeDialog->AddConstructHandler(make_callback(this, &UIStylerSelectionExample::constructor_cb), false);
changeDialog->AddOkayHandler(make_callback(this, &UIStylerSelectionExample::ok_cb), false);
changeDialog->AddApplyHandler(make_callback(this, &UIStylerSelectionExample::apply_cb), false);
changeGrBeg1 = (NXOpen::UIStyler::GroupBox*)theDialog->GetStylerItem("GR_BEG_1", NXOpen::UIStyler::Dialog::ItemTypeGroupBox);
changeBitmap1 = (NXOpen::UIStyler::BitMap*)theDialog->GetStylerItem("BITMAP_1", NXOpen::UIStyler::Dialog::ItemTypeBitmap);
changeLabel1 = (NXOpen::UIStyler::LabelItem*)theDialog->GetStylerItem("LABEL_1", NXOpen::UIStyler::Dialog::ItemTypeLabelItem);
changeStr0 = (NXOpen::UIStyler::StringItem*)theDialog->GetStylerItem("STR_0", NXOpen::UIStyler::Dialog::ItemTypeStringItem);
changeStr0->AddActivateHandler(make_callback(this, &UIStylerSelectionExample::bend_radius_cb), false);
changeCgBeg5 = (NXOpen::UIStyler::CollapsibleGroup*)theDialog->GetStylerItem("CG_BEG_5", NXOpen::UIStyler::Dialog::ItemTypeCollapsibleGroup);
changeToggle6 = (NXOpen::UIStyler::Toggle*)theDialog->GetStylerItem("TOGGLE_6", NXOpen::UIStyler::Dialog::ItemTypeToggle);
changeToggle6->AddValueChangedHandler(make_callback(this, &UIStylerSelectionExample::remove_surface_self_intersections_cb), false);
changeReal6 = (NXOpen::UIStyler::RealItem*)theDialog->GetStylerItem("REAL_6", NXOpen::UIStyler::Dialog::ItemTypeRealItem);
changeReal6->AddActivateHandler(make_callback(this, &UIStylerSelectionExample::tolerance_cb), false);
}
catch (const NXOpen::NXException& ex)
{
// ---- Enter your exception handling code here -----
UIStylerSelectionExample::theUI->NXMessageBox()->Show("UI Styler", NXOpen::NXMessageBox::DialogTypeError, ex.Message());
}
return;
}
NXOpen::UIStyler::LabelItem* UIStylerSelectionExample::GetChangeLabel1()
{
return changeLabel1;
}
extern "C" DllExport void ufusr(char *param, int *retcod, int param_len)
{
try
{
NXOpen::UIStyler::DialogResponse response;
theUIStylerSelectionExample = new UIStylerSelectionExample();
// The following method shows the dialog immediately
response = theUIStylerSelectionExample->Show();
theUIStylerSelectionExample->Dispose();
}
catch (const NXOpen::NXException& ex)
{
// ---- Enter your exception handling code here -----
UIStylerSelectionExample::theUI->NXMessageBox()->Show("UI Styler", NXOpen::NXMessageBox::DialogTypeError, ex.Message());
}
} // User exit ends
extern "C" DllExport int ufusr_ask_unload()
{
// return (int)Session::LibraryUnloadOptionExplicitly;
return (int)Session::LibraryUnloadOptionImmediately;
// return (int)Session::LibraryUnloadOptionAtTermination;
}
extern "C" DllExport void ufusr_cleanup(void)
{
try
{
if(UIStylerSelectionExample::isDisposeCalled == false)
{
theUIStylerSelectionExample->Dispose();
}
UIStylerSelectionExample::isDisposeCalled = true;
}
catch (const NXOpen::NXException& ex)
{
// ---- Enter your exception handling code here -----
UIStylerSelectionExample::theUI->NXMessageBox()->Show("UI Styler", NXOpen::NXMessageBox::DialogTypeError, ex.Message());
}
return;
}
NXOpen::UIStyler::DialogResponse UIStylerSelectionExample::Show()
{
NXOpen::UIStyler::DialogResponse retValue = NXOpen::UIStyler::DialogResponseOk;
try
{
retValue = theDialog->Show();
}
catch (const NXOpen::NXException& ex)
{
UIStylerSelectionExample::theUI->NXMessageBox()->Show("UI Styler", NXOpen::NXMessageBox::DialogTypeError, ex.Message());
}
return retValue;
}
void UIStylerSelectionExample::Dispose()
{
try
{
if (UIStylerSelectionExample::isDisposeCalled == false)
{
delete changeDialog;
delete changeGrBeg1;
delete changeBitmap1;
delete changeLabel1;
delete changeStr0;
delete changeCgBeg5;
delete changeToggle6;
delete changeReal6;
delete theDialog;
}
UIStylerSelectionExample::isDisposeCalled = true;
}
catch (const NXOpen::NXException& ex)
{
UIStylerSelectionExample::theUI->NXMessageBox()->Show("UI Styler", NXOpen::NXMessageBox::DialogTypeError, ex.Message());
}
return;
}
int sel_cb(std::vector<NXOpen::NXObject *> selectedObject, std::vector<NXOpen::NXObject *> deselectedObjects, NXOpen::SelectionHandle* selectHandle)
{
try
{
std::vector<NXOpen::NXObject *>::iterator selIter;
for (selIter = selectedObject.begin(); selIter != selectedObject.end(); selIter++)
{
htEdges[(*selIter)->JournalIdentifier().GetLocaleText()] = *selIter;
}
for (selIter = deselectedObjects.begin(); selIter != deselectedObjects.end(); selIter++)
{
htEdges.erase((*selIter)->JournalIdentifier().GetLocaleText());
}
int cnt = htEdges.size();
char sel_edges[100];
sprintf(sel_edges, "Select Edges ( %d )", cnt);
theUIStylerSelectionExample->GetChangeLabel1()->SetLabel(NXOpen::NXString(std::string(sel_edges)));
}
catch (const NXOpen::NXException& ex)
{
UIStylerSelectionExample::theUI->NXMessageBox()->Show("UI Styler", NXOpen::NXMessageBox::DialogTypeError, ex.Message());
}
return NXOpen::UIStyler::DialogStateContinueDialog;
}
int filter_cb(NXOpen::NXObject *selectedObject, NXOpen::Selection::MaskTriple* selectionMask_array, NXOpen::SelectionHandle* selectHandle)
{
try
{
if(std::string(selectedObject->JournalIdentifier().GetText()) == std::string("EDGE * 6 * 1"))
return UF_UI_SEL_REJECT;
else
return UF_UI_SEL_ACCEPT;
}
catch (const NXOpen::NXException& ex)
{
UIStylerSelectionExample::theUI->NXMessageBox()->Show("UI Styler", NXOpen::NXMessageBox::DialogTypeError, ex.Message());
}
return NXOpen::UIStyler::DialogStateContinueDialog;
}
NXOpen::UIStyler::DialogState UIStylerSelectionExample::constructor_cb(NXOpen::UIStyler::StylerEvent* eventObject)
{
try
{
// Get the selection handle
NXOpen::SelectionHandle *selectH = changeDialog->GetSelectionHandle();
std::vector<NXOpen::Selection::MaskTriple> selectionMask_array;
NXOpen::Selection::MaskTriple selectionMask_arrayElem;
selectionMask_arrayElem.Type = UF_solid_type;
selectionMask_arrayElem.Subtype = UF_solid_edge_subtype;
selectionMask_arrayElem.SolidBodySubtype = UF_UI_SEL_FEATURE_ANY_EDGE;
selectionMask_array.push_back(selectionMask_arrayElem);
UI::GetUI()->SelectionManager()->SetSelectionMask(selectH, NXOpen::Selection::SelectionActionClearAndEnableSpecific, selectionMask_array);
UI::GetUI()->SelectionManager()->SetSelectionCallbacks(selectH, make_callback(&filter_cb), make_callback(&sel_cb));
changeToggle6->SetItemValue(true);
changeStr0->SetItemValue("5.0");
changeLabel1->SetLabel("Select Edges (0)");
}
catch (const NXOpen::NXException& ex)
{
UIStylerSelectionExample::theUI->NXMessageBox()->Show("UI Styler", NXOpen::NXMessageBox::DialogTypeError, ex.Message());
}
return NXOpen::UIStyler::DialogStateContinueDialog;
}
NXOpen::UIStyler::DialogState UIStylerSelectionExample::ok_cb(NXOpen::UIStyler::StylerEvent* eventObject)
{
try
{
NXOpen::UIStyler::DialogState LOCAL_state = apply_cb(eventObject);
return LOCAL_state;
}
catch (const NXOpen::NXException& ex)
{
UIStylerSelectionExample::theUI->NXMessageBox()->Show("UI Styler", NXOpen::NXMessageBox::DialogTypeError, ex.Message());
}
return NXOpen::UIStyler::DialogStateExitDialog;
}
NXOpen::UIStyler::DialogState UIStylerSelectionExample::apply_cb(NXOpen::UIStyler::StylerEvent* eventObject)
{
try
{
Part *workPart(theSession->Parts()->Work());
Part *displayPart(theSession->Parts()->Display());
Session::UndoMarkId markId1;
markId1 = theSession->SetUndoMark(Session::MarkVisibilityVisible, "Start");
Features::Feature *nullFeatures_Feature(NULL);
Features::EdgeBlendBuilder *edgeBlendBuilder1;
edgeBlendBuilder1 = workPart->Features()->CreateEdgeBlendBuilder(nullFeatures_Feature);
theSession->SetUndoMarkName(markId1, "Edge Blend");
ScCollector *scCollector1;
scCollector1 = workPart->ScCollectors()->CreateCollector();
std::vector<Edge *> seedEdges1;
Features::Block *block1(dynamic_cast<Features::Block *>(workPart->Features()->FindObject("BLOCK(1)")));
for (htEdgesIterator = htEdges.begin(); htEdgesIterator != htEdges.end(); ++htEdgesIterator)
{
Edge *edge1(dynamic_cast<Edge *>(htEdgesIterator->second));
seedEdges1.push_back(edge1);
}
EdgeMultipleSeedTangentRule *edgeMultipleSeedTangentRule1;
edgeMultipleSeedTangentRule1 = workPart->ScRuleFactory()->CreateRuleEdgeMultipleSeedTangent(seedEdges1, 0.5, true);
std::vector<SelectionIntentRule *> rules1(1);
rules1[0] = edgeMultipleSeedTangentRule1;
scCollector1->ReplaceRules(rules1, false);
Session::UndoMarkId markId2;
markId2 = theSession->SetUndoMark(Session::MarkVisibilityInvisible, "Edge Blend");
edgeBlendBuilder1->LimitsListData()->CapsList()->Clear(ObjectList::DeleteOptionDelete);
edgeBlendBuilder1->SetTolerance(0.0254);
edgeBlendBuilder1->SetAllInstancesOption(false);
edgeBlendBuilder1->SetRemoveSelfIntersection(true);
edgeBlendBuilder1->SetConvexConcaveY(false);
edgeBlendBuilder1->SetRollOverSmoothEdge(true);
edgeBlendBuilder1->SetRollOntoEdge(true);
edgeBlendBuilder1->SetMoveSharpEdge(true);
edgeBlendBuilder1->SetOverlapOption(Features::EdgeBlendBuilder::OverlapAnyConvexityRollOver);
edgeBlendBuilder1->SetBlendOrder(Features::EdgeBlendBuilder::OrderOfBlendingConvexFirst);
edgeBlendBuilder1->SetSetbackOption(Features::EdgeBlendBuilder::SetbackSeparateFromCorner);
int csIndex1;
csIndex1 = edgeBlendBuilder1->AddChainset(scCollector1, "5");
Features::Feature *feature1;
feature1 = edgeBlendBuilder1->CommitFeature();
theSession->DeleteUndoMark(markId2, NULL);
edgeBlendBuilder1->Destroy();
htEdges.clear();
changeLabel1->SetLabel("Select Edges (0)");
}
catch (const NXOpen::NXException& ex)
{
UIStylerSelectionExample::theUI->NXMessageBox()->Show("UI Styler", NXOpen::NXMessageBox::DialogTypeError, ex.Message());
}
return NXOpen::UIStyler::DialogStateContinueDialog;
}
NXOpen::UIStyler::DialogState UIStylerSelectionExample::bend_radius_cb(NXOpen::UIStyler::StylerEvent* eventObject)
{
try
{
}
catch (const NXOpen::NXException& ex)
{
// ---- Enter your exception handling code here -----
UIStylerSelectionExample::theUI->NXMessageBox()->Show("UI Styler", NXOpen::NXMessageBox::DialogTypeError, ex.Message());
}
// Callback acknowledged, do not terminate dialog
return NXOpen::UIStyler::DialogStateContinueDialog;
// or Callback acknowledged, terminate dialog.
// return NXOpen::UIStyler::DialogStateExitDialog;
}
NXOpen::UIStyler::DialogState UIStylerSelectionExample::remove_surface_self_intersections_cb(NXOpen::UIStyler::StylerEvent* eventObject)
{
try
{
}
catch (const NXOpen::NXException& ex)
{
// ---- Enter your exception handling code here -----
UIStylerSelectionExample::theUI->NXMessageBox()->Show("UI Styler", NXOpen::NXMessageBox::DialogTypeError, ex.Message());
}
// Callback acknowledged, do not terminate dialog
return NXOpen::UIStyler::DialogStateContinueDialog;
// or Callback acknowledged, terminate dialog.
// return NXOpen::UIStyler::DialogStateExitDialog;
}
NXOpen::UIStyler::DialogState UIStylerSelectionExample::tolerance_cb(NXOpen::UIStyler::StylerEvent* eventObject)
{
try
{
}
catch (const NXOpen::NXException& ex)
{
UIStylerSelectionExample::theUI->NXMessageBox()->Show("UI Styler", NXOpen::NXMessageBox::DialogTypeError, ex.Message());
}
return NXOpen::UIStyler::DialogStateContinueDialog;
}
复制代码
作者:
staylove
时间:
2011-5-11 20:01
最近也一直在研究,帮你看看吧。不知道能不能解决!!
作者:
猛虎下山
时间:
2011-9-13 13:52
没有用过啊
欢迎光临 iCAx开思网 (https://www.icax.org/)
Powered by Discuz! X3.3