gzxzl wrote:
谢谢二位大侠!
对于第二位说的,我觉得还不是我想要的。比如,我建立了一个名为ug_example.prt的文件,我只在这个文件里画了个长方体,现在我打开这个文件,然后执行UG/Open API程序,在这个长方体上作截面。同样我打开其他的文件,也能用同一程序对文件中的部件进行操作。程序在实现时,首先要取得“长方体”的tag,是吗?请大虾帮助解决!
stranger wrote:
这两个都是文件的tag,要获得长方体的tag,可以通过用户选择或者uf_obj_cycle_by_name
gzxzl wrote:
各位好!我的问题还没有解决,我使用了函数UF_PART_ask_displayed_part()
编译时就不成功,我又使用了函数UF_ASSEM_ask_work_part,虽然编译成功但到UG中去执行就是不行。哎,谁能帮我!!!
gzxzl wrote:
[quote]stranger wrote:
这两个都是文件的tag,要获得长方体的tag,可以通过用户选择或者uf_obj_cycle_by_name
gzxzl wrote:
各位不要急吗,我认为我说得比较清楚了。正如前面我说的,假如我想利用函数:extern int UF_CURVE_section_from_planes (UF_CURVE_section_general_data_p_t general_data, UF_CURVE_section_planes_data_p_t planes_data, tag_t * section_curves )
在一个打开的prt文件中对一个实体做截面线,那么就需要知道这个实体的tag,是吧?我的意思是在任意一个打开的文件中都适用,那么要识别tag的函数就不能需要输入某个实体的name等参数,这样才能普遍适用。
请大虾解释。THANK YOU VERY MUCH!
zzz wrote:
UF_OBJ_cycle_objs_in_part() can get any object in your part. I have told you before. Did you use it?
gzxzl wrote:
[quote]zzz wrote:
UF_OBJ_cycle_objs_in_part() can get any object in your part. I have told you before. Did you use it?
gzxzl wrote:
zzz你好,假如有如下程序,对一打开的prt文件做如下操作;
#include <stdio.h>
#include <uf.h>
#include <uf_curve.h>
#include <uf_modl.h>
#include <uf_part.h>
#include <uf_so.h>
#include <uf_defs.h>
#include <uf_object_types.h>
#include <uf_csys.h>
#include <uf_obj.h>
#define UF_CALL(X) (report( __FILE__, __LINE__, #X, (X)))
static int report (char *file, int line, char *call, int irc)
{
if (irc)
{
char messg[133];
printf("%s, line %d, %s\n", file, line, call);
UF_get_fail_message (irc, messg);
printf(" returned a %d\n", irc);
printf(" returned error %d, %s\n", irc, messg);
}
return (irc);
}
static void do_ugopen_api (void)
{
double plane_data[9] = {100.0,0.0,50.0, 100.0,0.0,49.0, 100.0,1.0,50.0};
double vect[3] = {250.0, 0.0, 0.0};
double vect2[3] = {250.0, 50.0, 0.0};
int curr_part,num_parts,count_1;
tag_t part_tag, block_tag, plane_tag;
tag_t objects[1], planes[1];
tag_t section_curves_feature, *section_curves;
tag_t feature;
const logical flip = TRUE;
int num_section_curves, type;
UF_CURVE_section_general_data_t general_data;
UF_CURVE_section_planes_data_t planes_data;
UF_CURVE_section_parallel_data_t parallel_data;
char *part_name = "section_curves";
char *edge_lens[3] = {"300.0","25.0","150.0"};
在此应获得block_tag的值(也就是打开的part中的值),我不知如何处理,请大侠帮助解决?
int type, subtype;
part_tag = UF_PART_ask_display_part();
block_tag = NULL_TAG;
UF_OBJ_cycle_objs_in_part(part_tag, UF_solid_type, [$block_tag)]
while(block_tag)
{
UF_OBJ_ask_type_and_subtype(block_tag, [$type, &subtype)]
if(subtype == UF_solid_body_subtype)
{
break;
}
UF_OBJ_cycle_objs_in_part(part_tag, UF_solid_type, [$block_tag)]
} objects[0] = block_tag;
FTN(uf5374) (&plane_data[0], &plane_data[3], &plane_data[6],
[$plane_tag)]
planes[0] = plane_tag;
general_data.associate = 1;
general_data.objects = objects;
general_data.num_objects = 1;
general_data.grouping = 0;
general_data.join_type = 0;
general_data.tolerance = 0.0254;
planes_data.planes = planes;
planes_data.num_planes = 1;
UF_CALL (UF_CURVE_section_from_planes (&general_data, &planes_data,
[$section_curves_feature))]
printf (" section curves feature tag is %d\n", section_curves_feature);
parallel_data.base_plane = plane_tag;
parallel_data.step_distance = 3.0;
parallel_data.start_distance = 0.0;
parallel_data.end_distance = 10.0;
UF_CALL (UF_CURVE_section_from_parallel_planes ([$general_data, [$para]]llel_data,
[$section_curves_feature))]
UF_CALL (UF_CURVE_ask_feature_curves (section_curves_feature,
[$num_section_curves, §ion_curves))]
UF_free (section_curves);
}
void ufusr (char *param, int *retcode, int paramLen)
{
if (!UF_CALL(UF_initialize()))
{
do_ugopen_api();
UF_CALL(UF_terminate());
}
}
int ufusr_ask_unload(void)
{
return (UF_UNLOAD_IMMEDIATELY);
}
lcfq wrote:
你用下面的代码没有作出来,那就是你的问题了。我自己前两天才编了,使用良好。
//include the head files needed.
tag_t body_tag=NULL_TAG;
tag_t feat_tag=NULL_TAG;
tag_t part_tag=NULL_TAG;
//get the tag of the current display part.
Part_tag=UF_PART_ask_display_part();
// find the solid body by a feature associated with it.
feat_type=UF_feature_type;
UF_OBJ_cycle_objs_in_part(part, feat_type, [$feat_tag)]
if(feat_tag==NULL_TAG)
{
uc1601("no feature found",1);
UF_terminate();
}
UF_MODL_ask_feat_body(feat_tag, [$body_tag)]
if(body_tag==NULL_TAG)
{
uc1601("no feature found",1);
UF_terminate();
}
lcfq wrote:
我写的部分只是找到block的tag。
欢迎光临 iCAx开思工具箱 (https://t.icax.org/) | Powered by Discuz! X3.3 |