Python Forum
Could someone help me finish this ASAP - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: Could someone help me finish this ASAP (/thread-35851.html)



Could someone help me finish this ASAP - JimmyDricks - Dec-20-2021

Hello Guys,

I'm hoping anyone can help an ignorant modeler. I haven't done much coding since I was in school, and I was trying to create a tool that would allow me to make Roof tiles for numerous buildings in my scene. The only ones I can find online were MEL based and was trying to create it myself... started building it.. and I'm lost in my functions, all I've really built is my window. Help anyone, in anyway. Guidance, or what you would do etc.


cmds.window(title='Roof Tile Creator',sizeable=False, resizeToFitChildren=True, backgroundColor=[0,0,0])

cmds.rowColumnLayout(numberOfColumns=1) #Master Layout


cmds.rowColumnLayout(numberOfColumns=1)#Layout A
cmds.text(width=100, height=20, label='Select GEO for Tile', backgroundColor=[0,255,0])

cmds.setParent('..')

cmds.rowColumnLayout(numberOfColumns=1)#Layout B
cmds.text(width=80, height=20, label='Rotate & Position the GEO on the Z axis',backgroundColor=[255,165,0])


cmds.rowColumnLayout(numberOfColumns=2, backgroundColor=[0,0,0])#Layout C
cmds.text(width=80, height=20, label='Row')
cmds.intSliderGrp(width=150, height=12.5, field=True,minValue=0, maxValue=999, value=1 )

cmds.setParent('..')

cmds.rowColumnLayout(numberOfColumns=2)#Layout D
cmds.text(width=80, height=20, label='Column')
cmds.intSliderGrp(width=150, height=12.5, field=True, minValue=0, maxValue=999, value=1)

cmds.setParent('..')

cmds.rowColumnLayout(numberOfColumns=2)#Layout E
cmds.text(width=80, height=20, label='Height Offset')
cmds.intSliderGrp(width=150, height=12.5, field=True, minValue=0, maxValue=4, value=1.5)

cmds.setParent('..')

cmds.rowColumnLayout(numberOfColumns=1)#Layout F
cmds.button(label='Create', width=80, height=15)

cmds.showWindow()



RE: Haven't coded forever, little lost creating Tool. - Larz60+ - Dec-20-2021

Please:
  • Post enough code to enable running. Complete is best.
  • State your goal
  • Where you think you're at
  • Anything else useful for debugging



RE: Haven't coded forever, little lost creating Tool. - JimmyDricks - Dec-22-2021

'''Python Script to quickly build and shape roof tiles. Select the model, use the UI, and go
Enter the Number of tiles by inputing number of rows & columns.'''


import maya.cmds as cmds

class TileWindow(object):


def __init__(self):

self.window = "TileWindow"
self.title = "Roof Tile Creator"
self.size = (100, 100)


if cmds.window(self.window, exists = True):
cmds.deleteUI(self.window, window=True)


self.window = cmds.window(self.window, title=self.title, widthHeight=self.size)

cmds.rowColumnLayout(numberOfColumns=1,adjustableColumn = True)#Layout1
cmds.text(width=100, height=20, label= 'Select Model for Tile', backgroundColor=[0,255,0])

cmds.setParent('..')

cmds.rowColumnLayout(numberOfColumns=1, adjustableColumn = True)#Layout2
cmds.text(width=200, height=20, label='Rotate & Position Model on Z axis:',backgroundColor=[255,165,0])

cmds.setParent('..')

cmds.rowColumnLayout(numberOfColumns=2, adjustableColumn= True)#Layout3
cmds.text(width=80, height=20, label='Row')
cmds.separator
self.rowamount = cmds.intSliderGrp(width=150, height=12.5, field=True, minValue=0, maxValue=999, value=1)


cmds.setParent('..')

cmds.rowColumnLayout(numberOfColumns=2, adjustableColumn = True)#Layout4
cmds.text(width=80, height=20, label='Column')
cmds.separator
self.columnamount = cmds.intSliderGrp(width=150, height=12.5, field=True, minValue=0, maxValue=999, value=1)

cmds.setParent('..')

cmds.rowColumnLayout(numberOfColumns=2, adjustableColumn = True)#Layout5
cmds.text(width=80, height=20, label='Height Offset')
cmds.separator
self.heightoffset = cmds.intSliderGrp(width=150, height=12.5, field=True, minValue=1.5, maxValue=4, value=1.5)

cmds.setParent('..')

cmds.rowColumnLayout(numberOfColumns=1, adjustableColumn = True)
self.tileName = cmds.textFieldGrp( label='Tile Name:')

cmds.rowColumnLayout(numberOfColumns=1, adjustableColumn = True)#Layout6
self.tileCreateBtn = cmds.button(label='Create', width=80, height=15, command=self.createTile)



cmds.showWindow()

def createTile (self, *args):

numberOfRows = cmds.intSliderGrp(self.rowamount, query=True, value=True)

numberOfColumns = cmds.intSliderGrp(self.columnamount, query=True, value=True)

amountOfHeightoffset = cmds.intSliderGrp(self.heightoffset, query=True, value=True)

name = cmds.textFieldGrp(self.tileName, query=True, text=True)




myWindow = TileWindow()



I know I have to define my tile, I was going to use a polyCube command, and non linear bend. Not really sure how to go about that. Or how to write the code to call upon the values from each slider.


Could someone help me finish this ASAP - JimmyDricks - Dec-23-2021

Hello could anyone help me with this.

I'm trying to finish my function so that when I press create it references the information from my slider groups.


import maya.cmds as cmds
import random


"""Python Script to quickly build and shape roof tiles. Select the model, use the UI, and go
Enter the Number of tiles by inputing number of rows & columns."""


result = cmds.ls(sl=True)


class TileWindow(object):
    def createTile(self, *args):

        numberOfRows = cmds.intSliderGrp(self.rowamount, query=True, value=True)

        numberOfColumns = cmds.intSliderGrp(self.columnamount, query=True, value=True)

        amountOfHeightoffset = cmds.intSliderGrp(
            self.heightoffset, query=True, value=True
        )

        name = cmds.textFieldGrp(self.tileName, query=True, text=True)

        sel = cmds.ls(selection=True)

        Tile = cmds.polyCube(width=31.433, height=43.10, depth=3.175)

    def __init__(self):

        self.window = "TileWindow"
        self.title = "Roof Tile Creator"
        self.size = (1000, 1000)

        if cmds.window(self.window, exists=True):
            cmds.deleteUI(self.window, window=True)

        self.window = cmds.window(self.window, title=self.title, widthHeight=self.size)

        cmds.rowColumnLayout(numberOfColumns=1, adjustableColumn=True)  # Layout1
        cmds.text(
            width=100,
            height=20,
            label="Select Model for Tile",
            backgroundColor=[0, 255, 0],
        )

        cmds.setParent("..")

        cmds.rowColumnLayout(numberOfColumns=1, adjustableColumn=True)  # Layout2
        cmds.text(
            width=200,
            height=20,
            label="Rotate & Position Model on Z axis:",
            backgroundColor=[255, 165, 0],
        )

        cmds.setParent("..")

        cmds.rowColumnLayout(numberOfColumns=2, adjustableColumn=True)  # Layout3
        cmds.text(width=80, height=20, label="Row")
        cmds.separator
        self.rowamount = cmds.intSliderGrp(
            "value1",
            width=150,
            height=12.5,
            field=True,
            minValue=0,
            maxValue=999,
            value=1,
        )

        cmds.setParent("..")

        cmds.rowColumnLayout(numberOfColumns=2, adjustableColumn=True)  # Layout4
        cmds.text(width=80, height=20, label="Column")
        cmds.separator
        self.columnamount = cmds.intSliderGrp(
            "value2",
            width=150,
            height=12.5,
            field=True,
            minValue=0,
            maxValue=999,
            value=1,
        )

        cmds.setParent("..")

        cmds.rowColumnLayout(numberOfColumns=2, adjustableColumn=True)  # Layout5
        cmds.text(width=80, height=20, label="Height Offset")
        cmds.separator
        self.heightoffset = cmds.intSliderGrp(
            "value3",
            width=150,
            height=12.5,
            field=True,
            minValue=1,
            maxValue=4,
            value=1,
        )

        cmds.setParent("..")

        cmds.rowColumnLayout(numberOfColumns=1, adjustableColumn=True)  # Layout6
        self.tileName = cmds.textFieldGrp("value4", label="Tile Name:")

        cmds.rowColumnLayout(numberOfColumns=1, adjustableColumn=True)  # Layout
        self.tileCreateBtn = cmds.button(
            label="Create", width=80, height=15, command=self.createTile
        )

        cmds.showWindow()


myWindow = TileWindow()



RE: does python have a c++ set equivalent container - Larz60+ - Dec-23-2021

There is a python package named maya, but I it's not what you you are looking for.
If you used pip install maya what you installed is a datetime manipulation package, see:
https://pypi.org/project/maya/

cmds is a class of the purchased product Maya (autodesk):
see: https://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2020/ENU/Maya-Scripting/files/GUID-C0F27A50-3DD6-454C-A4D1-9E3C44B3C990-htm.html


RE: Could someone help me finish this ASAP - Larz60+ - Dec-23-2021

Do not start new threads when continuing previous subject. It's against forum rules.


RE: Could someone help me finish this ASAP - JimmyDricks - Dec-23-2021

(Dec-23-2021, 01:04 AM)Larz60+ Wrote: Do not start new threads when continuing previous subject. It's against forum rules.

I don't care. I'm looking for help, not speeches


RE: Could someone help me finish this ASAP - Larz60+ - Dec-23-2021

Please see help: https://python-forum.io/misc.php?action=help&hid=22