Background3D Functions

This group of functions is used to work with 3D background images.

AddBackground3D()

Add a Background3D to model

GetNumBackground3Ds()

Get Number of Background3D's in a model

GetAllBackground3Ds()

Get id's of all Background3Ds in model

ShowAllBackground3Ds()

Show all Background3Ds in model

HideAllBackground3Ds()

Hide all Background3Ds in model

DelAllBackground3Ds()

Delete all Background3Ds in model

DelBackground3D(id)

Delete specific Background3D frommodel

GetAllBackground3DRelativePaths()

Get relative paths to all Background3D images in model.

GetAllBackground3DAbsolutePaths()

Get absolute paths to all Background3D images in model.

GetBackground3DRelativePath(id)

Get relative path to specified Background3D's image.

GetBackground3DAbsolutePath(id)

Get absolute path to specified Background3D's image.

SetBackground3DRelativePath(id, fname)

Set relative path to specified Background3D's image.

SetBackground3DAbsolutePath(id, fname)

Set absolute path to specified Background3D's image.

Details

openvsp.AddBackground3D()[source]

Add a Background3D to model

nbg = GetNumBackground3Ds()

# Add Background3D
bg_id = AddBackground3D()

if GetNumBackground3Ds() != nbg + 1 :
    print( "ERROR: AddBackground3D" )
    assert False, "ERROR: AddBackground3D"

DelBackground3D( bg_id )
Return type:

string

Returns:

string ID for added Background3D

openvsp.GetNumBackground3Ds()[source]

Get Number of Background3D’s in a model

nbg = GetNumBackground3Ds()

# Add Background3D
bg_id = AddBackground3D()

if GetNumBackground3Ds() != nbg + 1 :
    print( "ERROR: AddBackground3D" )
    assert False, "ERROR: AddBackground3D"

DelBackground3D( bg_id )
Return type:

int

Returns:

int Number of Background3D’s in model

openvsp.GetAllBackground3Ds()[source]

Get id’s of all Background3Ds in model

nbg = GetNumBackground3Ds()

# Add Background3D
AddBackground3D()
AddBackground3D()
AddBackground3D()

if GetNumBackground3Ds() != nbg + 3 :
    print( "ERROR: AddBackground3D" )
    assert False, "ERROR: AddBackground3D"

bg_array = GetAllBackground3Ds()

for n in range( len( bg_array ) ):
    print( bg_array[n] )

DelAllBackground3Ds()
Return type:

std::vector< std::string,std::allocator< std::string > >

Returns:

vector<string> Vector of Background3D IDs

openvsp.ShowAllBackground3Ds()[source]

Show all Background3Ds in model

# Add Background3D
AddBackground3D()
AddBackground3D()
AddBackground3D()

assert GetNumBackground3Ds() == 3, "the three Background3Ds were not all added"
assert len( GetAllBackground3Ds() ) == 3, "the three Background3Ds were not all added"

ShowAllBackground3Ds()

DelAllBackground3Ds()

assert GetNumBackground3Ds() == 0, "DelAllBackground3Ds left something behind"
assert len( GetAllBackground3Ds() ) == 0, "DelAllBackground3Ds left something behind"
openvsp.HideAllBackground3Ds()[source]

Hide all Background3Ds in model

# Add Background3D
AddBackground3D()
AddBackground3D()
AddBackground3D()

assert GetNumBackground3Ds() == 3, "the three Background3Ds were not all added"
assert len( GetAllBackground3Ds() ) == 3, "the three Background3Ds were not all added"

HideAllBackground3Ds()

DelAllBackground3Ds()

assert GetNumBackground3Ds() == 0, "DelAllBackground3Ds left something behind"
assert len( GetAllBackground3Ds() ) == 0, "DelAllBackground3Ds left something behind"
openvsp.DelAllBackground3Ds()[source]

Delete all Background3Ds in model

# Add Background3D
AddBackground3D()
AddBackground3D()
AddBackground3D()

DelAllBackground3Ds()

nbg = GetNumBackground3Ds()

if nbg != 0 :
    print( "ERROR: DelAllBackground3Ds" )
    assert False, "ERROR: DelAllBackground3Ds"
openvsp.DelBackground3D(id)[source]

Delete specific Background3D frommodel

# Add Background3D
AddBackground3D()
bg_id = AddBackground3D()
AddBackground3D()

nbg = GetNumBackground3Ds()

DelBackground3D( bg_id )

if GetNumBackground3Ds() != nbg -1 :
    print( "ERROR: DelBackground3D" )
    assert False, "ERROR: DelBackground3D"
Parameters:

[in] – id string Background3D ID to delete

openvsp.GetAllBackground3DRelativePaths()[source]

Get relative paths to all Background3D images in model. Note that path is relative to the model’s *.vsp3 file. Consequently, if a file has not yet been saved or assigned a file name, the relative path is meaningless.

# Add Background3D
AddBackground3D()
AddBackground3D()
AddBackground3D()

bg_file_array = GetAllBackground3DRelativePaths()
assert len( bg_file_array ) > 0, "GetAllBackground3DRelativePaths returned nothing"

for n in range( len( bg_file_array ) ):
    print( bg_file_array[n] )

DelAllBackground3Ds()
Return type:

std::vector< std::string,std::allocator< std::string > >

Returns:

vector<string> Vector of relative paths to Background3D image files

openvsp.GetAllBackground3DAbsolutePaths()[source]

Get absolute paths to all Background3D images in model.

# Add Background3D
AddBackground3D()
AddBackground3D()
AddBackground3D()

bg_file_array = GetAllBackground3DAbsolutePaths()
assert len( bg_file_array ) > 0, "GetAllBackground3DAbsolutePaths returned nothing"

for n in range( len( bg_file_array ) ):
    print( bg_file_array[n] )

DelAllBackground3Ds()
Return type:

std::vector< std::string,std::allocator< std::string > >

Returns:

vector<string> Vector of absolute paths to Background3D image files

openvsp.GetBackground3DRelativePath(id)[source]

Get relative path to specified Background3D’s image. Note that path is relative to the model’s *.vsp3 file. Consequently, if a file has not yet been saved or assigned a file name, the relative path is meaningless.

# Add Background3D
bg_id = AddBackground3D()

SetBackground3DRelativePath( bg_id, "front.png" )
bg_file = GetBackground3DRelativePath( bg_id )
assert len( bg_file ) > 0, "GetBackground3DRelativePath returned nothing"

print( bg_file )

DelAllBackground3Ds()
Parameters:

[in] – id string Background3D ID

Return type:

string

Returns:

string Relative path to Background3D image file

openvsp.GetBackground3DAbsolutePath(id)[source]

Get absolute path to specified Background3D’s image.

# Add Background3D
bg_id = AddBackground3D()

SetBackground3DAbsolutePath( bg_id, "/user/me/vsp_work/front.png" )
bg_file = GetBackground3DAbsolutePath( bg_id )
assert len( bg_file ) > 0, "GetBackground3DAbsolutePath returned nothing"

print( bg_file )

DelAllBackground3Ds()
Parameters:

[in] – id string Background3D ID

Return type:

string

Returns:

string Absolute path to Background3D image file

openvsp.SetBackground3DRelativePath(id, fname)[source]

Set relative path to specified Background3D’s image. Note that path is relative to the model’s *.vsp3 file. Consequently, if a file has not yet been saved or assigned a file name, the relative path is meaningless.

# Add Background3D
bg_id = AddBackground3D()

SetBackground3DRelativePath( bg_id, "front.png" )
assert GetBackground3DRelativePath( bg_id ) == "front.png", "SetBackground3DRelativePath did not take"

bg_file = GetBackground3DRelativePath( bg_id )

print( bg_file )

DelAllBackground3Ds()
Parameters:
  • [in] – id string Background3D ID

  • [in] – fname string Relative path to Background3D image file

openvsp.SetBackground3DAbsolutePath(id, fname)[source]

Set absolute path to specified Background3D’s image.

# Add Background3D
bg_id = AddBackground3D()

SetBackground3DAbsolutePath( bg_id, "front.png" )
bg_file = GetBackground3DAbsolutePath( bg_id )

print( bg_file )

# A relative name is resolved against the working directory, so the path that
# comes back ends with the name that was set.
assert bg_file.endswith( "front.png" ), "SetBackground3DAbsolutePath did not take"

DelAllBackground3Ds()
Parameters:
  • [in] – id string Background3D ID

  • [in] – fname string Absolute path to Background3D image file