pathtext

8 篇文章 0 订阅
4 篇文章 0 订阅
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <title> New Document </title>
  <style>
/*
.node {
  stroke: #ffffff;
  stroke-width: 0.1px;
}
*/
.link {
  stroke: #999;
  stroke-opacity: .6;
}

</style>
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
 </head>

<body>
<script src="d3.min.js"></script>
<script>

var width = 960,
    height = 500;

var colors = d3.scale.category20();

var force = d3.layout.force()
    .charge(-320)
    .linkDistance(100)
    .size([width, height]);

var svg = d3.select("body").append("svg")
    .attr("width", width)
    .attr("height", height);

d3.json("miserables1.json", function(error, graph) {
  force
      .nodes(graph.nodes)
      .links(graph.links)
      .on("tick", tick)
      .start();

  var link = svg.selectAll(".link")
      .data(graph.links)
      .enter().append("line")
      .attr("class", "link")
      .attr("id", function(d) { return d.value; })
      .style("stroke-width", function(d) { return Math.sqrt(d.value); });

link.append('text')
    /*.attr('x', 10)
    .attr('y', 20)
    .style('fill', 'steelblue')
    .style('font-size', '24px')
    .style('font-weight', 'bold')
    .append('textPath')
    .attr({//引用路径
        'xlink:href': function(d) { return "'#"+d.value+"'"; }
    })*/
    .text(function(d) { return d.value; });

  var node = svg.selectAll(".node")
      .data(graph.nodes)
      .enter().append("g")
      .attr("class", "node")
      .call(force.drag);



node.append("circle")
      .attr("r", 10)
      .style("fill", function(d) { return colors(d.group); });

 
 node.append("title")
      .text(function(d) { return d.name});
 node.append("text")
    .attr("x", 12)
    .attr("dy", ".35em")
    .text(function(d) { return d.name; });
      

  /*force.on("tick", function() {
    link.attr("x1", function(d) { return d.source.x; })
        .attr("y1", function(d) { return d.source.y; })
        .attr("x2", function(d) { return d.target.x; })
        .attr("y2", function(d) { return d.target.y; });
    node
      .attr("transform", function(d) {
              return "translate(" + d.x + "," + d.y + ")";
      });
  });*/
  function tick() {//打点更新坐标
  link
      .attr("x1", function(d) { return d.source.x; })
      .attr("y1", function(d) { return d.source.y; })
      .attr("x2", function(d) { return d.target.x; })
      .attr("y2", function(d) { return d.target.y; });

  node
      .attr("transform", function(d) {
              return "translate(" + d.x + "," + d.y + ")";
      });
}

});

</script>
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要编写一个Python脚本来实现查找并绑定脚本的功能,可以按照以下步骤进行操作: 1. 导入必要的模块:在脚本开始处导入所需的模块,比如maya.cmds和os。 2. 创建UI界面:使用maya.cmds创建一个窗体,并添加所需的UI元素,例如按钮、下拉菜单和标签。 3. 实现功能函数:编写函数来实现具体的功能。例如,get_location_desk_list()函数可以用来获取本地磁盘列表,并将其添加到下拉菜单中。 4. 编写事件处理函数:为UI元素添加相应的事件处理函数。例如,当用户选择某个磁盘路径时,可以编写change_desk()函数来更新当前选择路径的显示。 5. 实现导入OBJ文件功能:编写函数来根据用户选择的路径,自动导入路径与子目录下的所有OBJ文件,并重命名它们。可以分别编写import_obj_re()函数实现导入所有OBJ文件的功能,以及import_obj_single()函数实现导入当前路径OBJ文件的功能。 以下是一个示例脚本的代码: ```python import maya.cmds as mc import os # 创建UI界面 def create_ui(): mc.window(title='磁盘路径', height=600) mc.columnLayout() # 添加目录下拉菜单 op = mc.optionMenu(label='目录', cc="change_desk()") # 添加显示当前选择路径的标签 pathText = mc.text(label='CurrentPath: C:/') # 获取本地磁盘并初始化菜单 get_location_desk_list() # 添加点击按钮 mc.button(label='导入所有OBJ', c='import_obj_re()') mc.button(label='导入当前路径OBJ', c='import_obj_single()') mc.showWindow() # 获取本地磁盘 def get_location_desk_list(): disk_list = [] for d in string.ascii_uppercase: disk = d + ':' if os.path.isdir(disk): disk_list.append(disk + "/") mc.menuItem(label=disk + "/") return disk_list # 更新当前选择路径的显示 def change_desk(): selected_path = mc.optionMenu(op, q=True, value=True) mc.text(pathText, e=True, label='CurrentPath: ' + selected_path) # 导入所有OBJ文件 def import_obj_re(): selected_path = mc.optionMenu(op, q=True, value=True) # 遍历路径与子目录下的所有OBJ文件,并导入并重命名 for root, dirs, files in os.walk(selected_path): for file in files: if file.endswith(".obj"): mc.file(os.path.join(root, file), i=True, renameAll=True) # 导入当前路径OBJ文件 def import_obj_single(): selected_path = mc.optionMenu(op, q=True, value=True) # 导入当前路径下的所有OBJ文件,并重命名 for file in os.listdir(selected_path): if file.endswith(".obj"): mc.file(os.path.join(selected_path, file), i=True, renameAll=True) # 执行脚本 create_ui() ``` 请注意,这只是一个示例脚本,具体的实现可能根据实际需求有所调整。在使用此脚本之前,请确保已正确安装Maya软件,并了解如何编写和运行Python脚本。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [使用Python编写Maya脚本插件批量导入Obj文件](https://blog.csdn.net/qq_34766000/article/details/97276222)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值