Calc Geo Extents: Difference between revisions

From Macros Wiki
Jump to navigationJump to search
ConnerO (talk | contribs)
No edit summary
ConnerO (talk | contribs)
No edit summary
 
Line 3: Line 3:
|!    calculate the extents in X and Y of the selected geometry
|!    calculate the extents in X and Y of the selected geometry
|-
|-
|
| 
|-
|-
|a1$ = "This macro will calculate the extents"
|a1$ = "This macro will calculate the extents"
Line 9: Line 9:
|a2$ = "(min/max X and Y) of the selected geometry"
|a2$ = "(min/max X and Y) of the selected geometry"
|-
|-
|
| 
|-
|-
|message "%a1$\n%a2$"
|message "%a1$\n%a2$"
|-
|-
|
| 
|-
|-
|check part_open, "You must have a part open to run this macro"
|check part_open, "You must have a part open to run this macro"
Line 19: Line 19:
|check part_mill, "This macro is not designed for turned parts"
|check part_mill, "This macro is not designed for turned parts"
|-
|-
|
| 
|-
|-
|global xmin, ymin, xmax,ymax ! these variables are used by all macros
|global xmin, ymin, xmax,ymax ! these variables are used by all macros
Line 25: Line 25:
|global ics
|global ics
|-
|-
|
| 
|-
|-
|xmin=99999
|xmin=99999
Line 35: Line 35:
|ymax=-99999
|ymax=-99999
|-
|-
|
| 
|-
|-
|!     when we get the data for each feature, we can
|!     when we get the data for each feature, we can
Line 47: Line 47:
|ics = 1      ! world cs (local cs would be zero)
|ics = 1      ! world cs (local cs would be zero)
|-
|-
|
| 
|-
|-
|!     get the number of selected features
|!     get the number of selected features
Line 53: Line 53:
|!     -----------------------------------
|!     -----------------------------------
|-
|-
|
| 
|-
|-
|get_num_feat_selected inum
|get_num_feat_selected inum
Line 59: Line 59:
|if inum<1 then stop "No geometry selected"
|if inum<1 then stop "No geometry selected"
|-
|-
|
|&nbsp;
|-
|-
|!&nbsp;&nbsp;&nbsp;  loop through all selected features and
|!&nbsp;&nbsp;&nbsp;  loop through all selected features and
Line 69: Line 69:
|!&nbsp;&nbsp;&nbsp;  --------------------------------------
|!&nbsp;&nbsp;&nbsp;  --------------------------------------
|-
|-
|
|&nbsp;
|-
|-
|for i=1 to inum
|for i=1 to inum
Line 80: Line 80:


:!&nbsp;&nbsp;&nbsp;  ------------------------------------
:!&nbsp;&nbsp;&nbsp;  ------------------------------------
{|
<br>
|
|}
:get_selected_geo_ref i, iref
:get_selected_geo_ref i, iref
{|
<br>
|
|}
:!&nbsp;&nbsp;&nbsp;  get the feature type for this feature
:!&nbsp;&nbsp;&nbsp;  get the feature type for this feature


:!&nbsp;&nbsp;&nbsp;  -------------------------------------
:!&nbsp;&nbsp;&nbsp;  -------------------------------------
{|
<br>
|
|}
:get_feat_type iref, itype
:get_feat_type iref, itype
|}
<br>
{|
debug i, iref, itype
|debug i, iref, itype
<br>
|}
:if itype=1 then call "[[Check_Point_Data|Check_Point_Data.mac]]"
:if itype=1 then call "[[Check_Point_Data|Check_Point_Data.mac]]"


Line 108: Line 101:
|next i
|next i
|-
|-
|
|&nbsp;
|-
|-
|!&nbsp;&nbsp;&nbsp;  display the results
|!&nbsp;&nbsp;&nbsp;  display the results
Line 114: Line 107:
|!&nbsp;&nbsp;&nbsp;  -------------------
|!&nbsp;&nbsp;&nbsp;  -------------------
|-
|-
|
|&nbsp;
|-
|-
|xmin$=format$(xmin,"####0.0###")
|xmin$=format$(xmin,"####0.0###")
Line 124: Line 117:
|ymax$=format$(ymax,"####0.0###")
|ymax$=format$(ymax,"####0.0###")
|-
|-
|
|&nbsp;
|-
|-
|msg$="X Min = %xmin$\n"
|msg$="X Min = %xmin$\n"
Line 134: Line 127:
|msg$=msg$+"X Max = %ymax$"
|msg$=msg$+"X Max = %ymax$"
|-
|-
|
|&nbsp;
|-
|-
|message msg$, "Geometry Extents"
|message msg$, "Geometry Extents"
|-
|-
|
|&nbsp;
|-
|-
|yesno "Draw a rectangle around the geometry ?", iyesno
|yesno "Draw a rectangle around the geometry ?", iyesno
|-
|-
|
|&nbsp;
|-
|-
|if iyesno=0 then stop "Finished"
|if iyesno=0 then stop "Finished"
|-
|-
|
|&nbsp;
|-
|-
|contour[
|contour[
Line 162: Line 155:
|]
|]
|-
|-
|
|&nbsp;
|-
|-
|redraw
|redraw
|-
|-
|
|&nbsp;
|-
|-
|stop "Finished"
|stop "Finished"
|-
|-
|}
|}

Latest revision as of 20:42, 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"