Snap-To Functions

This group of API functions provide the capabilities available in the Snap-To tool.

ComputeMinClearanceDistance(*args)

Compute the minimum clearance distance for the specified geometry

SnapParm(*args)

Snap the specified Parm to input target minimum clearance distance

Details

openvsp.ComputeMinClearanceDistance(*args)[source]

Compute the minimum clearance distance for the specified geometry

fid = AddGeom( "FUSELAGE", "" )             # Add Fuselage

pid = AddGeom( "POD", "" )                     # Add Pod

x = GetParm( pid, "X_Rel_Location", "XForm" )

SetParmVal( x, 3.0 )

Update()

min_dist = ComputeMinClearanceDistance( pid, SET_ALL )

# The Pod was moved clear of the Fuselage, so there is a real gap between
# them.  Sliding it back into the Fuselage has to close that gap.
assert min_dist > 0.0, "ComputeMinClearanceDistance reports no clearance between separated Geoms"

SetParmVal( x, 0.0 )

Update()

assert ComputeMinClearanceDistance( pid, SET_ALL ) < min_dist, "ComputeMinClearanceDistance did not close as the Geoms came together"
Parameters:
  • [in] – geom_id string Geom ID

  • [in] – set int Collision set enum (i.e. SET_ALL)

  • [in] – useMode bool Flag determine if mode is used instead of sets

  • [in] – modeID string ID of Mode to use

Return type:

float

Returns:

double Minimum clearance distance

openvsp.SnapParm(*args)[source]

Snap the specified Parm to input target minimum clearance distance

#Add Geoms
fid = AddGeom( "FUSELAGE", "" )             # Add Fuselage

pid = AddGeom( "POD", "" )                     # Add Pod

x = GetParm( pid, "X_Rel_Location", "XForm" )

SetParmVal( x, 3.0 )

Update()

min_dist = SnapParm( x, 0.1, True, SET_ALL )

Update()

# Snapping moves the Parm until the clearance reaches the target, so the Parm
# has to have moved and the clearance has to end up where it was asked for.
assert abs( GetParmVal( x ) - 3.0 ) > 1e-9, "SnapParm did not move the Parm"
assert abs( ComputeMinClearanceDistance( pid, SET_ALL ) - 0.1 ) < 1e-4, "SnapParm did not reach the target clearance"
assert abs( min_dist - ComputeMinClearanceDistance( pid, SET_ALL ) ) < 1e-4, "SnapParm reported a clearance it did not reach"
Parameters:
  • [in] – parm_id string Parm ID

  • [in] – target_min_dist double Target minimum clearance distance

  • [in] – inc_flag bool Direction indication flag. If true, upper parm limit is used and direction is set to positive

  • [in] – set int Collision set enum (i.e. SET_ALL)

  • [in] – useMode bool Flag determine if mode is used instead of sets

  • [in] – modeID string ID of Mode to use

Return type:

float

Returns:

double Minimum clearance distance