家を建てるまでのログ

iet(イエティ)ともうします。 一条工務店のi-smartで家を建てるブログです。

Photoshopでハイドロテクトタイル塗り全パターン

今晩は、自分の家のタイルの塗り分けを検討するために、Photoshopでタイルの(前面部分だけ)塗り分け全パターン分の画像を生成して見ています。

f:id:iet:20151204001936p:plain

いちいち設計打ち合わせでパターン色をフィーリングで指定して画像があがってくるのを待つ、のはちょっともどかしい(笑)

タイルのそれぞれパーツごと各色レイヤーで持って、レイヤーのOn/Offで塗り分け色パターンを切り替える感じですね。

うちだと家の前面が2パターンの塗り分け(窓部分の上下をi-cubeのように塗るかどうか、それともi-smartらしく一色にするか)があるので、5色 * 5色 * 2パターン で50パターン塗り分け方があります。 (→45パターンでした)

さすがにこの分の画像を生成するのは骨なので、VBAでCOM経由でPhotoshopを操作して生成してます。

↓ コードは、こんな感じのクソコードです。使い捨てなのでクソコードでOKです。

    Static psp As New Photoshop.Application
    
    Dim targetDoc As Photoshop.Document
    Set targetDoc = psp.Documents("図面合成1.psd")
    
    Dim colors
    colors = Array("Pink", "White", "Brown", "Orange", "Black")
    
    Dim baseColors As New Dictionary
    Dim frontColors As New Dictionary
    Dim windowColors As New Dictionary
    
    Dim layerNameRegexp As New RegExp
    layerNameRegexp.Pattern = "(Front|Window|Base)(\w+)"
    
    Dim aL As ArtLayer
    
    Dim lerSet As LayerSet
    For Each lerSet In targetDoc.LayerSets
        For Each aL In lerSet.ArtLayers
            If layerNameRegexp.Test(aL.Name) Then
                Dim rExec As MatchCollection
                Set rExec = layerNameRegexp.Execute(aL.Name)
                Dim partName$, colorName$
                partName$ = rExec(0).SubMatches(0)
                colorName = rExec(0).SubMatches(1)
                
                Select Case partName$
                Case "Front"
                    Set frontColors(colorName) = aL
                Case "Window"
                    Set windowColors(colorName) = aL
                Case "Base"
                    Set baseColors(colorName) = aL
                End Select
            End If
        Next
    Next
    
    Dim jpegSaveOption As New JPEGSaveOptions
    jpegSaveOption.Quality = 0.6
    
    For Each eBaseColor In colors
        baseColors(eBaseColor).Visible = True
        
        For Each eFrontColor In colors
            frontColors(eFrontColor).Visible = True
        
            windowColors(eFrontColor).Visible = True
            
            targetDoc.SaveAs "C:\どっかのフォルダ\" & eBaseColor & "_" & eFrontColor & "_win", jpegSaveOption, True
            
            windowColors(eFrontColor).Visible = False
        
            targetDoc.SaveAs "C:\どっかのフォルダ\" & eBaseColor & "_" & eFrontColor & "_sole", jpegSaveOption, True
        
            frontColors(eFrontColor).Visible = False
        Next
    
        baseColors(eBaseColor).Visible = False
    Next

プログラマとしての経験がちょっとは役に立ったかな?

一条ブロガーのブログを見ていると、みなさん、だいたい30代ぐらいで建てる人が多いみたいですね。(私はギリギリ20代)

そのぐらいの年齢だと、仕事での経験もそれなりにあるはずで、みなさんそれぞれの家を建てる時に、自分の職業で培った強みを活かしているんだろうなあと思いました。

家の工法に詳しい人、設備に詳しい人、法律に詳しい人、お金に詳しい人、美的センスが優れている人、コミュニケーション能力が高い人、いろんな人がいますね。私はどれでもないんだな(笑)