How to automatic select top surface of a cylinder...

How to automatic select top surface of a cylinder...

Rui_Ramos
Advocate Advocate
1,028 Views
7 Replies
Message 1 of 8

How to automatic select top surface of a cylinder...

Rui_Ramos
Advocate
Advocate

Hello Guys,

I wounder if somenone could help me out here please.!!

how to automatic select  top surface of a cylinder by macro or command?

 

thanks in advance

have a nice Day

 

Rui

0 Likes
Accepted solutions (2)
1,029 Views
7 Replies
Replies (7)
Message 2 of 8

Yogesh.Mohite
Alumni
Alumni

Hi @Rui_Ramos,

 

Thanks for raising your query PowerMill forum.

 

The similar question was asked before by one of PowerMill user and his query was solved, please follow this forum link.

 


Yogesh Mohite
Message 3 of 8

kukelyk
Advisor
Advisor
Hi, is it a simple model, or are there a model with some boss features? Is the top of the cylinder flat? Could You provide some sample?
Message 4 of 8

Rui_Ramos
Advocate
Advocate

Hello,

its a very simple model with a flat top and bottom, very basic .

 

0 Likes
Message 5 of 8

kukelyk
Advisor
Advisor
Accepted solution

Try this:

DRAW LEVEL ALL
BLANK UNDO
EDIT BLOCKTYPE BOX
EDIT BLOCK COORDINATE WORKPLANE
EDIT BLOCK RESETLIMIT "0"
EDIT BLOCK ALL UNLOCK
EDIT BLOCK LIMITTYPE MODEL
VIEW MODEL ; SHADE RESTORE
VIEW MODEL ; WIREFRAME OFF
GRAPHICS LOCK
STRING firstmodelname = FOLDER('model')[0].name
EDIT MODEL $firstmodelname SELECT FLAT
BLANK EXCEPT
//a sík felületek ID-it kirakjuk egy külső file-ba
//pront flat surfaces' ID to a temp file
STRING tempfile = "C:\temp\macrotemp.tmp"
DELETE FILE $tempfile
DIALOGS MESSAGE OFF
ECHO OFF DCPDEBUG UNTRACE COMMAND ACCEPT
TRACEFILE OPEN $tempfile
SIZE MODEL
TRACEFILE CLOSE
DIALOGS ERROR OFF
FILE CLOSE infile
DIALOGS MESSAGE ON
DIALOGS ERROR On

//majd visszaolvassuk egy listába
//reread file to a list
STRING LIST tempfilecontent = {}
FILE OPEN $tempfile FOR READ AS infile
FILE READ $tempfilecontent FROM infile
FILE CLOSE infile 
BOOL feluletek = 0
STRING LIST id_lista = {}
//make a new list without header
FOREACH line IN $tempfilecontent {
	IF size(tokens($line)) > 3 AND position($line, $firstmodelname) != -1 {
		$feluletek = 1
	}
	IF $feluletek {
		IF length($line) > 2 {
			INT k = add_last($id_lista, tokens($line)[0])
		}
	}
}


EDIT MODEL ALL DESELECT ALL
//calculate bounding box for each surface
REAL LIST $Z_s = {}

FOREACH id IN $id_lista {
	STRING mycmd = "EDIT MODEL '" + $firstmodelname + "'  SELECT '"+ $id + "'"
	DOCOMMAND $mycmd
	EDIT BLOCK RESET
	INT K = add_last($Z_s, $Block.Limits.ZMax)
}
BLANK UNDO
EDIT MODEL ALL DESELECT ALL
//seek for the biggest value
INT i = 0
REAL maxZ = max($Z_s)
WHILE $i < size($id_lista) {
	IF compare( $Z_s[$i] , $maxZ, 0.001)  {
		STRING mycmd = "EDIT MODEL '" + $firstmodelname + "'  SELECT '"+ $id_lista[$i] + "'"
		DOCOMMAND $mycmd
		GRAPHICS UNLOCK
		RETURN
	}
	$i = $i + 1
}

(there is no filtering for cylinder top..)

Message 6 of 8

Rui_Ramos
Advocate
Advocate

worked great!! thanks a lot!!

I just forgot one thing,

can it be done to the last model in folder?

I would be very apreciated if you could help me out one more time.

 

 

 

 

0 Likes
Message 7 of 8

kukelyk
Advisor
Advisor
Accepted solution

Try with:

STRING lastmodelname = FOLDER('model')[size(FOLDER('model'))-1].name

and replace all $firstmodelname to $lastmodelname 

Message 8 of 8

Rui_Ramos
Advocate
Advocate

Fantastic..!!

Thank you very much!!

 

Have a Nice Day....

Rui

0 Likes