Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

#Quixel Megascans Bridge API ####Updated: Aug 19th, 2016

We have developed an API to fetch information from the Bridge. The following is an initial list of endpoints any software will be able to retrieve information from.

  • Megascans repository path
  • Zip folder paths
  • Get all assets (folder and json path)
  • Get selected assets (folder and json path)
  • Search results (folder and json path) against a string
  • Register tool

We will grow this list as we get feedback and requests.

The Bridge will run a web server to which all tools can connect to. Querying one of the above listed endpoints will result in a json response.

###Example: (Tested in maya)

import urllib2
response = urllib2.urlopen('http://localhost:28241/GetAllAssets/')
print response.read()

The response in this case will be a json listing folder and json paths to the associated assets. The asset jsons kept by the Bridge will always be representative of the content the user has already downloaded.

##Megascans Bridge API

###RegisterSendTo This web request should be run at startup to ensure communication with the Megascans Bridge. Users will be able to send assets to the registered tool from the Bridge. User will specify tool and the port to which the bridge will connect to. Example:

import urllib2
response = urllib2.urlopen('http://localhost:28241/RegisterSendTo/Maya:12345')
print response.read()
response.close()

import urllib2
response = urllib2.urlopen('http://localhost:28241/RegisterSendTo/Modo:23456)
print response.read()
response.close()

###GetMegascansFolder Returns the path to the Megascans assets folder. Example:

import urllib2
response = urllib2.urlopen('http://localhost:28241/GetMegascansFolder/')
print response.read()
response.close()

Response:
{
  "folder": "C:\\Users\\Quixel\\Megascans Assets"
}

###GetZipFolderPaths Returns all the Zip folder paths. Example:

import urllib2
response = urllib2.urlopen('http://localhost:28241/GetZipFolderPaths/')
print response.read()
response.close()

Response:
{
  "folders": [
    "C:\\Users\\Quixel\\Zip Assets"
  ]
}

###GetSelectedAsset Returns a json with folder and json path to selected assets in the Megascans Bridge. Example:

import urllib2
response = urllib2.urlopen('http://localhost:28241/GetSelectedAsset/')
print response.read()
response.close()

Response:
{
  "assets": [
    {
      "folder": "C:\\Users\\Quixel\\Megascans Assets\\surface\\_ogioH0_surface_ms",
      "json": "C:\\Users\\Quixel\\Megascans Assets\\surface\\_ogioH0_surface_ms\\ogioH0.json"
    },
    {
      "folder": "C:\\Users\\Quixel\\Megascans Assets\\surface\\_ogios0_surface_ms",
      "json": "C:\\Users\\Quixel\\Megascans Assets\\surface\\_ogios0_surface_ms\\ogios0.json"
    },
    {
      "folder": "C:\\Users\\Quixel\\Megascans Assets\\surface\\_olslp0_surface_ms",
      "json": "C:\\Users\\Quixel\\Megascans Assets\\surface\\_olslp0_surface_ms\\olslp0.json"
    }
  ]
}

###GetAllAssets Returns a json with folder and json path to all assets in the Megascans Bridge. Example:

import urllib2
response = urllib2.urlopen('http://localhost:28241/GetAllAssets/')
print response.read()
response.close()

Response:
{
  "assets": [
    {
      "folder": "C:\\Users\\Quixel\\Megascans Assets\\3d\\Rock_Sandstone_pjhio_3d_ms",
      "json": "C:\\Users\\Quixel\\Megascans Assets\\3d\\Rock_Sandstone_pjhio_3d_ms\\pjhio.json"
    },
    {
      "folder": "C:\\Users\\Quixel\\Megascans Assets\\3d\\Rock_Sandstone_pjhuB_3d_ms",
      "json": "C:\\Users\\Quixel\\Megascans Assets\\3d\\Rock_Sandstone_pjhuB_3d_ms\\pjhuB.json"
    },
    {
      "folder": "C:\\Users\\Quixel\\Megascans Assets\\surface\\_ogioH0_surface_ms",
      "json": "C:\\Users\\Quixel\\Megascans Assets\\surface\\_ogioH0_surface_ms\\ogioH0.json"
    },
    {
      "folder": "C:\\Users\\Quixel\\Megascans Assets\\surface\\_ogios0_surface_ms",
      "json": "C:\\Users\\Quixel\\Megascans Assets\\surface\\_ogios0_surface_ms\\ogios0.json"
    },
    {
      "folder": "C:\\Users\\Quixel\\Megascans Assets\\surface\\_olslp0_surface_ms",
      "json": "C:\\Users\\Quixel\\Megascans Assets\\surface\\_olslp0_surface_ms\\olslp0.json"
    },
    {
      "folder": "C:\\Users\\Quixel\\Megascans Assets\\surface\\_pehpA0_surface_ms",
      "json": "C:\\Users\\Quixel\\Megascans Assets\\surface\\_pehpA0_surface_ms\\pehpA0.json"
    }
]
}

###Search Returns a json with folder and json path for searched assets in the Megascans Bridge. Example:

import urllib2
response = urllib2.urlopen('http://localhost:28241/Search/pehpA')
print response.read()
response.close()

Response:
{
  "assets": [
    {
      "folder": "C:\\Users\\Quixel\\Megascans Assets\\surface\\_pehpA0_surface_ms",
      "json": "C:\\Users\\Quixel\\Megascans Assets\\surface\\_pehpA0_surface_ms\\pehpA0.json"
    }
  ]
}

Example:

import urllib2
response = urllib2.urlopen('http://localhost:28241/Search/brown')
print response.read()
response.close()

Response:
{
  "assets": [
    {
      "folder": "C:\\Users\\Quixel\\Megascans Assets\\surface\\_pjEuY0_surface_ms",
      "json": "C:\\Users\\Quixel\\Megascans Assets\\surface\\_pjEuY0_surface_ms\\pjEuY0.json"
    },
    {
      "folder": "C:\\Users\\Quixel\\Megascans Assets\\surface\\_pjEv00_surface_ms",
      "json": "C:\\Users\\Quixel\\Megascans Assets\\surface\\_pjEv00_surface_ms\\pjEv00.json"
    },
    {
      "folder": "C:\\Users\\Quixel\\Megascans Assets\\surface\\_pkbfr0_surface_ms",
      "json": "C:\\Users\\Quixel\\Megascans Assets\\surface\\_pkbfr0_surface_ms\\pkbfr0.json"
    }
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment