md

package
v0.0.0-...-4946764 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package md contains the Go wrappers for calls to Model Derivative API https://developer.autodesk.com/en/docs/model-derivative/v2/overview/

The API offers the following features:

  • Translate designs into SVF format for rendering in the Forge Viewer.
  • Extract design metadata and integrate it into your app. Including object hierarchy trees, model views, and object properties, - such as materials, density and volume, etc.
  • Extract selected parts of a design and export the set of geometries in OBJ format.
  • Create different-sized thumbnails from design files.
  • Translate designs into different formats, such as STL and OBJ.

Index

Constants

View Source
const (
	DefaultModelDerivativePath = "/modelderivative/v2/designdata"
)

Variables

View Source
var (
	// TranslationSVFPreset specifies the minimum necessary for translating a generic (single file, uncompressed)
	// model into svf.
	TranslationSVFPreset = TranslationParams{
		Output: OutputSpec{
			Destination: DestSpec{"us"},
			Formats: []FormatSpec{
				FormatSpec{
					"svf",
					[]string{"2d", "3d"},
				},
			},
		},
	}
)

Functions

This section is empty.

Types

type ChildrenSpec

type ChildrenSpec struct {
	GUID     string `json:"guid,omitempty"`
	Role     string `json:"role,omitempty"`
	MIME     string `json:"mime,omitempty"`
	URN      string `json:"urn,omitempty"`
	Progress string `json:"progress,omitempty"`
	Status   string `json:"status,omitempty"`
}

type DerivativeSpec

type DerivativeSpec struct {
	Name         string         `json:"name,omitempty"`
	HasThumbnail bool           `json:"hasThumbnail,string,omitempty"`
	Role         string         `json:"role,omitempty"`
	Status       string         `json:"status,omitempty"`
	Progress     string         `json:"progress,omitempty"`
	Children     []ChildrenSpec `json:"children,omitempty"`
}

type DestSpec

type DestSpec struct {
	Region string `json:"region,omitempty"`
}

DestSpec is used within OutputSpecs and is useful when specifying the region for translation results

type FormatSpec

type FormatSpec struct {
	Type  string   `json:"type"`
	Views []string `json:"views,omitempty"`
}

FormatSpec is used within OutputSpecs and should be used when specifying the expected format and views (2d or/and 3d)

type ManifestResult

type ManifestResult struct {
	Type         string           `json:"type,omitempty"`
	HasThumbnail bool             `json:"hasThumbnail,string,omitempty"`
	Status       string           `json:"status,omitempty"`
	Progress     string           `json:"progress,omitempty"`
	Region       string           `json:"region,omitempty"`
	URN          string           `json:"urn,omitempty"`
	Derivatives  []DerivativeSpec `json:"derivatives,omitempty"`
}

type MetadataResult

type MetadataResult struct {
	Data MetadataSpec `json:"data",omitempty`
}

type MetadataSpec

type MetadataSpec struct {
	Type     string     `json:"type",omitempty`
	Metadata []ViewSpec `json:"metadata",omitempty`
}

type ModelDerivativeAPI

type ModelDerivativeAPI struct {
	Client  *clientapi.Client
	APIPath string
}

API struct holds all paths necessary to access Model Derivative API

func NewAPIWithCredentials

func NewAPIWithCredentials(ClientID string, ClientSecret string) ModelDerivativeAPI

NewAPIWithCredentials returns a Model Derivative API client with default configurations

func (ModelDerivativeAPI) GetManifest

func (api ModelDerivativeAPI) GetManifest(urn string) (result ManifestResult, err error)

func (ModelDerivativeAPI) GetMetadata

func (api ModelDerivativeAPI) GetMetadata(urn string) (result MetadataResult, err error)

func (ModelDerivativeAPI) GetObjectTree

func (api ModelDerivativeAPI) GetObjectTree(urn string, viewID string) (status int, result TreeResult, err error)

func (ModelDerivativeAPI) GetPropertiesObject

func (api ModelDerivativeAPI) GetPropertiesObject(urn string, viewID string) (result PropertiesResult, err error)

func (ModelDerivativeAPI) GetPropertiesStream

func (api ModelDerivativeAPI) GetPropertiesStream(urn string, viewID string) (status int, result io.ReadCloser, err error)

func (ModelDerivativeAPI) GetThumbnail

func (api ModelDerivativeAPI) GetThumbnail(urn string) (reader io.ReadCloser, err error)

func (ModelDerivativeAPI) TranslateToSVF

func (api ModelDerivativeAPI) TranslateToSVF(objectID string) (result TranslationResult, err error)

TranslateToSVF is a helper function that will use the TranslationSVFPreset for translating into svf a given ObjectID. It will also take care of converting objectID into Base64 (URL Safe) encoded URN.

func (ModelDerivativeAPI) TranslateWithParams

func (api ModelDerivativeAPI) TranslateWithParams(params TranslationParams) (result TranslationResult, err error)

TranslateWithParams triggers translation job with settings specified in given TranslationParams

type ObjectSpec

type ObjectSpec struct {
	ObjectID   int64  `json:"objectid"`
	Name       string `json:"name"`
	ExternalID string `json:"externalId"`
	Properties json.RawMessage
}

type OutputSpec

type OutputSpec struct {
	Destination DestSpec     `json:"destination,omitempty"`
	Formats     []FormatSpec `json:"formats"`
}

OutputSpec reflects data found upon creation translation job and receiving translation job status

type PropertiesResult

type PropertiesResult struct {
	Data   PropertiesSpec `json:"data",omitempty`
	Result string         `json:"result",omitempty`
}

type PropertiesSpec

type PropertiesSpec struct {
	Type       string       `json:"type"`
	Collection []ObjectSpec `json:"collection"`
}

type TranslationInput

type TranslationInput struct {
	URN           string  `json:"urn"`
	CompressedURN *bool   `json:"compressedUrn,omitempty"`
	RootFileName  *string `json:"rootFileName,omitempty"`
}

type TranslationParams

type TranslationParams struct {
	Input  TranslationInput `json:"input"`
	Output OutputSpec       `json:"output"`
}

TranslationParams is used when specifying the translation jobs

type TranslationResult

type TranslationResult struct {
	Result       string `json:"result"`
	URN          string `json:"urn"`
	AcceptedJobs struct {
		Output OutputSpec `json:"output"`
	}
}

TranslationResult reflects data received upon successful creation of translation job

type TreeNodeSpec

type TreeNodeSpec struct {
	ObjectID int64          `json:"objectid",omitempty`
	Name     string         `json:"name",omitempty`
	Objects  []TreeNodeSpec `json:"objects",omitempty`
}

type TreeResult

type TreeResult struct {
	Data TreeSpec `json:"data",omitempty`
}

type TreeSpec

type TreeSpec struct {
	Type    string         `json:"type",omitempty`
	Objects []TreeNodeSpec `json:"objects",omitempty`
}

type ViewSpec

type ViewSpec struct {
	Name string `json:"name",omitempty`
	Role string `json:"role",omitempty`
	Guid string `json:"guid",omitempty`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL