通过ElementColor类得到的颜色中有Element类型、Bylevel,ByCell,其中element可以直接得到对应的rgb值,bylevel可以通过levelDefinitonColor获得,那么ByCell的颜色怎么处理呢?当元素是SharedCell时获得的elementcolor就是ByCell源的
获取到Cell的子元素,从子元素上读取元素的颜色。如果是共享单元的话,就得找到共享单元定义元素,再去迭代子元素去获取颜色
如何找到共享单元定义元素呢?我是想要获取到共享单元的assign material,所以想要得到其颜色
SharedCellElement下有一个GetDefinition函数可以获取到
请问我通过selectionset选择集拿到的元素获取的是shared cells还是直接是下面的shape、shared cell呢?SharedCellElement是不是指下面的shared cell,包不包括shape、mesh呢?如果不包括,shape要怎么处理呢?
我还在文件中发现了有的shape的color是bycell
推测你DGN文件是从DWG转换过来的吧?从MS帮助中可以看到如下英文解释:
Color can also be set ByCell or ByLevel. If ByCell is selected, when a cell is placed the active color is used in place of the color used when the cell was created.ByCell is enabled, by default, only in DWG workmode. You can enable ByCell in DGN workmode by enabling the following capability in the standards, project, or user configuration file: _USTN_CAPABILITY <+CAPABILITY_BYCELL.
大致意思就是说,这个ByCell的颜色是从你创建Cell的颜色来取的,不受当前系统颜色的影响。另外,这个ByCell仅在DWG工作模式默认起作用。