Module: DFC::Attribute

Class Method Summary # collapse

Class Method Details

.get_attr_to_hash(entity, filter = nil) ⇒ Hash

获取实体的属性 Hash

Examples:

group = Sketchup.active_model.entities.add_group
group.set_attribute('dfc', 'test', 'hhhh')
hash = DFC::Attribute.attr_to_hash(group)
puts hash
# -> {"dfc"=>{"test"=>"hhhh"}}

Parameters:

  • entity (Sketchup::Entity)

    Sketchup 实体对象

  • filter (Array, NilClass) (defaults to: nil)

    可空。过滤器,仅提取 filter 里边的字典

Returns:

  • (Hash)

    属性 Hash。如果没有属性,返回的是空的 Hash

Version:

  • 2.2.0

.set_hash_to_attr(entity, hash) ⇒ NilClass

将 Hash 直接设置为实体的属性

Examples:

group = Sketchup.active_model.entities.add_group
hash = {
	"dfc" => {
		"test" => "hhhh"
	}
}
DFC::Attribute.set_hash_to_attr(group, hash)
puts group.get_attribute('dfc', 'test') # -> "hhhh"

Parameters:

  • entity (Sketchup::Entity)

    Sketchup 实体对象

  • hash (Hash)

    属性值,二级 Hash

Returns:

  • (NilClass)

    返回nil

Version:

  • 2.1.2