cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Assemble component to Part level reference

SOLVED
Highlighted
Amethyst

Assemble component to Part level reference

Hi All,

 

I want to assemble a part with part level reference.For example assembly structure

A.ASM

X Axis

Y Axis

Z Axis

B.PRT

BX Axis

BY Axis

BZ Axis

C.PRT

CX Axis

CY Axis

CZ Axis

 

Now I want to assemble C.PRT in A.ASM using reference of B.PRT (ie BX Axis, BY Axis, BZ Axis) 

using toolkit. Kindly throw some light on this 

 

Regards,

Manjunath S

Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions

Re: Assemble component to Part level reference

@Ketan_Lalcheta  the issue has been resolved, the problem is with the line

err = ProAsmcompConstraintsSet (NULL, &nzsl_feature, nzsl_consts);

where NULL to be replaced with Top level assembly path.

Thanks for the effort and highlighting few points.

6 REPLIES 6

Re: Assemble component to Part level reference

Refer sample code from below path:

 

[protoolkit load point]/protkdoc/samples/UgAsmcompConstraint_c.html

 

You just need to provide reference of C.PRT as ProAsmcompconstraintAsmreferenceSet and B.Prt as ProAsmcompconstraintCompreferenceSet.

 

-HIH

Ketan

Re: Assemble component to Part level reference

@Ketan_Lalcheta  I use the same code

	ProError err;
	ProMdl part_asm;
	ProMdldata mdl_data;
	char name[PRO_NAME_SIZE];

	int i;
	ProMdl asm_mdl ;
	ProSolid nzsl_sld;
	ProAsmcomp nzsl_feature;
	ProAsmcompconstraint* nzsl_consts;
	ProAsmcompconstraint nzsl_const;
	ProName asm_dtms[3], comp_dtms[3];
	ProModelitem asm_dtm , comp_dtm , sub_part;
	ProAsmcomppath comp_path, new_comp_path;
	ProSelection asm_sel, comp_sel;
	ProIdTable c_id_table;

	err = ProAsmcompMdlGet(p_feature,&part_asm);
	err = ProMdlDataGet(part_asm, &mdl_data);
	ProWstringToString(name,mdl_data.name);
		
	if(strcmp(name, "MD40090D4000_SYM" ) == 0)
	{
	c_id_table [0] = p_feature->id;
	c_id_table [1] = -1;
	err = ProMdlRetrieve(L"TPM027.PRT",(ProMdlType)PRO_MDL_PART,(ProMdl*)&nzsl_sld);
	err = ProMdlCurrentGet(&asm_mdl);
			
	err = ProAsmcomppathInit((ProSolid)part_asm,c_id_table,0,&new_comp_path);

	ProStringToWstring (asm_dtms [0], "B");
	ProStringToWstring (comp_dtms [0], "B");
	ProStringToWstring (asm_dtms [1], "C");
	ProStringToWstring (comp_dtms [1], "C");

	err = ProAsmcompAssemble(NULL,nzsl_sld,intial_pos,&nzsl_feature);
	
	err = ProArrayAlloc (0, sizeof (ProAsmcompconstraint), 1, (ProArray*)&nzsl_consts);
	
	for (i=0; i<=1 ; i++)
	{
		if (i == 0)
		{
			err = ProModelitemByNameInit(part_asm,PRO_AXIS,asm_dtms[i], &asm_dtm);
			err = ProModelitemByNameInit((ProMdl*)nzsl_sld,PRO_AXIS,comp_dtms[i], &comp_dtm);
		}

		else
		{
			err = ProModelitemByNameInit(part_asm,PRO_SURFACE,asm_dtms[i], &asm_dtm);
			err = ProModelitemByNameInit((ProMdl*)nzsl_sld,PRO_SURFACE,comp_dtms[i], &comp_dtm);
		}
	
			//err = ProModelitemByNameInit(part_asm,PRO_SURFACE,asm_dtms[i], &asm_dtm);
			//err = ProModelitemByNameInit((ProMdl*)nzsl_sld,PRO_SURFACE,comp_dtms[i], &comp_dtm);
	
	//err = ProAsmcomppathInit((ProSolid)asm_mdl,c_id_table,0,&comp_path);
		
	err = ProSelectionAlloc (&new_comp_path, &asm_dtm, &asm_sel);
	err = ProSelectionAlloc (NULL, &comp_dtm, &comp_sel);
	
	err = ProAsmcompconstraintAlloc (&nzsl_const);

	err = ProAsmcompconstraintTypeSet(nzsl_const,PRO_ASM_ALIGN);

	err = ProAsmcompconstraintAsmreferenceSet (nzsl_const, asm_sel, PRO_DATUM_SIDE_YELLOW);
			
	err = ProAsmcompconstraintCompreferenceSet (nzsl_const, comp_sel, PRO_DATUM_SIDE_YELLOW);

	if (i == 1)
	{
		err = ProAsmcompconstraintCompreferenceSet (nzsl_const, comp_sel, PRO_DATUM_SIDE_RED);
	}

	err = ProArrayObjectAdd ((ProArray*)&nzsl_consts, -1, 1, &nzsl_const);

	err = ProAsmcompConstraintsSet (NULL, &nzsl_feature, nzsl_consts);

	err = ProSolidRegenerate((ProSolid)asm_mdl,PRO_REGEN_ALLOW_CONFIRM);
	}
		return PRO_TK_ABORT;
	}

but when the process is completed i found the assembly reference were not retrieved 

Re: Assemble component to Part level reference

Hi

 

Below could be your points to verify or try with :

 

1. ProAsmcompConstraintsSet() and ProSolidRegenerate() should be out of for loop and should be done once only.

 

2. Selection objects got using API ProSelectionAlloc() might not be proper.

 

3. Do below to check whether those objects are correct or not:
A. Try to verify selection objects using API ProSelectionVerify() and check whether this API returns PRO_TK_NO_ERROR or not.
B. Observe whether selection objects get highlighted properly in Creo model or not (use API ProSelectionHighlight())

4. I feel that those selection objects are not proper. If so, first of all make sure ProModelitemByNameInit() gives proper model item objects and API returns PRO_TK_NO_ERROR. I presume both CAD models have already a datum plane it means surface having name as C ans Axis having name as B.

 

5. In API ProModelitemByNameInit() for model item of component, you have directly used proMdl as nzsl_sld. It is not correct. This is just the model before assembling.
What you should use is something different. Using ProAsmcompAssemble(), you got nzsl_feature as ProAsmcomp. Use this ProAsmComp into API ProAsmcompMdlGet() and output mdl should be used into ProModelitemByNameInit.

 

6. Same way model input to ProModelitemByNameInit() for model item of assembly might not be proper. You need to find out proper MDL. If you are planning to assemble with B.prt from main.asm, first of all find ASM COMP PATH for B.prt using ProAsmcomppathInit() and use API ProAsmcomppathMdlGet() to have proper model handle.

 

-HIH

Ketan

Re: Assemble component to Part level reference

@Ketan_Lalcheta the same code works fine if the assembly reference were given but when the part reference were provided the its not accepting.

Re: Assemble component to Part level reference

Then some issue with modelitem init... Check for last 2 points I mentioned

Re: Assemble component to Part level reference

@Ketan_Lalcheta  the issue has been resolved, the problem is with the line

err = ProAsmcompConstraintsSet (NULL, &nzsl_feature, nzsl_consts);

where NULL to be replaced with Top level assembly path.

Thanks for the effort and highlighting few points.