Forum

#1 2016-09-16 10:49:18

Eniara
New member

python scritping ReferenceNode

Hi ! I'm student and i'm new in script. I just want to import, in reference, an asset. Here i script with python.
I succeed to import the asset, but the prefix is present. The Doc Guerilla explain that is possible to don't create this prefix, with example:

>>> from guerilla import Modifier
>>> with Modifier() as mod:
...     n = mod.createnode('geom')
...     # assume objPath1 is the path of an OBJ
...     refNode, topNodes = mod.createref('foo', objPath1, n, {'prefixnodes':False,'containschildren':True})

I know i can just write the name and the object path for the createref. The option and the constrains chlidren are not compulsory.
But when i try, it doesn't work. Someone can help me to understand please ? This my script:

import guerilla

#recuperation du nom du fichier
fileName = guerilla.Document().filename
fileNameSpt = fileName.split("\\")

nameSpt = fileNameSpt[-1].split("_")
name = nameSpt[0] + "_" + nameSpt[1] + "_" + nameSpt[2]

#importer le file (.abc)
pathAssetAbc = "Y:/Decharge/02_PROD/04_LIBRARY/ABC/ASSET/"
from guerilla import Document, Modifier
with Modifier() as mod:
    refNode, topNodes = mod.createref(name, pathAssetAbc + name + "_MODE_A_PUBLISH.abc", {'prefixnodes':False})


When i execute it, the console say:
Traceback (most recent call last):
  File "<string>", line 14, in <module>
  File "c:\program files\guerilla render\python\guerilla.py", line 328, in createref
    ref, roots = self._mod.createref(name, filename, parent._lua if parent else None, toLua (options), nohostrefs)
AttributeError: 'dict' object has no attribute '_lua'

the line 14 is this one: refNode, topNodes = mod.createref(name, pathAssetAbc + name + "_MODE_A_PUBLISH.abc", {'prefixnodes':False})

Thanks !

Last edited by Eniara (2016-09-16 10:49:37)

Offline

 

#2 2016-09-16 12:49:44

hulud
Guerilla dev, the guy to hug

Re: python scritping ReferenceNode

Dear Eniara,

You forgot the third parameter, the scene node into which you want to load the reference. Use Document() for the root node or create a node with the command mod.createnode('nodeName').

node = Document()
refNode, topNodes = mod.createref(name, pathAssetAbc + name + "_MODE_A_PUBLISH.abc", node, {'prefixnodes':False})

node = mod.createnode('nodeName')
refNode, topNodes = mod.createref(name, pathAssetAbc + name + "_MODE_A_PUBLISH.abc", node, {'prefixnodes':False})


Cyril 'Hulud' Corvazier
Guerilla developer
http://www.mercs-eng.com

Offline

 

#3 2016-09-16 14:38:47

Eniara
New member

Re: python scritping ReferenceNode

Dear Hulud,

It's working !!!! Thank you a lot !!
I believe the scene node is not mandatory if i want the ref in the root. Thanks.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2008 PunBB