Skip to main content
13-Aquamarine
Sep 27, 2023 12:54 PM UTC
Solved

get left and bottom most edges from drawing view

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

 

 

 

CHASEONHOAnswer
18-Opal
Oct 4, 2023 2:19 AM UTC

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;
}

7 replies

14-Alexandrite
Sep 27, 2023 4:30 PM UTC

Have a look at ProDrawingViewOutlineGet function.

Translate
Aravind9813-AquamarineAuthor
13-Aquamarine
Sep 28, 2023 8:50 AM UTC

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

Translate
RPN
18-Opal
Sep 28, 2023 1:02 PM UTC

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

Translate
CHASEONHO18-OpalAnswer
18-Opal
Oct 4, 2023 2:19 AM UTC

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;
}
Translate
RPN
18-Opal
Oct 4, 2023 8:15 AM UTC

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"
Translate