我正在研究vba CATIA,我正在尝试为翻译操作创建一个函数。但是我在将函数的输出分配给对象时遇到错误。
期待解决方案。
提前致谢!!
void wantEat(int p, int rank, char *state, char* stateLeft, char* stateRight){
char *s;
MPI_Status status ;
/* if left or right neighbor is eating */
if(compare(stateLeft, "eat") || compare (stateRight, "eat")){
state = "want_Eat";
printf("%s : I wait for eating\n", nomPhilosophe(rank));
/* the process have to send his new state to his neighbors */
MPI_Send(state, strlen(state)+1, MPI_CHAR,
(rank - 1 + p) % p, 0, MPI_COMM_WORLD);
MPI_Send(state, strlen(state)+1, MPI_CHAR,
(rank + 1) % p, 0, MPI_COMM_WORLD);
/* if only left neighbor is eating */
if(compare(stateLeft,"eat") && !compare(stateRight,"eat")){
/* Wait for left neighbor finishes eating */
MPI_Recv(stateLeft, 6, MPI_CHAR, (rank - 1 + p) % p, 0,
MPI_COMM_WORLD, &status);
/* and eat */
state = "eat";
}
/* if only right neighbor is eating */
if(compare(stateRight,"eat") && !compare(stateLeft,"eat")){
/* wait for right neighbor message */
MPI_Recv(stateRight, 6, MPI_CHAR, (rank + 1) % p, 0,
MPI_COMM_WORLD, &status);
/* and eat */
state = "eat";
}
/* if both neighboors are eating */
if(compare(stateRight,"eat") && compare(stateLeft,"eat")){
/* wait for messages of the 2 neighbors */
MPI_Recv(stateLeft, strlen("think")+1, MPI_CHAR, MPI_ANY_SOURCE, 0,
MPI_COMM_WORLD, &status);
MPI_Recv(stateRight, strlen("think")+1, MPI_CHAR, MPI_ANY_SOURCE, 0,
MPI_COMM_WORLD, &status);
/* and eat */
state = "eat";
}
}
/* if neighbors are not eating */
else{
/* eat */
state= "eat";
}
/* send the new state to neighbors */
MPI_Send(state, strlen(state)+1, MPI_CHAR,
(rank - 1 + p) % p, 0, MPI_COMM_WORLD);
MPI_Send(state, strlen(state)+1, MPI_CHAR,
(rank + 1) % p, 0, MPI_COMM_WORLD);
}
int main(int argc, char* argv[]){
int my_rank; /* rank of process */
int p; /* number of processes */
char* state = "think"; /* state of process (think, eat, or want_eat) */
char* stateLeft = "think"; /* state of the left neighbor of the process */
char* etatD = "think"; /* state of the right neighbor of the process */
/* start up MPI */
MPI_Init(&argc, &argv);
/* find out process rank */
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
/* find out number of processes */
MPI_Comm_size(MPI_COMM_WORLD, &p);
think(my_rank); /* process "my_rank" is thinking */
wantEat(p, my_rank, state, stateLeft, stateRight); /* process "my_rank" wants to eat */
eat(my_rank); /* process "my_rank" is eating */
/* shut down MPI */
MPI_Finalize();
return 0;
}
调用该函数:
Function CreateTranslate(source As Object, value As Double, direction As Double)
Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part
If direction = 1 Then
Set hybridShapeFactory1 = part1.HybridShapeFactory
Set hybridShapeDirection1 = hybridShapeFactory1.AddNewDirectionByCoord(1#, 0#, 0#)
Else
If direction = 2 Then
Set hybridShapeFactory1 = part1.HybridShapeFactory
Set hybridShapeDirection1 = hybridShapeFactory1.AddNewDirectionByCoord(0#, 1#, 0#)
Else
If direction = 3 Then
Set hybridShapeFactory1 = part1.HybridShapeFactory
Set hybridShapeDirection1 = hybridShapeFactory1.AddNewDirectionByCoord(0#, 0#, 1#)
End If
End If
End If
Set CreateTranslate = hybridShapeFactory1.AddNewEmptyTranslate()
Set reference1 = part1.CreateReferenceFromObject(source)
CreateTranslate.ElemToTranslate = reference1
CreateTranslate.direction = hybridShapeDirection1
CreateTranslate.DistanceValue = value
End Function
答案 0 :(得分:1)
创建函数以返回对象时,必须使用Set
语句将对象分配给变量或属性。
Set result_of_translate = CreateTranslate(Kotfl, 0, 1)