Skip to main content
13-Aquamarine
September 27, 2023
Solved

get left and bottom most edges from drawing view

  • September 27, 2023
  • 2 replies
  • 2605 views

Hi all.

 

In Creo toolkit how to take left and bottom most edges from the drawing view(not a model view)?

if anyone knows pls help me

 

Thanks

 

 

 

Best answer by CHASEONHO

1. Visit all views using ProDrawingViewVisit

2. Use ProDrawingViewSheetGet to determine the sheet number of the visited view

3. Compare positions using ProDrawingViewOutlineGet for the same sheet number

Below is sample code to get the bottom left view for recent sheets.

static int curSheet = -1;
ProError userViewVisit(ProDrawing drw,ProView view,ProError status,ProAppData data)
{
	int viewSheet = -1;
	status = ProDrawingViewSheetGet(drw,view,&viewSheet);
	if(curSheet == viewSheet)
	{
		ProName viewName;
		status = ProViewNameGet(*(ProView*)data,viewName);	
		if(status!=PRO_TK_NO_ERROR)	*(ProView*)data = view;
		else
		{
			Pro3dPnt VeiwSize_1[2],VeiwSize_2[2];
			status = ProDrawingViewOutlineGet(drw,view,VeiwSize_1);
			status = ProDrawingViewOutlineGet(drw,*(ProView*)data,VeiwSize_2);
			if(VeiwSize_1[0][0] < VeiwSize_2[0][0] || VeiwSize_1[0][1] < VeiwSize_2[0][1])
			{
				*(ProView*)data = view;
			}
		}		
	}
	return PRO_TK_NO_ERROR;
}
ProError userTest()
{
	ProMdl drw;
	ProError status = ProMdlCurrentGet(&drw);
	if(status != PRO_TK_NO_ERROR)	return status;
	ProMdlType type;
	status = ProMdlTypeGet(drw,&type);
	if(type != PRO_MDL_DRAWING)	return PRO_TK_BAD_CONTEXT;
	status = ProDrawingCurrentSheetGet((ProDrawing)drw,&curSheet);
	ProView leftBottomView = NULL;
	status = ProDrawingViewVisit((ProDrawing)drw,(ProViewVisitAction)userViewVisit , NULL,&leftBottomView);
	if(leftBottomView != NULL)
	{
		ProName viewName;
		status = ProViewNameGet(leftBottomView,viewName);
		ProMessageDisplay(MSGFIL,"USER %0ls",viewName);
	}
	return PRO_TK_NO_ERROR;
}

2 replies

14-Alexandrite
September 27, 2023

Have a look at ProDrawingViewOutlineGet function.

Aravind9813-AquamarineAuthor
13-Aquamarine
September 28, 2023

yes but with this i couldn't find the left most drawing view

RPN
18-Opal
September 28, 2023

What about to visit each view on a sheet and compare 🤪

CHASEONHO18-OpalAnswer
18-Opal
October 4, 2023

1. Visit all views using ProDrawingViewVisit

2. Use ProDrawingViewSheetGet to determine the sheet number of the visited view

3. Compare positions using ProDrawingViewOutlineGet for the same sheet number

Below is sample code to get the bottom left view for recent sheets.

static int curSheet = -1;
ProError userViewVisit(ProDrawing drw,ProView view,ProError status,ProAppData data)
{
	int viewSheet = -1;
	status = ProDrawingViewSheetGet(drw,view,&viewSheet);
	if(curSheet == viewSheet)
	{
		ProName viewName;
		status = ProViewNameGet(*(ProView*)data,viewName);	
		if(status!=PRO_TK_NO_ERROR)	*(ProView*)data = view;
		else
		{
			Pro3dPnt VeiwSize_1[2],VeiwSize_2[2];
			status = ProDrawingViewOutlineGet(drw,view,VeiwSize_1);
			status = ProDrawingViewOutlineGet(drw,*(ProView*)data,VeiwSize_2);
			if(VeiwSize_1[0][0] < VeiwSize_2[0][0] || VeiwSize_1[0][1] < VeiwSize_2[0][1])
			{
				*(ProView*)data = view;
			}
		}		
	}
	return PRO_TK_NO_ERROR;
}
ProError userTest()
{
	ProMdl drw;
	ProError status = ProMdlCurrentGet(&drw);
	if(status != PRO_TK_NO_ERROR)	return status;
	ProMdlType type;
	status = ProMdlTypeGet(drw,&type);
	if(type != PRO_MDL_DRAWING)	return PRO_TK_BAD_CONTEXT;
	status = ProDrawingCurrentSheetGet((ProDrawing)drw,&curSheet);
	ProView leftBottomView = NULL;
	status = ProDrawingViewVisit((ProDrawing)drw,(ProViewVisitAction)userViewVisit , NULL,&leftBottomView);
	if(leftBottomView != NULL)
	{
		ProName viewName;
		status = ProViewNameGet(leftBottomView,viewName);
		ProMessageDisplay(MSGFIL,"USER %0ls",viewName);
	}
	return PRO_TK_NO_ERROR;
}
RPN
18-Opal
October 4, 2023

What about this 😂

 

set xvalList [list]
foreach view [ps_view list] {
 ps_view outline $view outLineObj
 lappend xvalList [list $view [outLineObj cget -x1] ]
 lappend xvalList [list $view [outLineObj cget -x2] ]
}
set minItem [lindex [lsort -incr -index 1 $xvalList ] 0]
lassign $minItem ViewName xVal
Debug "The View $ViewName is topleft with x $xVal"