2022/01/18
*この記事で扱っているVectorworksのバージョンはVectorworks architect 2019 です。
今回はMarionette(マリオネット)の
「Set Char Properties」ノードについて。
文字列図形のフォントやサイズ、太字など表現を
どうやってコントロールするのか調べてことがなかったので、
少し試行錯誤してみた。
(↓下図の右側、オレンジ色のノードです。)
マリオネットノードを選択してOIP(オブジェクト情報パレット)にある
「説明」ボタンをクリックすると
下図のような説明のダイアログが出てくる。
文字列図形の表現がなんとなくできそう。
「iCount」は設定を適用する文字数まで指定できるのか......
「iFontID」はフォント指定できるっぽいけれどもIDってなんだろう......
.......とりあえず「 i 」って書いてるからintを流すのかな!?
という感じでとりあえずデタラメに入れて様子を見てみる。
文字列図形は何もかわらなかった。
「iCount」に流し込むintが「0」だったからかな。
ということで文字数よりちょっと少ない整数をいれてみたら
整数の数だけ文字列図形の表現が変わった。
その次は「フォントID」につまずいた。
フォントにIDが振られているみたいに見えるけれども
どこで確認できるのかさっぱりわからない。
あらためてA&Aさんの
ノードリファレンス(図形-文字)を読んでみると
「Get Font ID」というノードがあることがわかった。
(A&A.ノードリファレンス https://www.aanda.co.jp/develop/Marionette/reference.html#category-string)
これっぽい(予感)。
フォント名を入力するとフォントIDを出力してくれるということで
やってみるとiCountに入れた数だけ表現が変わった。
いつもメイリオを使っているので
Stringノードに「メイリオ」をOIPで入力して使ってみている。
(*ちなみにメイリオのフォントIDは「156」でした。)
以下、スクリプトも少し見てみる。
@Marionette.NodeDefinition
class Params(metaclass = Marionette.OrderedClass):
#APPEARANCE
#Name
this = Marionette.Node( 'Set Char Properties' )
this.SetDescription('Sets the properties of the characters within the specified range in the text object')
#Input Ports
textIn = Marionette.PortIn( vs.Handle(0), 'hText' )
textIn.SetDescription('The text object')
start = Marionette.PortIn(0, 'iStart')
start.SetDescription('An integer representing the starting character position in the text string. An index of 0 refers to the first character in the string')
count = Marionette.PortIn(1, 'iCount')
count.SetDescription('The number of characters to set the properties of')
fontID = Marionette.PortIn(None, 'iFontID')
fontID.SetDescription('Returns the font ID of the character')
size = Marionette.PortIn(None, 'nSize')
size.SetDescription('The character point size. 1 point = 1/72')
style = Marionette.PortIn(None, 'iStyle')
style.SetDescription('The text style of the character. Result is encoded in the low 7 bits of an integer and in range [0, 127] by combining the following values:'
'0 = Plain, 1 = Bold, 2 = Italic, 4 = Underline, 8 = Outline, 16 = Shadowed, 32 = Superscript, 64 = Subscript')
#OIP Controls
#Output Ports
textOut = Marionette.PortOut('text')
textOut.SetDescription('The modified text object')
#BEHAVIOR
def RunNode(self):
#inputs
textIn = self.Params.textIn.value
start = self.Params.start.value
count = self.Params.count.value
fontID = self.Params.fontID.value
size = self.Params.size.value
style = self.Params.style.value
#script
vs.SetTextFont(textIn, start, count, fontID)
vs.SetTextSize(textIn, start, count, size)
vs.SetTextStyle(textIn, start, count, style)
#outputs
self.Params.textOut.value = textIn
#Vectorworks
#ベクターワークス
#Marionette
#マリオネット
#文字
#文字列
#文字列図形
#SetCharProperties
#GetFontID
#font
#フォント