PDA

View Full Version : How to use PCore's "Save Log" to build a LW Python reference manual



Celshader
04-05-2012, 10:02 PM
Hi, guys,

I've been :bangwall::bangwall::bangwall: for some time trying to figure out how to export the results of help() in PCore to a text file. I spent so much time trying to figure out how to use Python to do it that I completely overlooked the "Save Log" button on the lower-left-hand corner of the PCore interface. (D'oh!)

So, I figured I should write down how to do it here.


Launch PCore
type "import lwsdk" in the commandline to import the lwsdk module into PCore
change the number of Max Lines from 100 to 10000
type "help(lwsdk)" into the commandline. The help info for LWInterfaceInfo will appear.
Use the "Save Log" button to save the results of "help(lwsdk)" to a to a text file.
Click on "Clear Log" to clear the buffer.
repeat steps 4-6 to extract the help data for other lwsdk functions like LWMessageFuncs and save them to text files.


Based on the content of lwsdk.txt, these functions are available in the lwsdk Python module:



Color
ContextMenuFuncs
Control
DTBakeZone
DTDrawFuncs
DTEventParam
DTKeySelect
DTMenuCallbacks
DTMouseParam
DTToolCallbacks
DrawFuncs
DyBitfieldHint
DyChoiceHint
DyReqChoiceDesc
DyReqControlDesc
DyReqStringDesc
DyReqTextDesc
DyValCustom
DyValFVector
DyValFloat
DyValIVector
DyValInt
DyValPointer
DyValString
DynaMonitorFuncs
DynaStringHint
DynaValue
EDBoundCv
EDEdgeInfo
EDPointInfo
EDPolygonInfo
HostDisplayInfo
IChannelFactory
IChannel
ICommandSequenceFactory
ICommandSequence
ICustomObjFactory
ICustomObj
IDisplacementFactory
IDisplacement
IFactoryFuncs
IGenericFactory
IGeneric
IGizmoFuncs
IHandlerFuncs
IImageFilterFactory
IImageFilter
IInterfaceFuncs
IItemFuncs
IItemMotionFactory
IItemMotion
ILayoutToolFactory
ILayoutToolFuncs
ILayoutTool
IMasterFactory
IMaster
IObjReplacementFactory
IObjReplacement
IPlugin
IRenderFuncs
IShaderFactory
IShader
LSURFuncs
LWAnimFrameAccess
LWBackdropInfo
LWBlockIdent
LWBoneInfo
LWCHANGEFUNCS
LWCameraAccess
LWCameraEvaluationFuncs
LWCameraInfo
LWCameraRay
LWChannelAccess
LWChannelInfo
LWColorPickLocal
LWColorSpaceFuncs
LWComRing
LWCompInfo
LWComponentTimingInfo
LWCustomObjAccess
LWDisplacementAccess
LWDopetrackProxy
LWEnvelopeFuncs
LWEnvironmentAccess
LWEventNotifyPluginChange
LWFileIOFuncs
LWFileReqLocal
LWFilterAccess
LWFogInfo
LWFontListFuncs
LWFrameInfo
LWFrameTimingInfo
LWGPolMeshInfo
LWGizmo
LWGlobalPool
LWGlobalService
LWIllumination
LWImageList
LWImageLoaderLocal
LWImageProtocol
LWImageSaverLocal
LWImageUtil
LWInstancerAccess
LWInterfaceInfo
LWItemInfo
LWItemInstanceInfo
LWItemInstancerFuncs
LWItemMotionAccess
LWLMonFuncs
LWLayoutGeneric
LWLightAccess
LWLightEvaluationFuncs
LWLightInfo
LWListInfo
LWLoadState
LWMTUtilFuncs
LWMasterAccess
LWMeshEditTool
LWMeshInfo
LWMessageFuncs
LWMicropol
LWModCommand
LWMonitor
LWNameChangeData
LWNodalAccess
LWNodalMaterial
LWNodeDrawFuncs
LWNodeEditorFuncs
LWNodeFuncs
LWNodeInputFuncs
LWNodeOGLTextureOutput
LWNodeOutputFuncs
LWNodeUtilityFuncs
LWObjReplacementAccess
LWObjectFuncs
LWObjectImport
LWObjectInfo
LWPCoreConsole
LWPSBufDesc
LWPSysFuncs
LWPanAreaDesc
LWPanChoiceDesc
LWPanControlDesc
LWPanLWItemDesc
LWPanListBoxDesc
LWPanMenuDesc
LWPanMultiListBoxDesc
LWPanPopupDesc
LWPanRangeDesc
LWPanStringDesc
LWPanTextDesc
LWPanTreeDesc
LWPanXPanDesc
LWPanelMenuFuncs
LWPanels
LWPhoton
LWPixelAccess
LWPixelRGB24
LWPixelRGBA32
LWPixelRGBADBL
LWPixelRGBAFP
LWPixelRGBDBL
LWPixelRGBFP
LWPolyType
LWPolygonTypeAccess
LWPreviewFuncs
LWPreviewLight
LWPtypeWireDrawAccess
LWRasterFuncs
LWRayIllumination
LWRayTraceData
LWRootNode
LWSaveState
LWSceneConverter
LWSceneInfo
LWServerInfo
LWShaderAccess
LWShelfFuncs
LWStateQueryFuncs
LWSurfEdFuncs
LWSurfaceFuncs
LWTEXTFUNCS
LWTextureAccess
LWTextureFuncs
LWTimeInfo
LWTimer
LWToolEvent
LWToolFuncs
LWTool
LWTxtrEdFuncs
LWTxtrParamDesc
LWTxtrParamFuncs
LWVParmFuncs
LWVRayFuncs
LWValCustom
LWValFVector
LWValFloat
LWValIVector
LWValInt
LWValPointer
LWValString
LWValue
LWVertexIndexes
LWViewportInfo
LWViewportObjectAccess
LWViewportObjectCamera
LWViewportObjectMenu
LWVolumeAccess
LWVolumeSample
LWVolumetricEvaluationFuncs
LWWireDrawAccess
LWXPDrawFuncs
LWXPanelControl
LWXPanelDataDesc
LWXPanelFuncs
MeshEditOp
ModuleDescriptor
Panel
PvSample
SEApply
SEBank
SEColumn
SEVMap
SceneEditorGlobal
ServerRecord
ServerTagInfo
Vector
display_Metrics
st_LWHumanInterfaceDeviceAccess
st_LWHumanInterfaceDeviceCreateContext
st_LWHumanInterfaceDeviceHandler
st_LWHumanInterfaceHIDAccess
st_LWHumanInterfaceHIDCreateContext
st_LWHumanInterfaceHIDHandler
st_LWHumanInterfaceHIDReceiveAccess
st_LWHumanInterfaceManagerAccess
st_LWHumanInterfaceManagerHandler
st_LWHumanInterfaceTrackAccess


Here's a sample saved log after typing in "help(lwsdk.LWInterfaceInfo)":



>>> help(lwsdk.LWInterfaceInfo)
Help on class LWInterfaceInfo in module pcore:
class LWInterfaceInfo(__builtin__.object)
| Proxy of C++ PCore::LWInterfaceInfo class
|
| Methods defined here:
|
| __getattr__ lambda self, name
|
| __init__(self, *args)
| __init__(self) -> LWInterfaceInfo
| __init__(self, LWInterfaceInfo source_) -> LWInterfaceInfo
|
| __repr__ = _swig_repr(self)
|
| __setattr__ lambda self, name, value
|
| defaultItemTypeColor(self, *args)
| defaultItemTypeColor(self, LWItemType itemtype, float color, int set)
|
| itemColor(self, *args)
| itemColor(self, LWItemID item) -> int
|
| itemColorRgba(self, *args)
| itemColorRgba(self, LWItemID item, unsigned int state, float rgba)
|
| itemFlags(self, *args)
| itemFlags(self, LWItemID item) -> unsigned int
|
| itemIconScale(self, *args)
| itemIconScale(self, LWItemID item) -> float
|
| itemVis(self, *args)
| itemVis(self, LWItemID item) -> int
|
| schemaPos(self, *args)
| schemaPos(self, LWItemID item, double x, double y)
|
| selected_items(self)
| selected_items(self) -> PyObject
|
| setItemColorCustom(self, *args)
| setItemColorCustom(self, LWItemID item, double color)
|
| setItemColorIndex(self, *args)
| setItemColorIndex(self, LWItemID item, int color)
|
| valid(self)
| valid(self) -> bool
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
|
| alertLevel
| LWInterfaceInfo_alertLevel_get(LWInterfaceInfo self) -> int
|
| autoKeyCreate
| LWInterfaceInfo_autoKeyCreate_get(LWInterfaceInfo self) -> int
|
| boxThreshold
| LWInterfaceInfo_boxThreshold_get(LWInterfaceInfo self) -> int
|
| curTime
| LWInterfaceInfo_curTime_get(LWInterfaceInfo self) -> LWTime
|
| displayFlags
| LWInterfaceInfo_displayFlags_get(LWInterfaceInfo self) -> unsigned int
|
| dynaUpdate
| LWInterfaceInfo_dynaUpdate_get(LWInterfaceInfo self) -> int
|
| generalFlags
| LWInterfaceInfo_generalFlags_get(LWInterfaceInfo self) -> unsigned int
|
| previewEnd
| LWInterfaceInfo_previewEnd_get(LWInterfaceInfo self) -> LWFrame
|
| previewStart
| LWInterfaceInfo_previewStart_get(LWInterfaceInfo self) -> LWFrame
|
| previewStep
| LWInterfaceInfo_previewStep_get(LWInterfaceInfo self) -> LWFrame
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __swig_destroy__ = <built-in function delete_LWInterfaceInfo>
| delete_LWInterfaceInfo(LWInterfaceInfo self)
|
| __swig_getmethods__ = {'alertLevel': <built-in function LWInterfaceInf...
|
| __swig_setmethods__ = {'alertLevel': <built-in function LWInterfaceInf...

evenflcw
04-05-2012, 11:33 PM
Hmm... this is a good idea. For sure one could probably use python itself to process, format and create such a document. But really NT is the one that should do this (and add doc strings). But likely some kind poor bastard will do it in their place.

BigHache
04-06-2012, 12:33 AM
There's also a ton of stuff in the PCore file if you get help on that too. It's over 18k lines though and took 30 min? on my i5 to process.

Celshader
04-06-2012, 01:27 PM
There's also a ton of stuff in the PCore file if you get help on that too. It's over 18k lines though and took 30 min? on my i5 to process.

That's good to know. What should I type into PCore to get help on the PCore file? Typing "help(PCore)" and other variations did not work.

Celshader
04-06-2012, 04:19 PM
Hmm... this is a good idea. For sure one could probably use python itself to process, format and create such a document. But really NT is the one that should do this (and add doc strings). But likely some kind poor bastard will do it in their place.

I'll be that bastard... :bday:

This HTML document only contains the LWFunctions so far, but it's a start...

LightWave 11 Python Wordbook (http://dl.dropbox.com/u/9264841/forums/Newtek/LW11PythonWordbook.htm)

evenflcw
04-06-2012, 05:53 PM
Nicely done. Thanks.

BigHache
04-06-2012, 06:05 PM
Sweet, looking good Jen.

Try using all lowercase since it's case-sensitive. I have to use single quotes, looks like you don't though?


help('pcore')

Make sure to up your Max Lines to 19000, and get a sammich.

Celshader
04-06-2012, 06:51 PM
Sweet, looking good Jen.

Try using all lowercase since it's case-sensitive. I have to use single quotes, looks like you don't though?


help('pcore')

Thanks. :bowdown: It's working now.

I was using no quotes at all in-between the parentheses. PCore humored me for the other modules, but it looks like it's strict about help for 'pcore.'


Make sure to up your Max Lines to 19000, and get a sammich.

Yup. I'm letting it think about it right now in the background while I work on other stuff in the foreground.

BigHache
04-06-2012, 07:46 PM
Oh you know, I think someone posted the pcore file in the pre-release forums. Meh.

dwburman
04-07-2012, 12:32 AM
This might be a little easier to work with. ;)

http://dl.dropbox.com/u/45975558/LW11PythonWordbook3.htm

I basically put the list of names (functions?) into columns and added some CSS to make it a bit easier on the eyes. I probably took a bit too much time changing some of the structure (primarily removing formatting commands from the body and replacing them with hooks for the CSS).


It would have gone a bit faster if the < and > symbols were
search and replaced with their HTML equivalents ( &lt; and &gt; )
before HTML tags were added. :)

Celshader
04-07-2012, 11:03 AM
This might be a little easier to work with. ;)

http://dl.dropbox.com/u/45975558/LW11PythonWordbook3.htm

I basically put the list of names (functions?) into columns and added some CSS to make it a bit easier on the eyes. I probably took a bit too much time changing some of the structure (primarily removing formatting commands from the body and replacing them with hooks for the CSS).

That looks great! Thank you for sharing this.

dwburman
04-07-2012, 07:35 PM
You're welcome. Feel free to download and post it wherever. I don't know if I'll leave it in my dropbox or not. :)

BigHache
04-07-2012, 10:42 PM
Indeed, thank you both. I've started writing a pdf book, but I need more info to keep it going. This is also a great resource.

DuneBoy
04-13-2012, 07:40 PM
Building on Dana's work, I've added a 'View SDK Doc' link under all the applicable entries.

Just put the file in the SDK's html folder and now you can quickly get access to the proper SDK document which explains how the C API equivalent works.

http://dl.dropbox.com/u/13236441/Kouha/LW11PythonWordbookWSL.htm

I have the Word-to-URL list and python script (to update the html file) if anyone wants them.

ken

Celshader
04-13-2012, 07:53 PM
Building on Dana's work, I've added a 'View SDK Doc' link under all the applicable entries.

Just put the file in the SDK's html folder and now you can quickly get access to the proper SDK document which explains how the C API equivalent works.

http://dl.dropbox.com/u/13236441/Kouha/LW11PythonWordbookWSL.htm

I have the Word-to-URL list and python script (to update the html file) if anyone wants them.

ken

Thank you for posting this. This helps a lot. :thumbsup:

BigHache
10-05-2012, 08:57 AM
Definitely not trying to take away from the work that's been done, I just like this format (http://www.lawson3d.com/lwpywiki/index.php?title=Built-In_Classes) better. Still adding but it's growing. :)

Open to suggestions if someone has a better idea or has a thought to improve this one.