Jun-15-2019, 10:19 PM
Hi,
I am working on a book row generator. For that I want to let the customer place a curve and the books should be placed on that curve. Because I failed to do it with a normal curve I am trying it now with MASH. My problem is now that I can't figure out a way to bring the curve into the Mashnode via my script.
Right now I deleted everything that is in connection with the curve Node. But I was also trying to use ‘mashNetwork.createCurveWarp’, but I can't figure out what the attributes for the command is.
Thank you for every help and hint
I am working on a book row generator. For that I want to let the customer place a curve and the books should be placed on that curve. Because I failed to do it with a normal curve I am trying it now with MASH. My problem is now that I can't figure out a way to bring the curve into the Mashnode via my script.
Right now I deleted everything that is in connection with the curve Node. But I was also trying to use ‘mashNetwork.createCurveWarp’, but I can't figure out what the attributes for the command is.
Thank you for every help and hint
import os import MASH.api as mapi import maya.cmds as cmds class SetMaterial: # create a shader shader = cmds.shadingNode("blinn", asShader=True) # a file texture node file_node = cmds.shadingNode("file", asTexture=True) # a shading group shading_group = cmds.sets(renderable=True, noSurfaceShader=True, empty=True) # connect shader to sg surface shader cmds.connectAttr('%s.outColor' % shader, '%s.surfaceShader' % shading_group) # connect file texture node to shader's color cmds.connectAttr('%s.outColor' % file_node, '%s.color' % shader) class BookGenerator: def __init__(self): self.win=cmds.window('Book Generator', exists=True) if (self.win == 1): cmds.deleteUI('Book Generator', exist=True) self.win = cmds.window(title='Book Generator', widthHeight=(450, 850)) cmds.columnLayout(adj=True, rs=10) cmds.text('!Please select spline!') self.sizeBooks = cmds.intSliderGrp(l="Size of Books", min=0, max=10, field=True) self.thicknessBooks = cmds.intSliderGrp(l="Thickness of Books", min=0, max=10, field=True) self.randomSize = cmds.floatSliderGrp(l="Randomize Size", min=0, max=1, field=True) self.numberOfBooks = cmds.intSliderGrp(l="Number of Books", min=1, max=30, field=True) self.saveLocation = self.create_custom_save_location() cmds.button(label='Create mesh Network', command=self.createMashNetwork) cmds.showWindow(self.win) ####create save location###### def create_custom_save_location(self, path_name='customData'): proj_dir = cmds.internalVar(userWorkspaceDir=True) new_dir = os.path.join(proj_dir, path_name) if not os.path.exists(new_dir): os.makedirs(new_dir) return new_dir def load_fbx(self, *args): self.find_Book = os.path.join(self.saveLocation, 'Book.fbx') cmds.file(self.find_Book, i=True, type='fbx') cmds.select('Line002') #create Mesh Network def createMashNetwork(self, *args): self.loadFbx = self.load_fbx() cmds.select('Line002') # set material self.material = SetMaterial() #self.material.apply_mat_to_object('Line002') numberOfBooks = cmds.intSliderGrp(self.numberOfBooks, q=True, v=True) scaleOfRandomize = cmds.floatSliderGrp(self.randomSize, q=True, v=True) sizeBooks = cmds.intSliderGrp(self.sizeBooks, q=True, v=True) thicknessBooks = cmds.intSliderGrp(self.thicknessBooks, q=True, v=True) self.mashNetwork = mapi.Network() # creating the network self.mashNetwork.createNetwork(name="MASH_Network#") self.mashNetwork.setPointCount(numberOfBooks) # setting the distribution distance to 0 cmds.setAttr(self.mashNetwork.distribute + ".amplitudeX",numberOfBooks*3) # creating the randomNode self.randomNode = self.mashNetwork.addNode("MASH_Random") # changing the initial randomnode attributes cmds.setAttr(self.randomNode.name + ".positionX", 0) cmds.setAttr(self.randomNode.name + ".positionY", 0) cmds.setAttr(self.randomNode.name + ".positionZ", 0) # creating the randomNode self.randomNode = self.mashNetwork.addNode("MASH_Random") # changing the initial randomnode attributes cmds.setAttr(self.randomNode.name + ".scaleY", sizeBooks ) cmds.setAttr(self.randomNode.name + ". scaleX", thicknessBooks) cmds.setAttr(self.randomNode.name + ".randEnvelope", scaleOfRandomize) cmds.setAttr(self.randomNode.name + ".Envelope", 0.2) cmds.select('MASH5_ReproMesh') self.mashNetwork.createCurveWarp(name='Warped') BookGenerator()