Visual Components' Community

New Thinking for Factory Simulation
Welcome to Visual Components' Community Sign in | Help
in Search

Change the color of a part using Python script

Last post pe, loka 31 2008 13:29 by RicardoVelez. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • ke, elo 20 2008 14:21

    • Manuela
    • Top 10 Contributor
    • Joined on pe, helmi 22 2008
    • Posts 75

    Change the color of a part using Python script

     In order to change the color of a part the script for the workstation needs to be modified:
    Add the following lines to the code

        part.NodeMaterial = comp.Material
        part.MaterialInheritance = VC_MATERIAL_FORCE_INHERIT_NODE

    ”part” is handle to part
    ”comp” is the component where this script resides

    The method works for all the material which are defined for the workstations. Further information can be found in the VC_Node reference guide for python.

    If other materials or colors should be used, it is required to add a new color-parameter, which will be used then to assign certain colors.

    Filed under: ,
  • pe, loka 31 2008 13:29 In reply to

    Re: Change the color of a part using Python script

    The Python script mentioned above only works for changing Node material, not geometry features. Changing the material of a geometry feature is very computationally expensive, and not recommended, as it need to rebuild the entire node tree structure every time is updated. Changing the node material is very fast and simple, using the VC_MATERIAL_FORCE_INHERIT_NODE.

    For example, let’s say you want to create a status light for a machine:

    -          Green – On or working

    -          Yellow or Orange - Warning

    -          Red – System failure or error

    The best practice on modeling this light system would be to split the geometries into links, so that all geometries would be on its own link, as it is shown in the picture.

     


    Sometimes for the node to be rendered again, you would need to execute the update command on the node.

    Ricardo Velez
    Research and Development Manager
    Filed under: ,
Page 1 of 1 (2 items)