Announcement

Collapse
No announcement yet.

Populating Dropdown from Graphics HUB

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Populating Dropdown from Graphics HUB

    I want to populate a drop down of geometry (from the geometry tab) in template wizard. So if i have 3d objects saved i can just drop them in the geometry folder and have the template refresh the drop down list from the graphics hub.

    Has anyone done something like this before?

    Thanks in advance,
    Shotski

  • #2
    Yes, this is possible using the Viz GH REST Server. If you have this installed I can send a sample script. Basically you get a directory listing as XML from the REST server, which you then need to parse and send to the dropdown as a list of items. Works great.

    Comment


    • #3
      Thanks for the help

      Comment


      • #4
        Originally Posted by arc View Post
        Yes, this is possible using the Viz GH REST Server. If you have this installed I can send a sample script. Basically you get a directory listing as XML from the REST server, which you then need to parse and send to the dropdown as a list of items. Works great.
        Hi ARC, please share the code.

        Best regards

        Comment


        • #5
          Sorry I stepped away for a bit... Here's a quick example. It returns a list of items in the GH directory.


          Code:
          ' > ghRestServer is the hostname or IP plus port number of GH Rest server, like 127.0.0.1:19398:
          ' > user and pw are the login credentials for the GH
          ' > directoryUuid is the ID of the directory. Get this from the file info tab of the directory properties window in Artist
          ' > assetType is one of MATERIAL/GEOM/IMAGE/SCENE.
          
          
          
          ' --------- In this example, on form init it gets the directory listing and applies it to a combox box called "dropdown".
          ' You should do some error checking to make sure you have a valid list of items though.
          
          Sub InitForm
              listings = getGhListing("VizGhRest:19398", "Guest", "", "0FEC2A8B-0917-4BFC-B08E2E4BC8EF057E", "GEOM")
              dropdown.UTF8items = listings
          End Sub
          
          
          
          Function getGhListing(ghRestServer, user, pw, directoryUuid, assetType)
          
            '-------- get the directory listing (xml) from Graphic Hub REST server
          
            Set http = CreateObject("msxml2.ServerXMLHTTP")
            http.setTimeouts 1000,1000,1000,1000
          
            dim feedXml,url
          
            url = "http://" & ghRestServer & "/files/" & directoryUuid & "?term=" & assetType
          
            On Error Resume Next
               http.open "GET", url, False, user, pw
               http.send
               If Err.Number <> 0 Then
                  getGhListing = "Error: " & Err.Description
                  Exit Function
               End If
            On Error Goto 0
          
            feedXml = http.responseText
            set xmlDoc = CreateObject("Msxml2.DOMDocument")
          
            ' ------ parse the directory listing xml, add every entry/title to output
          
            if xmlDoc.loadXml(feedXml) then
               xmlDoc.setProperty "SelectionNamespaces", "xmlns:atom='http://www.w3.org/2005/Atom'"
               Set titles = xmlDoc.SelectNodes("//atom:entry/atom:title")
               dim output
               for each title in titles
                  output = output & title.text & VbCrLf
               next
               getGhListing = output
            else
               getGhListing = "Error: failed to parse xml"
               Exit Function
            end if
          
          End Function
          Last edited by arc; 04-03-2018, 02:22 PM.

          Comment


          • #6
            Thanks! looks nice and clean

            Comment

            Working...
            X