-
Notifications
You must be signed in to change notification settings - Fork 342
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #435 from og76/patch-1
Create change_text_case.py
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import bpy | ||
from bpy.props import * | ||
from ... events import executionCodeChanged | ||
from ... base_types.node import AnimationNode | ||
|
||
caseTypeItems= [("UPPER", "To Upper Case", ""), | ||
("LOWER", "To Lower Case", ""), | ||
("CAPITALIZE", "Capitalize Phrase", "") ] | ||
|
||
caseTypeCode = { item[0] : item[0].lower() for item in caseTypeItems } | ||
|
||
class ChangeTextCaseNode(bpy.types.Node, AnimationNode): | ||
bl_idname = "an_ChangeTextCaseNode" | ||
bl_label = "Change Text Case" | ||
|
||
def caseTypeChanges(self, context): | ||
executionCodeChanged() | ||
|
||
caseType = EnumProperty( | ||
name = "Case Type", default = "CAPITALIZE", | ||
items = caseTypeItems, update = caseTypeChanges) | ||
|
||
def create(self): | ||
self.inputs.new("an_StringSocket", "Text", "inText") | ||
self.outputs.new("an_StringSocket", "Text", "outText") | ||
|
||
def draw(self, layout): | ||
layout.prop(self, "caseType", text = "") | ||
|
||
def getExecutionCode(self): | ||
return "outText = inText.{}()".format(caseTypeCode[self.caseType]) |