IMEdit prismatic smoothing macro

Started by prehistory, April 10, 2009, 12:08:38 PM

Previous topic - Next topic

prehistory

This is one of my all-time favorite macros, and is actually the first macro I ever wrote in PolyWorks.  If you work on fairly prismatic models like car bodies, aerospace parts, or any other surface that you know should be "smooth", this macro will remove scanner noise and micro deviation while leaving the overall shape.  The trick is that we first anchor a Bezier patch over the area.  The macro then fits the patch to the polygonal model, rigidly, then fits the polygonal model back to the Bezier patch.  Numerous lines are commented out in this version, and you can tweak it to fit the patch with more control points, or smooth the area again after fitting, etc.

Version "4.0"

DECLARE dist 4
DECLARE proj 1
DECLARE units

CONFIG UNITS GET (units)

IF $units == "Meters"
    SET dist .05
    SET proj .02
    ENDIF

IF $units == "Millimeters"
    SET dist 4
    SET proj 2
ENDIF

IF $units == "Inches"
    SET dist .16
    SET proj .04
    ENDIF


#MACRO PAUSE ("Defeature Rhomboid", "Pick 4 corners (diagonal last) to defeature a low-curvature area, then R-click")
TREEVIEW SELECT NONE
EDIT SURFACE ANCHOR_RECTANGULAR 4_POINTS

WINDOW SHOW_CONTEXTUAL_PARAMETERS ( "Off" )


EDIT SURFACE CONTROL_POINTS DOUBLE NB_OF_ROWS ( "On", $dist )
EDIT SURFACE CONTROL_POINTS DOUBLE NB_OF_COLUMNS ( "On",$dist )
#EDIT SURFACE CONTROL_POINTS DOUBLE NB_OF_ROWS ( "On",$dist )
#EDIT SURFACE CONTROL_POINTS DOUBLE NB_OF_COLUMNS ( "On",$dist )

WINDOW REFRESH NOW
EDIT SURFACE FIT ( "1/4", $dist, 5 )
WINDOW REFRESH NOW

#SELECT VERTICES USING_SURFACES ABOVE_AND_BELOW ( 4 )
EDIT VERTICES PROJECT ONTO_SURFACE ALL_VERTICES ( $proj, 0.0 )
VIEW VISIBILITY OBJECTS HIDE
EDIT OBJECT DELETE
SELECT NONE
#SELECT TRIANGLES FROM_VERTICES
#SELECT GROW (3)
WINDOW REFRESH NOW
#MACRO PAUSE ("Final Smoothing", "Defeatured area will now be blended with surrounding polys")
#EDIT VERTICES SMOOTH ( .08, .8, 12, 75.0 )