gsmfxsmy 发表于 2016-3-20 19:15:41

20160320 lesson 2 2圆柱求和+手工输入中心线+点信息

/*****************************************************************************
**
** creat cly.cpp
**
** Description:
**   Contains Unigraphics entry points for the application.
**
*****************************************************************************/

/* Include files */
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
#   include <strstream>
#   include <iostream>
    using std::ostrstream;
    using std::endl;   
    using std::ends;
    using std::cerr;
#else
#   include <strstream.h>
#   include <iostream.h>
#endif
#include <uf.h>
#include <uf_ui.h>
#include <uf_exit.h>
#include<uf_part.h>
#include<uf_modl.h>
#include<uf_curve.h>
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))


static int report_error( char *file, int line, char *call, int irc)
{
    if (irc)
    {
      char err,
             msg;

      sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
            irc, line, file);
      UF_get_fail_message(irc, err);

      UF_print_syslog(msg, FALSE);
      UF_print_syslog(err, FALSE);
      UF_print_syslog("\n", FALSE);
      UF_print_syslog(call, FALSE);
      UF_print_syslog(";\n", FALSE);

      if (!UF_UI_open_listing_window())
      {
            UF_UI_write_listing_window(msg);
            UF_UI_write_listing_window(err);
            UF_UI_write_listing_window("\n");
            UF_UI_write_listing_window(call);
            UF_UI_write_listing_window(";\n");
      }
    }

    return(irc);
}


/*****************************************************************************
**Activation Methods
*****************************************************************************/
/*Unigraphics Startup
**      This entry point activates the application at Unigraphics startup */
extern DllExport void ufsta( char *param, int *returnCode, int rlen )
{
    /* Initialize the API environment */
    if( UF_CALL(UF_initialize()) )
    {
      /* Failed to initialize */
      return;
    }

    /* TODO: Add your application code here */
       
        //new part

        tag_t parttag=NULL_TAG;

        UF_PART_new("c:\\temp\\plmhome.prt",1,&parttag);

        //creat cyl

                double origin [ 3 ]={0,0,0};
                char *height={"50"};
                char *diam={"100"};
                double direction1 [ 3 ] ={1,1,1};
                double direction2 [ 3 ] ={-1,-1,-1};               
                tag_t cylFeatureTag=NULL_TAG;

        UF_CALL(UF_MODL_create_cyl1(UF_NULLSIGN,origin,height,diam,direction1,&cylFeatureTag));
        UF_CALL(UF_MODL_create_cyl1(UF_POSITIVE,origin,height,diam,direction2,&cylFeatureTag));
        //creat line
        UF_CURVE_line_t line_coords;
        line_coords.start_point=-50.0;
        line_coords.start_point=-50.0;
        line_coords.start_point=-50.0;
        line_coords.end_point=50;
        line_coords.end_point=50;
        line_coords.end_point=50;
        tag_t linetag=NULL_TAG;

        UF_CALL(UF_CURVE_create_line(&line_coords,&linetag));
        //creat point
        double pointstartcoords={line_coords.start_point,line_coords.start_point,line_coords.start_point};
        double pointendcoords={line_coords.end_point,line_coords.end_point,line_coords.end_point};
        tag_t pointtag=NULL_TAG;
        UF_CALL(UF_CURVE_create_point(pointstartcoords,&pointtag));
                double start;
                UF_CURVE_ask_point_data(pointtag,start);
        UF_CALL(UF_CURVE_create_point(pointendcoords,&pointtag));
                double end;
                UF_CURVE_ask_point_data(pointtag,end);
        char msg1;
        char msg2;
        sprintf(msg1,"start:\nx:%f\ty:%f\tz:%f\n",start,start,start);
        uc1601(msg1,1);
        sprintf(msg2,"end:\nx:%f\ty:%f\tz:%f\n",end,end,end);
        uc1601(msg2,1);
        //mapping point from abs to wcs

        UF_UI_open_listing_window();
        UF_UI_write_listing_window(msg1);
        UF_UI_write_listing_window(msg2);
       
        //close
        UF_PART_close_all();

    /* Terminate the API environment */
    UF_CALL(UF_terminate());
}

/*****************************************************************************
**Utilities
*****************************************************************************/

/* Unload Handler
**   This function specifies when to unload your application from Unigraphics.
**   If your application registers a callback (from a MenuScript item or a
**   User Defined Object for example), this function MUST return
**   "UF_UNLOAD_UG_TERMINATE". */
extern int ufusr_ask_unload( void )
{
    return( UF_UNLOAD_IMMEDIATELY );
}


gsmfxsmy 发表于 2016-3-20 19:27:35

本帖最后由 gsmfxsmy 于 2016-3-20 19:29 编辑

L:\1http://www.plmhome.com/forum.php?mod=image&aid=1833&size=300x300&key=0166b90bc9940100&nocache=yes&type=fixnonehttp://www.plmhome.com/forum.php?mod=image&aid=1834&size=300x300&key=6e4e991f4011faf5&nocache=yes&type=fixnonehttp://www.plmhome.com/forum.php?mod=image&aid=1835&size=300x300&key=3bb5347feca8c412&nocache=yes&type=fixnone
页: [1]
查看完整版本: 20160320 lesson 2 2圆柱求和+手工输入中心线+点信息