C4D脚本 Python : Sélectionner les polygones orientés 

2014-11-22 00:30 发布 | 作品版权归原作者所有,仅供参考学习,禁止商业使用!

插件脚本 /[脚本预设]
603 4 0
C4D脚本 Python : Sélectionner les polygones orientés
C4D脚本 Python : Sélectionner les polygones orientés - C4D之家 - image_01.png

Une nouvelle version est disponible dans le module Sélections Supplétives.
Sélectionne les polygones ayant la même orientation que le polygone sélectionné.
Une valeur de tolérance permet d'assouplir la sélection.
  1. import c4d
  2. import math
  3. from c4d import gui, Vector
  4. from c4d.utils import GetAngle
  5. from math import isnan

  6. # César Vonc - v 1.1

  7. class Dialogue(gui.GeDialog) :
  8.     annuler = True
  9.     tolerance = 0
  10.    
  11.     def CreateLayout(self) :
  12.         self.GroupBegin(10, c4d.BFH_SCALEFIT, 1, 2)
  13.         self.AddEditNumberArrows(11, c4d.BFH_SCALEFIT)
  14.         self.AddButton(12, c4d.BFH_SCALEFIT, initw = 100, inith = 20, name = "Valider")
  15.         self.GroupEnd()
  16.         return True
  17.    
  18.     def InitValues(self) :
  19.         self.SetTitle("Tolérance")
  20.         self.SetDegree(11, 0)
  21.         return True
  22.    
  23.     def Command(self, id, msg) :
  24.         if id == 12 :
  25.             self.annuler = False
  26.             self.tolerance = self.GetReal(11)
  27.             self.Close()
  28.         return True

  29. def recup_norm(index) :
  30.     poly = op.GetPolygon(index)
  31.     pA = op.GetPoint(poly.a)
  32.     pB = op.GetPoint(poly.b)
  33.     pC = op.GetPoint(poly.c)
  34.     pD = op.GetPoint(poly.d)
  35.     normale = (pA - pC).Cross(pB - pD)
  36.     normale.Normalize()
  37.     return normale

  38. def verif(va, vb, tol) :
  39.     angle = GetAngle(va, vb)
  40.     if isnan(angle) : return True
  41.     if tol >= angle : return True
  42.     else : return False


  43. def main() :
  44.     if not op : return
  45.     if op.GetType() != c4d.Opolygon : return
  46.    
  47.     bs = op.GetPolygonS()
  48.     nbsel = bs.GetCount()
  49.     if nbsel == 0 : return
  50.    
  51.     dial = Dialogue()
  52.     dial.Open(c4d.DLG_TYPE_MODAL)
  53.     if dial.annuler is True : return
  54.    
  55.     nbpol = op.GetPolygonCount()
  56.     normale_ref = Vector(0, 0, 0)
  57.    
  58.     doc.StartUndo()
  59.     doc.AddUndo(c4d.UNDOTYPE_CHANGE_SELECTION, op)
  60.    
  61.     for index, selec in enumerate(bs.GetAll(nbpol)) :
  62.         if not selec: continue
  63.         normale = recup_norm(index)
  64.         normale_ref += normale
  65.    
  66.     normale_ref.Normalize()
  67.     tolerance = dial.tolerance
  68.    
  69.     for i in xrange(nbpol) :
  70.         normale = recup_norm(i)
  71.         if verif(normale_ref, normale, tolerance) is True :
  72.             bs.Select(i)
  73.    
  74.     doc.EndUndo()
  75.     c4d.EventAdd()
  76.    
  77. if __name__=='__main__':
  78.     main()
复制代码


  
  

   

      
      

        
        
          Download(C8D)
        
      


      

        
      
      

      
      
      

      
      
      
   

  

  
  
  




B Color Smilies

Comment :4

插件脚本
软件性质:  
适用版本: C4D R15 - C4D R16 - C4D R17 - C4D R18 - C4D R19 - C4D R20 - C4D R21 - C4D S22 - C4D R23 - C4D S24 - C4D R25 - C4D S26 - C4D 2023 - C4D 2024 - C4D 2025
软件版本: Sélectionner les polygones orientés - v 1.1
系统平台: Win MAC 
软件语言: 英文 
插件来源: https://www.c4d.cn/c4dsoft.html
百套精美Kitbash3D模型专题合集下载
时尚卡通办公室人物C4D立体图标工程下载Cinema 4D Fashion Cartoon Office Character 3D Icon Project Download
C4D科技新闻片头电视栏目频道包装动画工程下载Cinema 4D Technology News Headline TV Program Channel Packaging Animation Project Download
关闭

C4D精选推荐 /10

智能
客服
快速回复 返回顶部 返回列表