Someone please help me to modify this script.
Moderators: Víctor Paredes, Belgarath, slowtiger
-
- Posts: 69
- Joined: Thu Jan 24, 2019 3:52 am
Someone please help me to modify this script.
Hi, I recently downloaded this script from this site:
https://mohoscripts.com/script/sz_recolor_layer
It is an excellent script, I use it mainly to paint many vectors or shapes at once.
But I would also like to be able to paint 3d shapes in the folder, for example I want to paint all vectors and in a folder there are also 3d files and I would like it to paint them.
Please is there someone who can modify it?
I tried to do it but I am very inexperienced.
https://mohoscripts.com/script/sz_recolor_layer
It is an excellent script, I use it mainly to paint many vectors or shapes at once.
But I would also like to be able to paint 3d shapes in the folder, for example I want to paint all vectors and in a folder there are also 3d files and I would like it to paint them.
Please is there someone who can modify it?
I tried to do it but I am very inexperienced.
- hayasidist
- Posts: 3857
- Joined: Wed Feb 16, 2011 8:12 pm
- Location: Kent, England
Re: Someone please help me to modify this script.
same as before about "fill" and "stroke" - it's to do with the material of each face. http://www.lostmarble.com/forum/viewtopic.php?p=201756
and localisation as here: http://www.lostmarble.com/forum/viewtop ... 32#p193632
also, 3d materials are not animatable (so the stuff in Stan's script about keyframes is not relevant to 3d)
hope that moves you forwards!
and localisation as here: http://www.lostmarble.com/forum/viewtop ... 32#p193632
also, 3d materials are not animatable (so the stuff in Stan's script about keyframes is not relevant to 3d)
hope that moves you forwards!
-
- Posts: 69
- Joined: Thu Jan 24, 2019 3:52 am
Re: Someone please help me to modify this script.
Hi, I am trying to do something like this:
but I get stuck what method or function can I use to paint the 3d and 2d shape?
but I get stuck what method or function can I use to paint the 3d and 2d shape?
Code: Select all
-- **************************************************
-- Provide Moho with the name of this script object
-- **************************************************
ScriptName = "Pintar"
-- **************************************************
-- General information about this script
-- **************************************************
Pintar = {}
function Pintar:Name()
return self:Localize('UILabel')
end
function Pintar:Version()
return '1.0'
end
function Pintar:UILabel()
return self:Localize('UILabel')
end
function Pintar:Creator()
return 'brayanmartin'
end
function Pintar:Description()
return self:Localize('Description')
end
function Pintar:ColorizeIcon()
return true
end
-- **************************************************
-- Is Relevant / Is Enabled
-- **************************************************
function Pintar:IsRelevant(moho)
return true
end
function Pintar:IsEnabled(moho)
return true
end
-- **************************************************
-- Keyboard/Mouse Control
-- **************************************************
function Pintar:OnMouseDown(moho, mouseEvent)
end
function Pintar:OnMouseMoved(moho, mouseEvent)
end
function Pintar:OnMouseUp(moho, mouseEvent)
end
function Pintar:OnKeyDown(moho, keyEvent)
end
function Pintar:OnKeyUp(moho, keyEvent)
end
-- **************************************************
-- Tool Panel Layout
-- **************************************************
Pintar.BOTON_PINTAR = MOHO.MSG_BASE
function Pintar:DoLayout(moho, layout)
self.vamos_a_pintar=LM.GUI.ColorSwatch(true)
self.boton_pintarButton = LM.GUI.Button(self:Localize('Boton_pintar'), self.BOTON_PINTAR)
layout:AddChild(self.boton_pintarButton, LM.GUI.ALIGN_LEFT, 0)
layout:AddChild(self.vamos_a_pintar , LM.GUI.ALIGN_LEFT, 0)
end
Elegir={}
function Elegir:Es_vector_3d(moho,layer)
local layerCount
local i
layerCount = layer:CountLayers()
if ( layerCount == 0 ) then
return
end
for i=0,layerCount-1 do
local childLayer =layer:Layer(i)
local childLayerType = childLayer:LayerType()
if ( childLayer:IsBoneType() ) then
Elegir:Es_vector_3d(moho,moho:LayerAsGroup(childLayer))
else
if ( childLayerType == MOHO.LT_3D ) then
---I want to paint here I have already found 3d
elseif ( childLayerType == MOHO.LT_VECTOR ) then
---I want to paint here I already found the vector form
local mesh = layer:Mesh()
for i = 0, mesh:CountShapes() - 1 do
local shape = mesh:Shape(i)
shape.fMyStyle.fFillCol:SetValue(0,true)
function Pintar:HandleMessage(moho, view, msg)
if msg == self.BOTON_PINTAR then
print("When you click on paint all shapes will be painted including 3d")
else
end
end
-- **************************************************
-- Localization
-- **************************************************
function Pintar:Localize(text)
local phrase = {}
phrase['Description'] = ''
phrase['UILabel'] = 'etiqueta_pintar'
phrase['Boton_pintar'] = 'Boton_pintar'
local fileWord = MOHO.Localize("/Menus/File/File=File")
if fileWord == "Файл" then
phrase['Description'] = ''
phrase['UILabel'] = 'etiqueta_pintar'
phrase['Boton_pintar'] = 'Boton_pintar'
end
return phrase[text]
end
- hayasidist
- Posts: 3857
- Joined: Wed Feb 16, 2011 8:12 pm
- Location: Kent, England
Re: Someone please help me to modify this script.
2d shape -- see Stan's tool .. that's a great start.
3d shape: this needs a "material" to be defined.
You have some options:
1: present the list of materials already defined and allow the user to select one or to define a new one.
2: just define a new one (and ignore the fact it might be a duplicate)
(see http://www.lostmarble.com/forum/viewtop ... 94#p201794 and https://mohoscripting.com/classes/M_Mesh3D)
then, for the selected layer, change the material for each of the faces to be the selected / created one - call it material #m
As previously noted, Moho doesn't have any UI for selecting points / faces in a 3d mesh, so you're really in an "all or nothing" situation (unless you want to try to build a picker!?)
(see http://www.lostmarble.com/forum/viewtop ... 56#p201756 and https://mohoscripting.com/classes/M_Face3D)
3d shape: this needs a "material" to be defined.
You have some options:
1: present the list of materials already defined and allow the user to select one or to define a new one.
2: just define a new one (and ignore the fact it might be a duplicate)
(see http://www.lostmarble.com/forum/viewtop ... 94#p201794 and https://mohoscripting.com/classes/M_Mesh3D)
then, for the selected layer, change the material for each of the faces to be the selected / created one - call it material #m
Code: Select all
for i = 0, mesh:CountFaces()-1 do
local face = mesh:Face(i)
face.matID = m
end
(see http://www.lostmarble.com/forum/viewtop ... 56#p201756 and https://mohoscripting.com/classes/M_Face3D)
-
- Posts: 69
- Joined: Thu Jan 24, 2019 3:52 am
Re: Someone please help me to modify this script.
Hello, thank you for replying.hayasidist wrote: ↑Tue Mar 22, 2022 7:35 pm 2d shape -- see Stan's tool .. that's a great start.
3d shape: this needs a "material" to be defined.
Here is the tool, it's a test I'm doing - I first try to paint the vectors of a group.
first I try to paint the vectors of a group.
but it gives me error (MESH A NIL VALUE)
What I want to achieve is to paint all the vectors and 3d objects of a group to the same color.
Here is the proof: https://www.mediafire.com/file/d9dgswq1 ... l.zip/file
- hayasidist
- Posts: 3857
- Joined: Wed Feb 16, 2011 8:12 pm
- Location: Kent, England
Re: Someone please help me to modify this script.
take a look at the "common problems" section on https://mohoscripting.com/
you need to add a line childLayer = moho:LayerAsVector(childLayer) (see https://mohoscripting.com/methods/68) before trying to access the (2d) mesh.
you need to add a line childLayer = moho:LayerAsVector(childLayer) (see https://mohoscripting.com/methods/68) before trying to access the (2d) mesh.
-
- Posts: 69
- Joined: Thu Jan 24, 2019 3:52 am
Re: Someone please help me to modify this script.
Thank you, this is getting complicated for me.hayasidist wrote: ↑Tue Mar 22, 2022 10:04 pm take a look at the "common problems" section on https://mohoscripting.com/
you need to add a line childLayer = moho:LayerAsVector(childLayer) (see https://mohoscripting.com/methods/68) before trying to access the (2d) mesh.
Now I need to set the color to the shape.
But I will investigate
- hayasidist
- Posts: 3857
- Joined: Wed Feb 16, 2011 8:12 pm
- Location: Kent, England
Re: Someone please help me to modify this script.
Stan's script is a good model to follow ... note that he has separated the UI from the actual "loop through the layers and change things" processing.
IOW the bulk of his SZ_RecolorLayer:Run(moho) happens only after the user commits the requested changes (presses "OK") and then it scans for layers to change (self:ScanLayers(moho) ) which fills in a table; and this table is then used to drive the loop to recolour (for [all table entries] do; self:RecolorLayer(moho,l,f); end )
IOW the bulk of his SZ_RecolorLayer:Run(moho) happens only after the user commits the requested changes (presses "OK") and then it scans for layers to change (self:ScanLayers(moho) ) which fills in a table; and this table is then used to drive the loop to recolour (for [all table entries] do; self:RecolorLayer(moho,l,f); end )
-
- Posts: 69
- Joined: Thu Jan 24, 2019 3:52 am
Re: Someone please help me to modify this script.
Hi Hayasidist, I solved the problem, I can now paint the vectors.hayasidist wrote: ↑Wed Mar 23, 2022 11:48 am Stan's script is a good model to follow ... note that he has separated the UI from the actual "loop through the layers and change things" processing.
IOW the bulk of his SZ_RecolorLayer:Run(moho) happens only after the user commits the requested changes (presses "OK") and then it scans for layers to change (self:ScanLayers(moho) ) which fills in a table; and this table is then used to drive the loop to recolour (for [all table entries] do; self:RecolorLayer(moho,l,f); end )
Now I get this error . Mesh 3d (NIL VALUE).
When I want to paint the 3d object.
Archive : https://www.mediafire.com/file/nrd3uset ... t.zip/file
- hayasidist
- Posts: 3857
- Joined: Wed Feb 16, 2011 8:12 pm
- Location: Kent, England
Re: Someone please help me to modify this script.
Take a look back at my previous reply to you, and the linked pages: http://www.lostmarble.com/forum/viewtop ... 22#p203622 for recolouring 3d objects
mesh3d does not have shapes - it has faces.
so your code
won't do anything except cause Lua to cough up errors.
What you need to do is
-- choose or define a material
-- assign that material to each face in the 3d mesh
mesh3d does not have shapes - it has faces.
so your code
Code: Select all
for i=0,mesh3d:CountShapes()-1 do
local shape3d=mesh3d:Shape(i)
shape3d.fMyStyle.fFillCol:SetValue(moho.layerFrame,self.vamos_a_pintar:Value())
What you need to do is
-- choose or define a material
-- assign that material to each face in the 3d mesh
-
- Posts: 69
- Joined: Thu Jan 24, 2019 3:52 am
Re: Someone please help me to modify this script.
But if you look at the file I sent you,hayasidist wrote: ↑Wed Mar 23, 2022 1:08 pm Take a look back at my previous reply to you, and the linked pages: http://www.lostmarble.com/forum/viewtop ... 22#p203622 for recolouring 3d objects
mesh3d does not have shapes - it has faces.
won't do anything except cause Lua to cough up errors.
What you need to do is
-- choose or define a material
-- assign that material to each face in the 3d mesh
if you go to the 3d object and select : Style, advanced, shapes.
There is a shape (MAT) that can be colored as if it were a vector.
-
- Posts: 69
- Joined: Thu Jan 24, 2019 3:52 am
Re: Someone please help me to modify this script.
hayasidist wrote: ↑Wed Mar 23, 2022 1:08 pm Take a look back at my previous reply to you, and the linked pages: http://www.lostmarble.com/forum/viewtop ... 22#p203622 for recolouring 3d objects
I'll try what you sent me and let you know what happens, thanks