Jump to content
Developer Wiki and Function Reference Links ×

Auto generate dimensions script issue


Emily L

Recommended Posts

Here is my script for auto-generate the dimension to the object info. However, it only works for the objects that are totally 0, 90, and 180 degrees, or the dimensions are off due to the angle. Is there anyone who can help me with my script? Thanks very much. 

 

------------------------------------------------------------------------------------------------------------------------------------------------

 

PROCEDURE InputData3D;

CONST
    RECD = 'PanelSizes';

VAR
            h:HANDLE;
            W,T,D:REAL;
            W1,T1,D1:STRING;
BEGIN
            h:=FSActLayer;
REPEAT
            Get3DInfo(h, T, W, D);    


            W1:=Num2Strf(W);
            T1:=Num2Strf(T);
            D1:=Num2Strf(D);

            
            SetRecord(h,RECD);
            SetRField(h,RECD,'Width',W1);
            SetRField(h,RECD,'Height',T1);
            SetRField(h,RECD,'Depth',D1);

            
            h:=NextSobj(h);

UNTIL(h=NIL)

END;
RUN(InputData3D);

 

 

Link to comment

Hi Emily,

   To get an "orthogonal" 3D size, you must first unrotate a 3D object before using Get3DInfo(). I modified your script to do just that. I also merged your Num2StrF() statements into the SetRField() statements to shorten the script a little. 

 

PROCEDURE InputData3D;
{ Get 3D_Size and attach or modify a "PanelSizes" record with the info. }
{ 11 Jan 2018 - Emily L. - Original script works for unrotated 3D objects only. }
{ 11 Jan 2018 - R.Mullin - Unrotate objects before measurement, then re-rotate them. }
CONST
    RECD = 'PanelSizes';
VAR
	h :HANDLE;
	W, T, D :REAL;
	Xcen, Ycen, Zcen :REAL;
	xRot, yRot, zRot :REAL;
	isMirrored :BOOLEAN; 
BEGIN
	h := FSActLayer;
	REPEAT
		if Get3DOrientation(h, xRot, yRot, zRot, isMirrored) then begin
			Get3DCntr(h, Xcen, Ycen, Zcen);		{ get 3D center }
			
			{ unrotate 3D object }
			Set3DRot(h,  0, 0, -zRot,  Xcen, Ycen, Zcen);
			Set3DRot(h,  0, -yRot, 0,  Xcen, Ycen, Zcen);
			Set3DRot(h,  -xRot, 0, 0,  Xcen, Ycen, Zcen);
			
			Get3DInfo(h, T, W, D);	{ get 3D size }
			
			{ re-rotate 3D object }
			Set3DRot(h,  xRot, 0, 0,  Xcen, Ycen, Zcen);
			Set3DRot(h,  0, yRot, 0,  Xcen, Ycen, Zcen);
			Set3DRot(H,  0, 0, zRot,  Xcen, Ycen, Zcen);
	
			{ store data in attached record. }
			SetRecord(h, RECD);
			SetRField(h, RECD, 'Width', Num2Strf(W));
			SetRField(h, RECD, 'Height', Num2Strf(T));
			SetRField(h, RECD, 'Depth', Num2Strf(D));
		end;		{ if Get3DOrientation }
		
		h := NextSObj(h);	
	UNTIL(h=NIL)
END;
RUN(InputData3D);

 

HTH,

Raymond

 

 

Edited by MullinRJ
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...