📄 samp4.c
字号:
/*load head file*/
#include<ProToolkit.h>#include<Pro2dEntdef.h>#include<ProANSI.h>#include<ProAnimate.h>#include<ProArray.h>#include<ProAsmcomp.h>#include<ProAsmcomppath.h>#include<ProAssembly.h>#include<ProAxis.h>#include<ProChamfer.h>#include<ProClCmd.h>#include<ProColor.h>#include<ProComm.h>#include<ProConst.h>#include<ProContour.h>#include<ProContourdata.h>#include<ProCore.h>#include<ProCsys.h>#include<ProCsysdata.h>#include<ProCurve.h>#include<ProCurvedata.h>#include<ProDatumdata.h>#include<ProDisplist.h>#include<ProDtmAxis.h>#include<ProDtmCrv.h>#include<ProDtmCrvSketch.h>#include<ProDtmCsys.h>#include<ProDtmPln.h>#include<ProEdge.h>#include<ProEdgedata.h>#include<ProElemId.h>#include<ProElement.h>#include<ProElempath.h>#include<ProExpldstate.h>#include<ProExtdata.h>#include<ProExtobj.h>#include<ProExtobjCB.h>#include<ProExtobjDisp.h>#include<ProExtobjRef.h>#include<ProExtobjSel.h>#include<ProExtrude.h>#include<ProFaminstance.h>#include<ProFamtable.h>#include<ProFeatForm.h>#include<ProFeatType.h>#include<ProFeature.h>#include<ProFixture.h>#include<ProFlatSrf.h>#include<ProForeignCurve.h>#include<ProGeomitem.h>#include<ProGeomitemdata.h>#include<ProGraphic.h>#include<ProGroup.h>#include<ProHardware.h>#include<ProImportfeat.h>#include<ProIntfData.h>#include<ProItemerr.h>#include<ProLayer.h>#include<ProLayerR19.h>#include<ProMaterial.h>#include<ProMdl.h>#include<ProMenu.h>#include<ProMenuBar.h>#include<ProMessage.h>#include<ProMfg.h>#include<ProMfgoper.h>#include<ProModFeat.h>#include<ProMode.h>#include<ProModelitem.h>#include<ProNcseq.h>#include<ProNcseqElem.h>#include<ProNote.h>#include<ProNotify.h>#include<ProObjects.h>#include<ProParameter.h>#include<ProParamval.h>#include<ProPart.h>#include<ProPattern.h>#include<ProPecktable.h>#include<ProPoint.h>#include<ProProcstep.h>#include<ProQuilt.h>#include<ProQuiltdata.h>#include<ProRelSet.h>#include<ProReplace.h>#include<ProRevolve.h>#include<ProRmdt.h>#include<ProRule.h>#include<ProSecConstr.h>#include<ProSecdim.h>#include<ProSecdimType.h>#include<ProSecerror.h>#include<ProSection.h>#include<ProSelection.h>#include<ProSheetmetal.h>#include<ProSimprep.h>#include<ProSimprepdata.h>#include<ProSizeConst.h>#include<ProSolid.h>#include<ProStdSection.h>#include<ProSurface.h>#include<ProSurfacedata.h>#include<ProSweep.h>#include<ProTool.h>#include<ProToolElem.h>#include<ProToolinput.h>#include<ProUICmd.h>#include<ProUtil.h>#include<ProValue.h>#include<ProVerstamp.h>#include<ProView.h>#include<ProWcell.h>#include<ProWchar.h>#include<ProWindows.h>#include<ProWorkspace.h>#include<ProWstring.h>
#include<UtilMatrix.h>
#include<UtilMath.h>
ProFileName UserMsg;
int UserSolidNoteCreate();
/*--------------------------------------------------------------------*\Application global data\*--------------------------------------------------------------------*/static uiCmdAccessState TestAccessDefault(uiCmdAccessMode access_mode){ return (ACCESS_AVAILABLE);}/*===========================================================================*\ Function : main Purpose : Test the ProToolkitMain() function. main is optional function.\*===========================================================================*/main(argc, argv)int argc;char **argv;{ ProToolkitMain(argc, argv); return(0);}/*====================================================================*\FUNCTION : user_initialize()PURPOSE : Pro/DEVELOP standard initialize - define menu button\*====================================================================*/int user_initialize( int argc, char *argv[], wchar_t errbuf[80]){
int i, menu_id;
ProError status;
uiCmdCmdId cmd_id;
/*----------------------------------------------------------------*\
消息文件
\*----------------------------------------------------------------*/
ProStringToWstring (UserMsg, "msg.txt");
status = ProMessageDisplay (UserMsg, "USER %0s", "Demo of creating note.\n");
/*---------------------------------------------------------------------*\
Add new button to the menu bar
\*---------------------------------------------------------------------*/
status = ProCmdActionAdd("MyCmd",
(uiCmdCmdActFn)UserSolidNoteCreate,
uiProe2ndImmediate, TestAccessDefault,
PRO_B_TRUE, PRO_B_TRUE, &cmd_id);
status = ProMenubarmenuPushbuttonAdd(
"File", "MyCmd", "Create Note", "Create a note",
"File.psh_exit", PRO_B_TRUE, cmd_id, UserMsg);
return (0);
}
/*====================================================================*\
FUNCTION : user_terminate()
PURPOSE : To handle any termination actions
\*====================================================================*/
void user_terminate()
{
}
/*================================================================*\
FUNCTION: UserSolidNoteCreate()
PURPOSE: Example of note creation for solids
\*================================================================*/
int UserSolidNoteCreate()
{
#define MAX_NOTE_LEN PRO_LINE_SIZE
int err;
ProSelection *p_sel; /* for selection */
int n_sel;
ProModelitem note_owner; /* owner of the note */
wchar_t** text_arr; /* list of note text lines */
ProMdl model; /* current model */
ProLine w_notetext; /* line of note text */
ProNote note; /* note object */
ProNoteAttach note_attach; /* attach information for
note */
int i;
ProMouseButton button;
ProPoint3d note_pos_scrn; /* note position in screen
coordinates */
ProPoint3d outline[2]; /* points delimiting the
model outline */
ProPoint3d note_pos; /* note position, in model
coordinates */
ProMatrix vmatrix, inv_vmatrix; /* view matrix and inverse */
ProMatrix def_matrix = {{1.0, 0.0, 0.0, 0.0},
{0.0, 1.0, 0.0, 0.0},
{0.0, 0.0, 1.0, 0.0},
{0.0, 0.0, 0.0, 1.0}};
/*----------------------------------------------------------------*\
Get the current model.
\*----------------------------------------------------------------*/
err = ProMdlCurrentGet (&model);
if (err != PRO_TK_NO_ERROR)
{
ProMessageDisplay (UserMsg, "USER %0s",
"取得当前模型失败.");
return (err);
}
/*----------------------------------------------------------------*\
Get the note text.
\*----------------------------------------------------------------*/
ProMessageDisplay (UserMsg, "USER %0s", "输入注释文本:");
err = ProMessageStringRead (MAX_NOTE_LEN, w_notetext);
if (err != PRO_TK_NO_ERROR)
return (err);
/*----------------------------------------------------------------*\
Fill the array of note lines.
\*----------------------------------------------------------------*/
err = ProArrayAlloc (1, sizeof(wchar_t*), 1, (ProArray*)&text_arr);
text_arr[0] = &w_notetext [0];
/*----------------------------------------------------------------*\
Get the modelitem for the model.
\*----------------------------------------------------------------*/
err = ProMdlToModelitem (model, ¬e_owner);
/*----------------------------------------------------------------*\
Create the note to be owned by the model.
\*----------------------------------------------------------------*/
err = ProSolidNoteCreate (model, NULL, text_arr, ¬e);
/*----------------------------------------------------------------*\
Get the leaders and add to the attachment.
\*----------------------------------------------------------------*/
ProMessageDisplay (UserMsg, "USER %0s",
"选择边作为箭头.");
err = ProSelect ("edge", -1, NULL, NULL, NULL, NULL, &p_sel,
&n_sel);
if (err != PRO_TK_NO_ERROR)
return (err);
err = ProNoteAttachAlloc (¬e_attach);
for (i = 0; i < n_sel; i++)
{
err = ProNoteAttachAddend (note_attach, p_sel[i],
PRO_NOTE_ATT_NONE);
}
/*----------------------------------------------------------------*\
Get the note position, in screen coordinates.
\*----------------------------------------------------------------*/
ProMessageDisplay (UserMsg, "USER %0s", "选择注释位置.");
err = ProMousePickGet (PRO_LEFT_BUTTON, &button, note_pos_scrn);
if (err != PRO_TK_NO_ERROR)
return (err);
/*----------------------------------------------------------------*\
Get the view matrix (the transformation from model coordinates
to screen coordinates) and invert.
\*----------------------------------------------------------------*/
err = ProViewMatrixGet (model, NULL, vmatrix);
err = ProUtilMatrixInvert (vmatrix, inv_vmatrix);
/*------------------------------------------------------------------*\
Transform the note position from screen coordinates to model
coordinates.
\*----------------------------------------------------------------*/
ProUtilPointTrans (inv_vmatrix, note_pos_scrn, note_pos);
err = ProSolidDispoutlineGet (model, def_matrix, outline);
/*----------------------------------------------------------------*\
Set the note position in terms of model size parameters
(see ProNote.h)
\*----------------------------------------------------------------*/
for (i = 0; i < 3; i++)
{
note_pos[i] = (note_pos[i] - outline[0][i]) /
(outline[1][i] - outline[0][i]);
}
err = ProNoteAttachFreeSet (note_attach, note_pos[0], note_pos[1],
note_pos[2]);
err = ProNotePlacementSet (¬e, note_attach);
/*----------------------------------------------------------------*\
Display the note.
\*----------------------------------------------------------------*/
err = ProNoteDisplay (¬e, PRO_DRAW_SET_MODE);
/*----------------------------------------------------------------*\
Free the memory.
\*----------------------------------------------------------------*/
err = ProNoteAttachRelease (¬e_attach);
err = ProArrayFree ((ProArray*)&text_arr);
return (PRO_TK_NO_ERROR);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -