Hi, I would be glad to help!
The way this (and other Creator script commands) work is just like how Creator works itself. You really are invoking the Creator tool directly with these commands. The rule of thumb is that if a tool has a dialog, you need to pass in all the parameters to that dialog. The rest of the requirements for the tool must be set up before you execute the tool. Just like in Creator, before you launch that tool, you need to make a selection. So in order to make your script work, you need to either select a polygon that has the texture you are looking for, or select the texture itself and make sure no polygons are selected. From your description, it appears you know the texture index... If so, simply do the following before your call the mgExecute:
db = mgGetCurrentDb()
mgDeselectAll (db)
mgSetCurrentTexture (db, index)
Or another alternative, is to just make the selection in creator before you run your script. (assuming your script is not modifying the selection before the call to mgExecute.
thank you Chris, Ill try out :)
Hey Chris just one more question,
this what i wrote:
mgSetCurrentTexture (db, 779)
mgExecute ("Select Similar Faces Texture", None)
mgExecute ("Shift Far Left", None)
mgDeselectAll (db)
mgSetCurrentTexture (db, 780)
mgExecute ("Select Similar Faces Texture", None)
mgExecute ("Shift Far Left", None)
mgDeselectAll (db)
mgSetCurrentTexture (db, 781)
mgExecute ("Select Similar Faces Texture", None)
mgExecute ("Shift Far Left", None)
mgDeselectAll (db)
Basically i want it to search texture by texture and shift to the left. But for some reason it stop working after 2 texture have been done. It doesn't shift the texture for the 781.
Can you tell me if it something that i wrote incorrectly and sorry for the inconvenience it my first time trying to do scripts XD.
Your code is fine except the original suggestion we gave you was not quite right. The Select Similar Faces Texture tool uses the "selected" textures in the texture palette, not the "current" texture in the palette.These are related but there are some subtle differences. For example, there can be one or more "selected textures" but only one "current" texture. Also, the "current" texture is always included in the "selected" textures but setting the "current" texture adds the texture to the "selected" textures. It does not make that texture the only selected texture as you might think. In your case, you want a single texture to be selected before you mgExecute the tool so you cannot use just mgSetCurrentTexture. Instead you must also use some other texture functions to set up the "selected" textures correctly.
So the problem with your original script is that when you called mgSetCurrentTexture the 2nd and subsequent times you were "adding" more textures to the "selected" textures. Consequently, your script was selecting more and more faces each time and shifting them.
Here is a code snippet that you can use instead of the script you posted above. Here you will see a helper function (SelectTexture) that ensures that the index you pass it is the one and only texture selected. So in your original script, instead of calling mgSetCurrentTexture, you simply call SelectTexture instead.
def SelectTexture(db, index):
# since the current texture is always "selected"
# we set the current texture first
mgSetCurrentTexture(db, index)
# then we clear the selected textures.# since the current texture stays selected,
# after this function, the "current" texture
# will be the only "selected" texture
mgDeselectAllTextures(db)
db = mgGetCurrentDb()
mgDeselectAll (db)SelectTexture (db, 779)
mgExecute ("Select Similar Faces Texture", None)
mgExecute ("Shift Far Left", None)
mgDeselectAll (db)SelectTexture (db, 780)
mgExecute ("Select Similar Faces Texture", None)
mgExecute ("Shift Far Left", None)
mgDeselectAll (db)SelectTexture (db, 781)
mgExecute ("Select Similar Faces Texture", None)
mgExecute ("Shift Far Left", None)
mgDeselectAll (db)
thank you Steve aprreciate your help :)
Craig
Hi,
I am trying to use this script function
mgExecute ("Select Similar Faces Texture", None)
But when i type a number in the None area it give me this error
E: Traceback (most recent call last):
E: File "<string>", line 1, in <module>
E: TypeError: in method 'mgExecute', argument 2 of type 'mgparamblock'
Is there another function that I can use or write it differently to make it search a designated face ?
thank you
1 person has this question