# UnstructGrid: Set Vector Settings on a Loaded Model

The vector result can be configured to make a better visual appearance of your result data, for instance settings such as scaling and coloring.

This example will show the vector result on the model, and set some vector settings for demonstration.

- Set the relative scaling to 0.2.
- Set single vector color to yellow.

The demo model file (10x10x10.vtf) contains a simple geometry and a vector result.

    void TutorialRunnerMainWindow::setVectorSettings()
    {
        //--------------------------------------------------------------------------
        // Load an UnstructGridModel from file and set a vector result
        // Apply some vector settings
        //--------------------------------------------------------------------------

        // Create the model and data source
        cee::PtrRef<cee::ug::UnstructGridModel> ugModel = new cee::ug::UnstructGridModel();
        cee::PtrRef<cee::ug::DataSourceVTF> source = new cee::ug::DataSourceVTF(42);

        // Open the vtf file
        cee::Str vtfFile = TutorialUtils::testDataDir() + "10x10x10.vtf";
        if (!source->open(vtfFile))
        {
            // VTF file not found
            return;
        }

        // Add the data source to the model
        ugModel->setDataSource(source.get());

        // Set the first state as current
        std::vector<cee::ug::StateInfo> stateInfos = source->directory()->stateInfos();
        int stateId = stateInfos[0].id();
        ugModel->modelSpec().setStateId(stateId);

        // Show the vector result on the model
        std::vector<cee::ug::ResultInfo> vectorResultInfos = source->directory()->vectorResultInfos();
        int vectorId = vectorResultInfos[0].id();
        ugModel->modelSpec().setVectorResultId(vectorId);

        // Set vector visible for all parts
        cee::ug::PartSettingsIterator it(ugModel.get());
        while (it.hasNext())
        {
            cee::ug::PartSettings* partSettings = it.next();
            partSettings->setVectorsVisible(true);
        }

        // Get vector settings for the current vector result
        cee::ug::VectorSettings* settings = ugModel->vectorSettings(vectorId);

        // Set relative scaling to 0.2
        settings->setScaleFactor(cee::ug::VectorSettings::RELATIVE_SCALING, 0.2);

        // Set single vector coloring to yellow for all vectors
        settings->setSingleVectorColor(cee::Color3f(1.0, 1.0, 0.0));

        // Add model to view. Ensure that old models are removed first
        cee::vis::View* gcView = getTutorialView();
        gcView->removeAllModels();
        gcView->addModel(ugModel.get());

        ugModel->updateVisualization();

        cee::BoundingBox bb = gcView->boundingBox();
        gcView->camera().fitView(bb, cee::Vec3d(0, 0, -1), cee::Vec3d(0, 1, 0));
        gcView->camera().inputHandler()->setRotationPoint(bb.center());

        gcView->requestRedraw();
    }

Conversation saved
HOOPSY BETA

### Hello! I'm HOOPSY

Your multilingual generative AI assistant for documentation. Ask me anything about HOOPS Envision for Desktop in your own language, or choose a sample question below to start a conversation:

What is HOOPS Envision for Desktop?
What are the latest release notes for HOOPS Envision for Desktop?
How do I start evaluating HOOPS Envision for Desktop?
How do I write my first sample application?
How can I get assistance?

HOOPSY may store conversations according to OpenAI's policy. Responses may not always be accurate.

HOOPSY is thinking...