Vectorworks スクリプト 四角形を壁に変換
Vectorworksの初期段階で壁をザクザク作っていくときは、四角形で作成したほうが速かったりもします。
今回は四角形を選択して、壁に変換するスクリプトのサンプルです。あまり検証してないので、エラーがでるかもです。
import vs
def callbackUuid(hand):
uuidList.append(vs.GetObjectUuid(hand))
def createUuidList(word):
vs.ForEachObject(callbackUuid, word)
return uuidList
def getAttr(hand):
attrDict = {}
fillType = vs.GetObjectVariableInt(hand, 696)
boo , fillName = vs.GetVectorFill(hand)
fillpat = vs.GetFPat(hand)
attrDict['タイプ'] = fillType
attrDict['パターン'] = fillpat
attrDict['リソース'] = boo
if boo == False:
fillName = None
attrDict['名前'] = fillName
red,green,blue = vs.GetFillFore(hand)
color = vs.RGBToColorIndex(red, green, blue)
attrDict['面前RGB'] = [red,green,blue]
attrDict['面前色'] = color
red,green,blue = vs.GetFillBack(hand)
color = vs.RGBToColorIndex(red, green, blue)
attrDict['面後RGB'] = [red,green,blue]
attrDict['面後色'] = color
boo,penOpa,fillOpa = vs.GetOpacityN(hand)
attrDict['面透明'] = fillOpa
red,green,blue = vs.GetPenFore(hand)
color = vs.RGBToColorIndex(red, green, blue)
attrDict['線RGB'] = [red,green,blue]
attrDict['線色'] = color
attrDict['線透明'] = penOpa
lineWide = vs.GetLW(hand)
lineStyle = vs.GetLSN(hand)
attrDict['線幅'] = lineWide
attrDict['ラインタイプ'] = lineStyle
return attrDict
def setAttr(attrDict,hand):
vs.SetPenFore(hand, attrDict['線色'])
vs.SetLW(hand, attrDict['線幅'])
vs.SetLSN(hand, attrDict['ラインタイプ'])
vs.SetOpacityN(hand, attrDict['線透明'], attrDict['面透明'])
if attrDict['リソース'] == True:
result = vs.Name2Index(attrDict['名前'])
vs.SetObjectVariableLongInt (hand,695,result * -1)
else:
if attrDict['タイプ'] == 1:
vs.SetFPat(hand, 0)
elif attrDict['タイプ'] == 2:
vs.SetFPat(hand, 1)
vs.SetFillBack(hand, attrDict['面後色'])
elif attrDict['タイプ'] == 3:
vs.SetFPat(hand,attrDict['パターン'])
vs.SetFillFore(hand, attrDict['面前色'])
vs.SetFillBack(hand, attrDict['面後色'])
uuidList = []
word = "((VSEL=TRUE) & (T=RECT))"
uuidList =createUuidList(word)
for rect in uuidList:
hand = vs.GetObjectByUuid(rect)
attrDict = getAttr(hand)
angle = vs.HAngle(hand)
center = vs.HCenter(hand)
vs.HRotate(hand, center, -1 * angle)
p1,p2 = vs.GetBBox(hand)
lenX = abs((p2[0]-p1[0]))
lenY = abs((p2[1]-p1[1]))
if lenX > lenY:
thick = lenY
long = lenX
beginPt = p1[0],center[1]
endPt = p2[0],center[1]
else:
thick = lenX
long = lenY
beginPt = center[0],p1[1]
endPt = center[0],p2[1]
vs.Wall(beginPt, endPt)
wallHand = vs.LNewObj()
vs.SetWallThickness(wallHand, thick)
setAttr(attrDict,wallHand)
vs.HRotate(wallHand,center,angle)
vs.DelObject(hand)