Calc Geo Extents: Difference between revisions
From Macros Wiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
{| | {| | ||
|- | |- | ||
|! calculate the extents in X and Y of the selected geometry | |! calculate the extents in X and Y of the selected geometry | ||
|- | |- | ||
| | | | ||
| Line 37: | Line 37: | ||
| | | | ||
|- | |- | ||
|! when we get the data for each feature, we can | |! when we get the data for each feature, we can | ||
|- | |- | ||
|! get the xyz values in either the world cs or | |! get the xyz values in either the world cs or | ||
|- | |- | ||
|! the cs local to each feature. | |! the cs local to each feature. | ||
|- | |- | ||
|trace on | |trace on | ||
| Line 49: | Line 49: | ||
| | | | ||
|- | |- | ||
|! get the number of selected features | |! get the number of selected features | ||
|- | |- | ||
|! ----------------------------------- | |! ----------------------------------- | ||
|- | |- | ||
| | | | ||
| Line 61: | Line 61: | ||
| | | | ||
|- | |- | ||
|! loop through all selected features and | |! loop through all selected features and | ||
|- | |- | ||
|! update the min/max xy data according | |! update the min/max xy data according | ||
|- | |- | ||
|! to each features xy data | |! to each features xy data | ||
|- | |- | ||
|! -------------------------------------- | |! -------------------------------------- | ||
|- | |- | ||
| | | | ||
| Line 75: | Line 75: | ||
| | | | ||
|} | |} | ||
:! get the feature reference number for | :! get the feature reference number for | ||
:! the 'i'th selected feature | :! the 'i'th selected feature | ||
:! ------------------------------------ | :! ------------------------------------ | ||
{| | {| | ||
| | | | ||
| Line 87: | Line 87: | ||
| | | | ||
|} | |} | ||
:! get the feature type for this feature | :! get the feature type for this feature | ||
:! ------------------------------------- | :! ------------------------------------- | ||
{| | {| | ||
| | | | ||
| Line 110: | Line 110: | ||
| | | | ||
|- | |- | ||
|! display the results | |! display the results | ||
|- | |- | ||
|! ------------------- | |! ------------------- | ||
|- | |- | ||
| | | | ||
Revision as of 14:31, 29 July 2010
| ! calculate the extents in X and Y of the selected geometry |
| a1$ = "This macro will calculate the extents" |
| a2$ = "(min/max X and Y) of the selected geometry" |
| message "%a1$\n%a2$" |
| check part_open, "You must have a part open to run this macro" |
| check part_mill, "This macro is not designed for turned parts" |
| global xmin, ymin, xmax,ymax ! these variables are used by all macros |
| global ics |
| xmin=99999 |
| ymin=99999 |
| xmax=-99999 |
| ymax=-99999 |
| ! when we get the data for each feature, we can |
| ! get the xyz values in either the world cs or |
| ! the cs local to each feature. |
| trace on |
| ics = 1 ! world cs (local cs would be zero) |
| ! get the number of selected features |
| ! ----------------------------------- |
| get_num_feat_selected inum |
| if inum<1 then stop "No geometry selected" |
| ! loop through all selected features and |
| ! update the min/max xy data according |
| ! to each features xy data |
| ! -------------------------------------- |
| for i=1 to inum |
- ! get the feature reference number for
- ! the 'i'th selected feature
- ! ------------------------------------
- get_selected_geo_ref i, iref
- ! get the feature type for this feature
- ! -------------------------------------
- get_feat_type iref, itype
|}
| debug i, iref, itype |
- if itype=1 then call "Check_Point_Data.mac"
- if itype=2 then call "Check_Line_Data.mac"
- if itype=3 then call "Check_Circle_Data.mac"
- if itype=4 then call "Check_Arc_Data.mac"
| next i |
| ! display the results |
| ! ------------------- |
| xmin$=format$(xmin,"####0.0###") |
| ymin$=format$(ymin,"####0.0###") |
| xmax$=format$(xmax,"####0.0###") |
| ymax$=format$(ymax,"####0.0###") |
| msg$="X Min = %xmin$\n" |
| msg$=msg$+"Y Min = %ymin$\n" |
| msg$=msg$+"X Max = %xmax$\n" |
| msg$=msg$+"X Max = %ymax$" |
| message msg$, "Geometry Extents" |
| yesno "Draw a rectangle around the geometry ?", iyesno |
| if iyesno=0 then stop "Finished" |
| contour[ |
| start xmin, ymin |
| line xmax, ymin |
| line xmax, ymax |
| line xmin, ymax |
| line xmin, ymin |
| ] |
| redraw |
| stop "Finished" |