View Full Version : Get bone mesh item

06-09-2014, 01:40 PM
In lscript I would do this:

theMesh = Scene.firstselect();

The below doesn't seem to work in python:

lwII = lwsdk.LWInterfaceInfo()
objSel = lwII.selected_items()

Is my python methodology incorrect?

06-09-2014, 02:40 PM
Think you need to look at lwsdk.LWItemInfo which has first, next etc. and also lwsdk.LWObjectInfo, the SDK example for LWInterfaceInfo would be a good starting place. I haven't tried any layout python scripts yet so would need to run a few tests before I could give much help.


06-09-2014, 03:15 PM
Ok I'll comb through those pages again. I did this morning and everything coming back through my print statement was still the bone.

06-09-2014, 03:37 PM
Quick test, may help, left the prints in to see what's happening via the console



#! /usr/bin/env python
# -*- Mode: Python -*-
# -*- coding: ascii -*-

import sys
import lwsdk

__author__ = ""
__date__ = "9 June 2014 "
__copyright__ = ""
__version__ = "1.0"
__maintainer__ = ""
__email__ = ""
__status__ = "Example"
__lwver__ = "11"

class select_object(lwsdk.IGeneric):
def __init__(self, context):
super(select_object, self).__init__()

# LWGeneric -------------------------------------------
def process(self, ga):
name = ga.commandArguments(ga.data)
result = ga.evaluate(ga.data, "EditObjects" )
print ( "Result of Command", result)

intinfo = lwsdk.LWInterfaceInfo()
selobj = intinfo.selected_items()
t = intinfo.curTime
iteminfo = lwsdk.LWItemInfo()
for i in selobj:
type = iteminfo.type(i)
print ("Selected object ", type)
name = iteminfo.name(i)
print ("Selected object name ", name)
return lwsdk.AFUNC_OK

ServerTagInfo = [
( "Python Select Object", lwsdk.SRVTAG_USERNAME | lwsdk.LANGID_USENGLISH ),
( "Select Object", lwsdk.SRVTAG_BUTTONNAME | lwsdk.LANGID_USENGLISH ),
( "Utilities/Python", lwsdk.SRVTAG_MENU | lwsdk.LANGID_USENGLISH )

ServerRecord = { lwsdk.GenericFactory("LW_PySelectObject", select_object) : ServerTagInfo }

06-09-2014, 04:28 PM
Thanks, I'll have to look at your code carefully cuz it looks like I'm doing the same thing you're doing. I must have an error that I'm just not seeing.

06-09-2014, 04:55 PM
It doesn't make sense to me but I created a new variable to hold lwsdk.LWInterfaceInfo() and when I used that to get the mesh item it worked.

I'm using lwsdk.LWInterfaceInfo() further up in my code and it worked there.