小编Ste*_*tre的帖子

如何获取选定对象Python Maya的名称

大家好,我有此过程程序可通过Python在Maya中创建不同的对象。创建完这些元素之后,我想让用户可以选择其中一些对象,并且可以通过按钮将其删除...问题是我不了解如何获取对象的名称...到目前为止,我的代码是这样。

#Deletes Selected Element selected from the user
def DeleteSelection(*args):
    selected = cmds.ls(sl=1,sn=True)
    print(selected)
    #if(cmds.objExists()):
        #cmds.delete(selected)
Run Code Online (Sandbox Code Playgroud)

在GUI中,我有这个按钮...

cmds.button(label='Delete Selection', w=150,h=30,command=DeleteSelection)
Run Code Online (Sandbox Code Playgroud)

python ls selection maya

4
推荐指数
1
解决办法
1万
查看次数

realloc引起的分段错误?

嘿,我正试图解决这个学校的运动..

编写一个程序,继续读取字符串并连接它们(将它们添加到单个字符串).串联应该在一个函数中发生,如果成功则返回1,如果失败则返回0.对于内存分配,只使用realloc!

调试程序时我没有收到任何错误,但是当我尝试运行程序时,在插入字符串之后,唯一出现的是"Segmentation Fault",它会是什么?这是代码:

#include<stdlib.h>
#include<stdio.h>
#include<string.h>

int cat(char **, char *);

int main(void)
{
  char string[51];
  char *output=NULL;
  char choice;
  do
  {
    printf("Please enter a string [<50 chars]: ");
    fgets(string,50,stdin);
    if(string[strlen(string)-1]=='\n') /* if newline was read as well */
      string[strlen(string)-1]=0;      /* discard it */
    if(cat(&output,string))
      printf("\n\nThe string now contains:\n%s\n",output);
    else
    {
      printf("error: memory (re-)allocation failed!\n\n");
      return 1; /* exit with error */ 
    }
    printf("Continue? (y/n) - ");
    fgets(string,3,stdin); /* read input from keyboard - leave a safety buffer to …
Run Code Online (Sandbox Code Playgroud)

c realloc dma

1
推荐指数
1
解决办法
757
查看次数

可调整大小的窗口命令 python-maya

自从我开始用Python编写脚本以来,我就一直遇到这个问题。

尽管我将“宽度”和“高度”标志添加到主“窗口”命令中,但大小始终根据最近的操作进行调整。。明白我的意思了吗?

难道它不应该总是给我在宽度和高度标志后输入的相同大小吗?

问题是什么?

我不想使用相当大的标志,因为我总是需要在使用窗口时调整它们。

这种奇怪行为背后的真正原因可能是什么?

我想打开我的窗口,无论我通过拖动窗口的一角调整其大小多少次......

如果需要的话,这是我的Python代码......

import maya.cmds as cmds



def createGUI():

    #If the window already exists, it will delete it.
    if cmds.window('myWindow',exists=True): 
        cmds.deleteUI('myWindow')

    #Creation window command
    winControl=cmds.window('myWindow',title='BookShelf Generator',resizeToFitChildren=True, sizeable=False) #s=False does not allow the user to change the size of the window

    #Windows Layout
    #Top Part
    #Header image
    cmds.rowColumnLayout(w=400)
    cmds.image( image='/home/s4915717/Stefano_Feltre_Scripting/artefacts/Images/UIheader02.png' )
    cmds.setParent("..")

    cmds.columnLayout(adjustableColumn=True,rowSpacing=0)
    cmds.frameLayout( label='BookShelf Options',collapsable=False, mw=5, mh=5 )
    cmds.text(label='Modify the value on the interace to create different aspect of the BookShelf.', align='center', height = 20) …
Run Code Online (Sandbox Code Playgroud)

python user-interface command window maya

1
推荐指数
1
解决办法
4403
查看次数

标签 统计

maya ×2

python ×2

c ×1

command ×1

dma ×1

ls ×1

realloc ×1

selection ×1

user-interface ×1

window ×1