Hi
I wanted to make a macro that copies a model in a given amount and distance in X Y
I got it X direction, but Y gives me some trouble.
//Copying models in X Y
ENTITY LIST $Model = INPUT ENTITY MODEL Choose_model "Model to copy"
CREATE FOLDER "Model" ;
RENAME FOLDER "Model\Folder1" "Copied models"
ACTIVATE FOLDER "Model\Copied models"
// CREATE LEVEL "Copies" LEVEL
EDIT MODEL $Model CLIPBOARD COPY
CREATE MODEL CLIPBOARD
EXPLORER SELECT Model "Model\Copied models\1" NEW\r
EDIT MODEL "1" DESELECT ALL
ACTIVATE MODEL #
STRING last = entity('model','').Name
STRING AmountX = INPUT "Amount of models in X Y"
STRING LIST $XAmount_token = tokens($AmountX,' ')
INT XAmount = real($XAmount_token[0])
STRING LIST $YAmount_token = tokens($AmountX,' ')
INT YAmount = real($YAmount_token[1])
STRING Copies = INPUT "Distance in X Y"
STRING LIST $Xpos_token = tokens($Copies,' ')
REAL Xpos = real($Xpos_token[0])
STRING LIST $Ypos_token = tokens($Copies,' ')
REAL Ypos = real($Ypos_token[1])
REAL Multi = $Xpos
INT CountX = $XAmount - 1
INT CountY = $YAmount
WHILE CountX > 0 {
STRING $Newmodel = new_entity_name('model')
EDIT MODEL $Model CLIPBOARD COPY
CREATE MODEL CLIPBOARD
FORM MODELTRANS EDIT MODEL $NewModel INTERACTIVE
TRANSFORM MOVE $Xpos
TRANSFORM TYPE MOVE TRANSFORM MOVEX PRESET TRANSFORM MODEL $NewModel
$Xpos = $CountX * $Multi
$CountX = CountX - 1
}
MODELTRANS ACCEPT
STRING LIST ModNames = extract(folder('model\Copied models'),'name')
STRING LIST NewYcopies = {}
FOREACH Mod IN $ModNames {
IF CountY > 0 {
STRING $Ymodel = new_entity_name('model')
EDIT MODEL $Mod CLIPBOARD COPY
CREATE MODEL CLIPBOARD
ACTIVATE MODEL $Ymodel
int s = add_first(NewYcopies, model.Name)
$CountY = CountY - 1
}
}
Hi
I solved the problem by myself and sharing my solution. If anybody has a better solution please share.
//Copying models in X Y
ENTITY LIST $Model = INPUT ENTITY MODEL Choose_model "Model to copy"
STRING NewName = "Copied_models"
CREATE FOLDER "Model" ;
RENAME FOLDER "Model\Folder1" $NewName
STRING ModelM = 'Model\' + $NewName
ACTIVATE FOLDER $ModelM
STRING ActiveF = ACTIVE_FOLDER()
EDIT MODEL $Model CLIPBOARD COPY
CREATE MODEL CLIPBOARD
// EXPLORER SELECT Model "Model\Copied models\1" NEW\r
EDIT MODEL "1" DESELECT ALL
ACTIVATE MODEL #
STRING last = entity('model','').Name
STRING AmountX = INPUT "Amount of models in X Y"
STRING LIST $XAmount_token = tokens($AmountX,' ')
INT XAmount = real($XAmount_token[0])
STRING LIST $YAmount_token = tokens($AmountX,' ')
INT YAmount = real($YAmount_token[1])
STRING Copies = INPUT "Distance in X Y"
STRING LIST $Xpos_token = tokens($Copies,' ')
REAL Xpos = real($Xpos_token[0])
STRING LIST $Ypos_token = tokens($Copies,' ')
REAL Ypos = real($Ypos_token[1])
REAL Multi = $Xpos
INT CountX = $XAmount - 1
INT CountY = $YAmount
WHILE CountX > 0 {
STRING $Newmodel = new_entity_name('model')
EDIT MODEL $Model CLIPBOARD COPY
CREATE MODEL CLIPBOARD
FORM MODELTRANS EDIT MODEL $NewModel INTERACTIVE
TRANSFORM MOVE $Xpos
TRANSFORM TYPE MOVE TRANSFORM MOVEX PRESET TRANSFORM MODEL $NewModel
$Xpos = $CountX * $Multi
$CountX = CountX - 1
}
MODELTRANS ACCEPT
$YAmount = $YAmount -1
REAL YMulti = Ypos
STRING LIST ModNames = extract(folder($ActiveF),'name')
WHILE $YAmount > 0 {
STRING LIST NewCopiedModNames = extract(folder($ActiveF),'name')
FOREACH Mod IN $ModNames {
EDIT MODEL $Mod CLIPBOARD COPY
CREATE MODEL CLIPBOARD
STRING LIST CopiedModNames = extract(folder($ActiveF),'name')
}
STRING LIST $New_Models = SUBTRACT((EXTRACT(FOLDER($ActiveF), 'name')), $NewCopiedModNames)
FOREACH Thing IN $New_Models {
FORM MODELTRANS EDIT MODEL $Thing INTERACTIVE
TRANSFORM MOVE $YPos
TRANSFORM TYPE MOVE TRANSFORM MOVEY PRESET TRANSFORM MODEL $Thing
}
$YPos = $YAmount * $YMulti
$YAmount = $YAmount - 1
}
MODELTRANS ACCEPT
Hi !
Here is the highlighted code were you might be wrong.
Pls, don't get it otherwise.
//Copying models in X Y
ENTITY LIST $Model = INPUT ENTITY MODEL Choose_model "Model to copy"
STRING NewName = "Copied_models"
CREATE FOLDER "Model" ;
RENAME FOLDER "Model\Folder1" $NewName
STRING ModelM = 'Model\' + $NewName
ACTIVATE FOLDER $ModelM
STRING ActiveF = ACTIVE_FOLDER()
EDIT MODEL $Model CLIPBOARD COPY
CREATE MODEL CLIPBOARD
// EXPLORER SELECT Model "Model\Copied models\1" NEW\r
EDIT MODEL "1" DESELECT ALL
ACTIVATE MODEL #
STRING last = entity('model','').Name
STRING AmountX = INPUT "Amount of models in X Y"
STRING LIST $XAmount_token = tokens($AmountX,' ')
INT XAmount = real($XAmount_token[0])
STRING LIST $YAmount_token = tokens($AmountX,' ')
INT YAmount = real($YAmount_token[0])
STRING Copies = INPUT "Distance in X Y"
STRING LIST $Xpos_token = tokens($Copies,' ')
REAL Xpos = real($Xpos_token[0])
STRING LIST $Ypos_token = tokens($Copies,' ')
REAL Ypos = real($Ypos_token[0])
REAL Multi = $Xpos
INT CountX = $XAmount - 1
INT CountY = $YAmount
WHILE CountX > 0 {
STRING $Newmodel = new_entity_name('model')
EDIT MODEL $Model CLIPBOARD COPY
CREATE MODEL CLIPBOARD
FORM MODELTRANS EDIT MODEL $NewModel INTERACTIVE
TRANSFORM MOVE $Xpos
TRANSFORM TYPE MOVE TRANSFORM MOVEX PRESET TRANSFORM MODEL $NewModel
$Xpos = $CountX * $Multi
$CountX = CountX - 1
}
MODELTRANS ACCEPT
$YAmount = $YAmount -1
REAL YMulti = Ypos
STRING LIST ModNames = extract(folder($ActiveF),'name')
WHILE $YAmount > 0 {
STRING LIST NewCopiedModNames = extract(folder($ActiveF),'name')
FOREACH Mod IN $ModNames {
EDIT MODEL $Mod CLIPBOARD COPY
CREATE MODEL CLIPBOARD
STRING LIST CopiedModNames = extract(folder($ActiveF),'name')
}
STRING LIST $New_Models = SUBTRACT((EXTRACT(FOLDER($ActiveF), 'name')), $NewCopiedModNames)
FOREACH Thing IN $New_Models {
FORM MODELTRANS EDIT MODEL $Thing INTERACTIVE
TRANSFORM MOVE $YPos
TRANSFORM TYPE MOVE TRANSFORM MOVEY PRESET TRANSFORM MODEL $Thing
}
$YPos = $YAmount * $YMulti
$YAmount = $YAmount - 1
}
MODELTRANS ACCEPT
Cheers !
Can't find what you're looking for? Ask the community or share your knowledge.