Skip to content
Sol Kim edited this page Apr 2, 2020 · 57 revisions

Welcome to the medic wiki!(日本語

Contents


Build

  • Required: SCons

  • Clone the Medic repository and update submodules.

$ git clone https://github.com/sol-ansano-kim/medic
$ cd medic
$ git submodule update --init
  • Run the scons command.
$ scons with-maya=[Version or Maya install directory]

windows

$ scons with-maya=[Version or Maya install directory] mscver=[Visual Studio Version]

Environment

Use pre-built package

Add the extracted package directory to MAYA_MODULE_PATH

e.g.

$ export MAYA_MODULE_PATH=$MAYA_MODULE_PATH:/User/MEDICUSR/medicPacakge

Setup manually

Libs

Append the lib directory path to the environment variable.

os directory environment variable
windows bin/[MAYAVERSION] PATH
linux lib/[MAYAVERSION] LD_LIBRARY_PATH
osx lib/[MAYAVERSION] DYLD_LIBRARY_PATH

e.g.

$ export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/User/MEDICUSR/medic/release/lib/2018

Python

Add "py/[MAYAVERSION]" to PYTHONPATH.

e.g.

$ export PYTHONPATH=$PYTHONPATH:/User/MEDICUSR/medic/release/py/2018

Plugins

Set plug-ins search paths. MEDIC_KARTE_PATH, MEDIC_TESTER_PATH

e.g.

$ export MEDIC_KARTE_PATH=$MEDIC_KARTE_PATH:/User/MEDICUSR/medic/release/plugins/2018/Karte
$ export MEDIC_TESTER_PATH=$MEDIC_TESTER_PATH:/User/MEDICUSR/medic/release/plugins/2018/Tester

Usage

Launch medic GUI

import medicUI
medicUI.Show()

Use medic module.

import medic

Get a karte.

manager = medic.PluginManager()
# manager.karte(<karte name>)
karte_all = manager.karte("All")

# from v1.4.0
# medic.GetKarte(<karte nane>)
karte_all = medic.GetKarte("All")

Create a Visitor.

visitor = medic.Visitor()

Check single Tester

#tester = manager.tester(<tester name>)
tester = manager.tester("NGon")
visitor.test(karte_all, tester)
reports = visitor.report(tester)

# from v1.4.0
# medic.GetTester(<tester name>)
tester = medic.GetTester("NGon")
visitor.visitTester(karte_all, tester)

Check all Testers in the Karte.

visitor.testAll(karte_all)
reports = visitor.reportAll()

# from v1.4.0
visitor.visitKarte(karte_all)

Karte

Write Karte in python dictionary style, and save as '.karte' extension file.

{
    "Name": "All",
    "Description": "All testers",
    "Testers": ["*"],
}

The list of testers can be set by tester names and wildcards.

e.g. ["FaceAssigned", "HasLayer", "Non*"]


Custom Tester

Pass the custom plugin directory to 'plugin-path' when you build with scons.

$ scons plugin-path=myPluginDir

C++ Tester

Include "medic/pluginapi.h" and inherit the MdTester class.
And define Create() which returns an instance of the custom tester class.

#include "medic/pluginapi.h"

class CustomTester : public MdTester
{
    std::string Name();
    std::string Description();
    bool Match(MdNode *node);
    MdReport *test(MdNode *node);
};

MEDIC_PLUGIN_API MdTester *Create()
{
    return new CustomTester();
}

Name() and Description() define the name and description, respectively.
Match() determines whether the node is a test target.
test() runs the check and returns MdReport if there was a problem, otherwise returns nullptr.

To enable the fix of Tester, override IsFixable() and fix().

...
    bool IsFixable();
    bool fix(MdReport *report, MdParamContainer *params);
...

fix() returns true if it fixed successfully.

To define the parameterContainer for fix(), override GetParameters().

...
    MdParamContainer *GetParameters();
...

Python Tester

Inherit the PyTester class, and define Create() which returns an instance of the custom tester class.

import medic
from Maya import OpenMaya

class CustomTester(medic.PyTester):
    def __init__(self):
        super(CustomTester, self).__init__()

def Create():
    return CustomTester()

Name() and Description() define the name and description, respectively.
Match() determines whether the node is a test target.
test() runs the check and returns PyReport if there was a problem, otherwise returns None.

  • (str) Name()
  • (str) Description()
  • (bool) Match(PyNode)
  • (PyReport) test(PyNode)
    def Name(self):
        return "CustomTester"
    def Description(self):
        return "A Custom Tester"
    def Match(self, node):
        return node.object().hasFn(OpenMaya.MFn.kDagNode)
    def test(self, node):
        #return None
        return medic.PyReport(node)

To enable the fix of Tester, override IsFixable() and fix().

  • (bool) IsFixable()
  • (bool) fix(PyReport, ParamContainer)

fix() returns true if it fixed successfully.

To define the parameterContainer for fix(), override GetParameters().

  • (ParamContainer) GetParameters()