能否用代码将Vector Display Ex电池中的箭头改成Vector Display电池中的箭头?(可以不要输入端Width)

我不知道你为啥要改这个电池的属性, Vector Display电池可以右键设置一些属性.你看看有没有你需要的设置.

如果要写代码的话,直接改原有电池的属性比较麻烦,不如自己用python或者C#写一个.

from ghpythonlib.componentbase import executingcomponent as component
import System.Drawing as sd
import Rhino.Geometry as rg

class MyComponent(component):
    lines = []
    colors = []
    
    def RunScript(self, pt, vec, color):
        if not pt :return 
        if not vec :return
        self.lines.append(rg.Line(pt,pt+vec))
        if not color:
            self.colors.append(sd.Color.Red)
        else:
            self.colors.append(color)
        
    def DrawViewportWires(self,args):
        count = len(self.lines)
        for i in xrange(count):
            args.Display.DrawArrow(self.lines[i],self.colors[i])
    
    
    def GetBoundingBox(self):
        if len(self.lines) == None:
            return  rg.BoundingBox.Empty
        else:
            self.box = rg.BoundingBox.Unset
            for line in self.lines:
                self.box.Union(line.BoundingBox)
            return self.box
    
    def get_ClippingBox(self):
        return self.GetBoundingBox()
    
    def BeforeSolveInstance(self):
        self.lines = []
        self.colors = []

文件下载:
Vector Display (python).rar (4.3 KB)

1 个赞

谢谢月神! :hand_with_index_finger_and_thumb_crossed:
代码我还写不出来,只是觉得这两个Vector Display电池可以结合一下(大箭头有点吓人!)。
英文论坛上也有人问类似的问题,但没人回答。Is there a way to customize the color of a vector as visualized by Vector Display component? - Grasshopper - McNeel Forum

那你把我那个python电池打个包,应该就可以了.

嗯~我试了,可以的。