Vizrt Script 2018.12.11


SETY

structure onoffcontainer
dYDiff as double
sContainerName as string
end structure

dim sListContainerName = (string) "SET_Y"
dim bMultipages = (boolean) true
dim sPagePrefix = (string) "ONOFF_PAGE_"
dim sLinesDomain = (string) "LINES"
dim iMaxLine = (Integer) scene.findcontainer(sPagePrefix&"1").findsubcontainer(sLinesDomain).ChildContainerCount
dim iLineNumber = (integer) 4
dim sLinePrefix = (string) "LINE_"
dim arrOnOff as array[onoffcontainer]

'max site differences when elements are “ON”
dim dYBase = 0
'dim dYDiff = scene.findcontainer(sPagePrefix&"1").findsubcontainer("LINE_1").GetBoundingBoxDimensions()[1]
dim dYDiff = (double) 18.8
'27

sub OnInitParameters()
RegisterParameterString("linenumber", "Line Number:","10",40,40,"")
RegisterPushButton("sety","Set List Y", 1)
end sub

sub OnExecAction(buttonId As Integer)

iLineNumber = CInt(GetParameterString("linenumber"))
VizCommunication.map["iLineNumber"] = CStr(iLineNumber)
TreatLines()
end sub

sub SetNumberOfLines(num As String)
iLineNumber = CInt(num)
VizCommunication.map["iLineNumber"] = iLineNumber
Println "iLineNumber"
Println iLineNumber
TreatLines()
end sub
sub TreatLines()
 
 VizCommunication.map["iMaxLine"] = CStr(iMaxLine)
 arrOnOff.Clear()
 
 'iMaxLine = CInt(GetParameterString("maxline"))
 'dYBase = 0
 'dYDiff = CDbl(GetParameterString("lineheight"))
 
 For i = 1 to iLineNumber
 'Println i
 dim sI = (string) i
 dim oLine as onoffcontainer
 'oLine.dYDiff = dYDiff
 'oLine.dOffset = dOffset
 oLine.sContainerName = sLinePrefix&i
 arrOnOff.push(oLine)
 Println "i dYDiff"
 Println dYDiff
 Next
dim cMainContainer = (container) scene.findcontainer(sListContainerName)
 dim cBaseContainer as container
 
 dim j = (integer) 0
 for j=1 to iMaxLine
 Println "j = "&j
 
 Println "j dYDiff"
 Println dYDiff
 cBaseContainer = (container) scene.findcontainer("ONOFF_PAGE_1").findsubcontainer(sLinePrefix&j)
 cBaseContainer.active = false
 cBaseContainer = (container) scene.findcontainer("ONOFF_PAGE_2").findsubcontainer(sLinePrefix&j)
 cBaseContainer.active = false
 Next
 
 dim i = (integer) 0
 for i=1 to iLineNumber 
 Println "sLinePrefix&i = "&sLinePrefix&i
 cBaseContainer = (container) scene.findcontainer("ONOFF_PAGE_1").findsubcontainer(sLinePrefix&i)
 cBaseContainer.active = true
 cBaseContainer = (container) scene.findcontainer("ONOFF_PAGE_2").findsubcontainer(sLinePrefix&i)
 cBaseContainer.active = true
 Next 
 
 'cMainContainer.position.y = 0
 
 dim dYBaseTemp = 0.0
 cMainContainer.position.y = -((iMaxLine-iLineNumber)*dYDiff)
'next
end sub

MAXSIZE

dim _intMaxValues as Integer = 3

sub OnInitParameters()
 RegisterParameterString("strMaxSizeCont", "Max Size Container", "txt_name", 20, 99,"")
 RegisterParameterDouble("dblMaxMaxSize", "Maximum MaxSize ", 0.0, 0,9999) 
 
 for i = 1 to _intMaxValues
 RegisterParameterString("strPara" & i, "ONOFF_Cont " & i, "", 15, 20,"") 
 RegisterParameterDouble("dblOffset" & i, "Offset " & i, 0.0, -9999,9999) 
 RegisterPushButton("on" &i,"ON", i)
 RegisterPushButton("off"&i,"OFF", i+_intMaxValues)
 next 
 
 RegisterParameterString("strBaseCont", "Single Line Base Container" , "ONOFF_NAME", 20, 99,"")
 
 RegisterParameterBool("bMultiLine", "Multiple Lines", false)
 'if GetParameterBool("bMultiLine") then
 RegisterParameterInt("intLines", "No. of Lines", 10, 1, 99 ) 
 RegisterParameterString("strLineContainer", "Line Container Prefix" , "ONOFF_LINE_", 20, 99,"")
 'end if
 
 RegisterParameterBool("bMultiPage", "Multiple Pages", false)
 
 
 RegisterParameterInt("intPages", "No. of Pages", 2, 1, 99 ) 
 RegisterParameterString("strPageContainer", "Page Container Prefix" , "ONOFF_PAGE_", 20, 99,"")
 'end if
 RegisterPushButton("checkMaxSize","Update Maxsize", (2*_intMaxValues)+1)
 
 UpdateGui()
end sub

Sub UpdateGui()

 SendGuiParameterShow("strBaseCont", CInt(not (GetParameterBool("bMultiLine") Or GetParameterBool("bMultiPage") )))

 SendGuiParameterShow("intLines", CInt(GetParameterBool("bMultiLine")))
 SendGuiParameterShow("strLineContainer", CInt(GetParameterBool("bMultiLine")))
 
 SendGuiParameterShow("intPages", CInt(GetParameterBool("bMultiPage")))
 SendGuiParameterShow("strPageContainer", CInt(GetParameterBool("bMultiPage")))
 
end sub

sub OnExecAction(buttonId As Integer)
 select case buttonId
 case (2*_intMaxValues)+1
 'Println "MAX SIZE IS FULL IN ACTION MEINER!"
 case else
 dim bOnOff as Boolean = (buttonId <= _intMaxValues)
 dim strPara as String 
 if buttonId <= _intMaxValues then ' ON
 strPara = GetParameterString("strPara" & buttonId)
 else 
 strPara = GetParameterString("strPara" & (buttonId - _intMaxValues))
 end if
 
 if GetParameterBool("bMultiPage") then ' mehrere seiten ?
 for i = 1 to GetParameterInt("intPages")
 
 dim strPageCont as String = "$" & GetParameterString("strPageContainer") & i
 
 if GetParameterBool("bMultiLine") then ' mehrere zeilen?
 for j = 1 to GetParameterInt("intLines")
 dim lineContainer as String = strPageCont & "$" & GetParameterString("strLineContainer") & j & "$" & strPara
 
 scene.findcontainer(lineContainer).Active = bOnOff
 PrintLn lineContainer & ": " & bOnOff
 next
 else
 scene.findcontainer(strPageCont & "$" & strPara).Active = bOnOff
 PrintLn strPageCont & "$" & strPara & ": " & bOnOff
 end if
 
 next
 else
 if GetParameterBool("bMultiLine") then ' mehrere zeilen?
 for j = 1 to GetParameterInt("intLines")
 dim lineContainer as String = "$" & GetParameterString("strLineContainer") & j & "$" & strPara
 scene.findcontainer(lineContainer).Active = bOnOff
 PrintLn lineContainer & ": " & bOnOff
 next
 else
 scene.findcontainer(GetParameterString("strBaseCont") & "$" & strPara).Active = bOnOff
 PrintLn GetParameterString("strBaseCont") & "$" & strPara & ": " & bOnOff
 end if
 end if
 end select
 TreatLines()
end sub

Sub TreatLines()
 if GetParameterBool("bMultiPage") then ' mehrere seiten ?
 for i = 1 to GetParameterInt("intPages")
 dim strPageCont as String = "$" & GetParameterString("strPageContainer") & i

 if GetParameterBool("bMultiLine") then ' mehrere zeilen?
 for j = 1 to GetParameterInt("intLines")
 dim lineContainer as String = strPageCont & "$" & GetParameterString("strLineContainer") & j 
 TreatLine(lineContainer)
 next
 else
 TreatLine(strPageCont)
 end if 
 next
 else
 if GetParameterBool("bMultiLine") then ' mehrere zeilen?
 for j = 1 to GetParameterInt("intLines")
 dim lineContainer as String = "$" & GetParameterString("strLineContainer") & j

 TreatLine(lineContainer)
 next
 else
 TreatLine (GetParameterString("strBaseCont")) 
 end if
 end if
end sub

sub TreatLine(byref strCont as String)

 dim myCont as Container = Scene.FindContainer(strCont)
 
 if myCont == null then 
 PrintLn ("Container not found")
 exit sub
 end if
 
 dim dMSBaseTemp = (double) GetParameterDouble("dblMaxMaxSize") 
 For i = 1 to _intMaxValues
 if GetParameterString("strPara" & i ) <> "" then
 if myCont.findsubcontainer(GetParameterString("strPara" & i)).Active == false then
 dMSBaseTemp = dMSBaseTemp + GetParameterDouble("dblOffset" & i)
 end if
 dMSBaseTemp = dMSBaseTemp - GetParameterDouble("dblOffset" & i)
 end if
 Next
 myCont.findsubcontainer(GetParameterString("strMaxSizeCont")).GetFunctionPluginInstance("Maxsize").SetParameterDouble("WIDTH_X",dMSBaseTemp)
end sub

sub OnParameterChanged(parameterName As String)
 UpdateGui()
 select case parameterName
 case "intMaxBaseCont", "intMaxSizeCont" 
 ' nichts machen, da ändern der Containernamen!!!
 
 case else
 TreatLines()
 end select
end sub

QUALITY

dim sTreeText as string
dim iRecursion as integer
dim sNL as string = Chr(10)
dim sResponse as string
dim aQualityType as array[string]
dim aExeptions as array[string]
dim aTargetContainerPath as array[string]
dim sMainContainerName as string
dim sSharpenValue as string
dim sTargetContainerPath as string


'automatic variables
dim sAutoMainContainerName as string
dim sAutoSharpen1 as string
dim sAutoSharpen2 as string
dim sAutoFilterContainer1 as string
dim sAutoFilterContainer2 as string
dim sAutoFilterContainer3 as string
dim sAutoFilterContainer4 as string
dim sAutoFilterContainer5 as string
dim sAutoFilterContainer6 as string

sAutoMainContainerName = "ALL"
sAutoSharpen1 = "95"
sAutoSharpen2 = "87"

'noc's
sAutoFilterContainer1 ="TRANS.txt_nat"

'irm
sAutoFilterContainer2 ="TRANS.txt_irm"

'irm 
sAutoFilterContainer3 ="TRANS.txt_nat_1"
'irm
sAutoFilterContainer4 ="TRANS.txt_nat_2"
'irm
sAutoFilterContainer5 ="TRANS.txt_nat_w"
'irm
sAutoFilterContainer6 ="FLAG.txt_nat"
'/automatic variables


aExeptions.size = 10
aQualityType.size = 10
aTargetContainerPath.size = 20

aQualityType[1] = "PIXEL"
aQualityType[2] = "LINEAR"
aQualityType[3] = "MIPMAP"
aQualityType[4] = "SHARPEN"




sub OnInitParameters()
 RegisterParameterString("sMainContainerName","Main container name","Main",40,40,"")
 RegisterParameterString("iSharpenValue","Sharpen","100",3,3,"")

 RegisterParameterString("sExeptionContainer1","Exeption Container 1","",40,40,"")
 RegisterParameterString("sExeptionContainer2","Exeption Container 2","",40,40,"")
 RegisterParameterString("sExeptionContainer3","Exeption Container 3","",40,40,"")
 RegisterParameterString("sExeptionContainer4","Exeption Container 4","",40,40,"")
 RegisterParameterString("sExeptionContainer5","Exeption Container 5","",40,40,"")
 RegisterParameterString("sExeptionContainer6","Exeption Container 6","",40,40,"")
 RegisterParameterString("sExeptionContainer7","Exeption Container 7","",40,40,"")
 RegisterParameterString("sExeptionContainer8","Exeption Container 8","",40,40,"")
 
 RegisterParameterString("sTargetContainer","Target Container (max. 2 levels)","",40,40,"")
 
 RegisterPushButton("CmdTexture", "Set texts to TEXTURE", 1)
 RegisterPushButton("CmdGeometry", "Set texts to GEOMETRY", 2)
 RegisterPushButton("CmdImgLinear", "Set images to LINEAR", 3)
 RegisterPushButton("CmdImgMipmap", "Set images to MIPMAP", 4)
 RegisterPushButton("CmdImgPixel", "Set images to PIXEL", 5)
 RegisterPushButton("CmdImgClamp", "Set images to CLAMP", 6)
 RegisterPushButton("CmdPutDummyText", "Put dummy text", 7)
 
 RegisterPushButton("CmdAuto", "Auto Nanjing", 100)
 
 
 RegisterInfoText("v1.0 | Script to convert all texts with the quality set. Also available for images.\nv1.1 | Convert with 2 levels filtering")
end sub

sub OnExecAction(buttonId As Integer)

 
 sResponse=""
 
 '' definition du main container
 if buttonId <> 100 then
 sMainContainerName = GetParameterString("sMainContainerName")
 sSharpenValue = GetParameterString("iSharpenValue")
 sTargetContainerPath= GetParameterString("sTargetContainer")
 else
 
 '' NANJING SCRIPTS !
 
 
 sResponse &= "*AUTO* Convert 1"&sNL
 '' script pour lancer la conversion des textes normaux
 sMainContainerName = sAutoMainContainerName
 sSharpenValue = sAutoSharpen1
 sTargetContainerPath= ""
 'lancer
 TransformTexts(Scene.FindContainer(sMainContainerName),1)
 
 
 
 sResponse &= "*AUTO* Convert 2"&sNL
 '' script pour lancer la conversion des textes petits (NOC)
 sMainContainerName = sAutoMainContainerName
 sSharpenValue = sAutoSharpen2
 sTargetContainerPath= sAutoFilterContainer1
 'lancer
 TransformTexts(Scene.FindContainer(sMainContainerName),1)
 
 
 sResponse &= "*AUTO* Convert 3"&sNL
 '' script pour lancer la conversion des textes petits (IRM)
 sMainContainerName = sAutoMainContainerName
 sSharpenValue = sAutoSharpen2
 sTargetContainerPath= sAutoFilterContainer2
 'lancer 
 TransformTexts(Scene.FindContainer(sMainContainerName),1)
 
 sResponse &= "*AUTO* Convert 4"&sNL
 '' script pour lancer la conversion des textes petits (IRM)
 sMainContainerName = sAutoMainContainerName
 sSharpenValue = sAutoSharpen2
 sTargetContainerPath= sAutoFilterContainer3
 'lancer 
 TransformTexts(Scene.FindContainer(sMainContainerName),1)
 
 sResponse &= "*AUTO* Convert 5"&sNL
 '' script pour lancer la conversion des textes petits (IRM)
 sMainContainerName = sAutoMainContainerName
 sSharpenValue = sAutoSharpen2
 sTargetContainerPath= sAutoFilterContainer4
 'lancer 
 TransformTexts(Scene.FindContainer(sMainContainerName),1)
 
 sResponse &= "*AUTO* Convert 6"&sNL
 '' script pour lancer la conversion des textes petits (IRM)
 sMainContainerName = sAutoMainContainerName
 sSharpenValue = sAutoSharpen2
 sTargetContainerPath= sAutoFilterContainer5
 'lancer 
 TransformTexts(Scene.FindContainer(sMainContainerName),1)
 
 sResponse &= "*AUTO* Convert 7"&sNL
 '' script pour lancer la conversion des textes petits (IRM)
 sMainContainerName = sAutoMainContainerName
 sSharpenValue = sAutoSharpen2
 sTargetContainerPath= sAutoFilterContainer6
 'lancer 
 TransformTexts(Scene.FindContainer(sMainContainerName),1)
 
 
 sTargetContainerPath= ""
 'conversion des images
 sResponse &= "*AUTO* Convert IMAGES 1"&sNL
 TransformTexts(Scene.FindContainer(sMainContainerName),3)
 sResponse &= "*AUTO* Convert IMAGES 2"&sNL
 'conversion du wrap
 TransformTexts(Scene.FindContainer(sMainContainerName),6)
 
 
 end if


 sResponse &= "*****SCRIPT******"&sNL
 if sMainContainerName <> "" and buttonId <> 100 then
 TransformTexts(Scene.FindContainer(sMainContainerName),buttonId)
 else
 if buttonId <> 100 then
 sResponse &= "ERROR: please enter the main container name"&sNL
 end if
 end if
 println sResponse
end sub


sub TransformTexts(cContainer as container, iCase as integer)
 dim sLine as string
 dim sTexteContenu as string
 dim sNomDuContainer as string
 dim sNomDuParentContainer as string
 dim iIdDuContainer as integer 
 dim sTexteImageNom as string
 dim iIdDeLImage as integer
 dim iExeption as integer
 dim iFilter as integer
 dim iIsFilteredContainer as integer
 dim iFilterOk as integer
 
 ' on considère qu'il n'y a pas de filtre
 iFilter = 0
 
 ' on considère que ce n'est pas le container filtré
 iIsFilteredContainer = 0

 ' on considère que le filtre n'est pas OK (resultante des deux valeurs iFilter et iIsFilteredContainer)
 iFilterOk = 0


 ' Collecte des exceptions
 aExeptions[0] = GetParameterString("sExeptionContainer1")
 aExeptions[1] = GetParameterString("sExeptionContainer2")
 aExeptions[2] = GetParameterString("sExeptionContainer3")
 aExeptions[3] = GetParameterString("sExeptionContainer4")
 aExeptions[4] = GetParameterString("sExeptionContainer5")
 aExeptions[5] = GetParameterString("sExeptionContainer6")
 aExeptions[6] = GetParameterString("sExeptionContainer7")
 aExeptions[7] = GetParameterString("sExeptionContainer8")




 iRecursion++
 do while cContainer <> null
 
 
 iExeption = 0
 sNomDuContainer = cContainer.name
 sNomDuParentContainer = cContainer.ParentContainer.ParentContainer.name&"."&cContainer.ParentContainer.name
 iIdDuContainer = cContainer.vizid
 
 ' si l'utlisateur à rempli le champ de filtre
 if sTargetContainerPath <> "" then
 ' le filtre est actif!
 iFilter = 1
 
 ' splitter le target container pour connaitre son chemin
 sTargetContainerPath.Split(".",aTargetContainerPath)
 for i=0 to 1
 if aTargetContainerPath[i] == cContainer.name then
 if aTargetContainerPath[i-1] = cContainer.ParentContainer.name and aTargetContainerPath[i-1] <> "" then
 ' c'est bien le container filtré
 iIsFilteredContainer = 1
 end if
 end if
 next
 end if
 
 ' tester par rapport au filtre
 if iIsFilteredContainer == 1 then
 iFilterOk = 1
 end if
 
 if iFilter == 0 then
 iFilterOk = 1
 end if
 
 for i = 0 to aExeptions.size
 if aExeptions[i] == sNomDuContainer then
 
 ' ignorer ce container
 iExeption = 1
 println aExeptions[i]& " -> " &sNomDuContainer
 end if
 next
 
 sLine=""
 if cContainer.Geometry.Text <> "" and iExeption == 0 and iFilterOk == 1 then
 sTexteContenu = cContainer.Geometry.Text
 'println "X:"&cContainer.Scaling.x&" Y:"&cContainer.Scaling.y
 select case iCase
 case 1
 'GO TO CHANGE ALL TEXTS IN TEXTURE
 sResponse &= "("&iIdDuContainer&"::"&sNomDuParentContainer&"."&sNomDuContainer&") => Change text quality to texture (sharpen "&sSharpenValue&")"& sNL
 SendCommand("RENDERER*TREE*#"&iIdDuContainer&"*GEOM*STYLE SET T")
 if sSharpenValue <> "" then
 SendCommand("RENDERER*TREE*#"&iIdDuContainer&"*GEOM*SHARPEN SET "&sSharpenValue)
 end if
 case 2 
 'GO TO CHANGE ALL TEXTS IN GEOMETRY
 sResponse &= "("&iIdDuContainer&"::"&sNomDuParentContainer&"."&sNomDuContainer&") => Change text quality to geometry"& sNL
 SendCommand("RENDERER*TREE*#"&iIdDuContainer&"*GEOM*STYLE SET NONE")
 case 7
 'PUT DUMMY TEXT IN TEXT FIELDS
 cContainer.Geometry.Text = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
 end select
 end if
 
 if cContainer.texture.image.vizid <> 0 and iExeption == 0 and iFilterOk == 1 then
 
 select case iCase
 case 3
 'GO TO CHANGE ALL IMAGES IN LINEAR
 if aQualityType[cContainer.texture.qualitytype]<>aQualityType[2] then
 sResponse &= "("&iIdDuContainer&"::"&sNomDuParentContainer&"."&sNomDuContainer&") => Change image quality to linear"& sNL
 SendCommand("RENDERER*TREE*#"&iIdDuContainer&"*TEXTURE*QUALITY SET LINEAR")
 else
 sResponse &= "--("&iIdDuContainer&"::"&sNomDuContainer&") => No need to change quality"& sNL
 end if
 
 case 4
 'GO TO CHANGE ALL IMAGES IN MIPMAP
 if aQualityType[cContainer.texture.qualitytype]<>aQualityType[3] then
 sResponse &= "("&iIdDuContainer&"::"&sNomDuParentContainer&"."&sNomDuContainer&") => Change image quality to mipmap"& sNL
 SendCommand("RENDERER*TREE*#"&iIdDuContainer&"*TEXTURE*QUALITY SET MIPMAP")
 else
 sResponse &= "("&iIdDuContainer&"::"&sNomDuParentContainer&"."&sNomDuContainer&") => No need to change quality"& sNL
 end if
 
 case 5
 'GO TO CHANGE ALL IMAGES IN PIXEL
 if aQualityType[cContainer.texture.qualitytype]<>aQualityType[1] then
 sResponse &= "("&iIdDuContainer&"::"&sNomDuParentContainer&"."&sNomDuContainer&") => Change image quality to pixel"& sNL
 SendCommand("RENDERER*TREE*#"&iIdDuContainer&"*TEXTURE*QUALITY SET PIXEL")
 else
 sResponse &= "("&iIdDuContainer&"::"&sNomDuParentContainer&"."&sNomDuContainer&") => No need to change quality"& sNL
 end if
 
 case 6
 'GO TO CHANGE ALL IMAGES IN CLAMP
 sResponse &= "("&iIdDuContainer&"::"&sNomDuParentContainer&"."&sNomDuContainer&") => Change image wrap to clamp"& sNL
 SendCommand("RENDERER*TREE*#"&iIdDuContainer&"*TEXTURE*WRAP SET CLAMP")
 end select
 end if

 ' appliquer la récursion
 TransformTexts(cContainer.FirstChildContainer,iCase)
 
 ' dans la boucle, définir le prochain container
 cContainer = cContainer.nextcontainer 
 loop
 iRecursion--
 
end sub