13#include <fmt/format.h>
14#include <fmt/ranges.h>
20 b.use_custom_socket_order();
21 b.allow_any_socket_order();
22 b.add_input<
decl::Geometry>(
"Geometry"_ustr).description(
"Geometry to remove attributes from");
23 b.add_output<
decl::Geometry>(
"Geometry"_ustr).propagate_all_geometry().align_with_previous();
27 .description(
"How the attributes to remove are chosen");
50 if (accessor.
contains(*exact_pattern)) {
51 attributes_to_remove.
append(*exact_pattern);
64 attributes_to_remove.
append(attribute_name);
68 if (attributes_to_remove.
is_empty()) {
72 for (
const StringRef attribute_name : attributes_to_remove) {
76 if (write_accessor.
remove(attribute_name)) {
93 if (!geometry_set.
has(type)) {
102 GeometryComponent &component = geometry_set.get_component_for_write(type);
103 return *component.attributes_for_write();
109 instances->ensure_geometry_instances();
118 for (
const int layer_index :
grease_pencil->layers().index_range()) {
120 if (drawing ==
nullptr) {
126 bke::CurvesGeometry &curves = drawing->strokes_for_write();
127 return curves.attributes_for_write();
137 const std::string pattern = params.
extract_input<std::string>(
"Name"_ustr);
138 if (pattern.empty()) {
139 params.
set_output(
"Geometry"_ustr, std::move(geometry_set));
143 std::string pattern_error;
148 params.
set_output(
"Geometry"_ustr, std::move(geometry_set));
162 quoted_attribute_names.
append(fmt::format(
"\"{}\"", attribute_name));
164 const std::string message = fmt::format(
165 fmt::runtime(
TIP_(
"Cannot remove built-in attributes: {}")),
166 fmt::join(quoted_attribute_names,
", "));
171 const std::string message = fmt::format(
172 fmt::runtime(
TIP_(
"Attribute does not exist: \"{}\"")), *exact_pattern);
177 params.
set_output(
"Geometry"_ustr, std::move(geometry_set));
185 ntype.
ui_name =
"Remove Named Attribute";
187 "Delete an attribute with a specified name from a geometry. Typically used to optimize "
Low-level operations for curves.
Low-level operations for grease pencil.
#define NODE_CLASS_ATTRIBUTE
#define GEO_NODE_REMOVE_ATTRIBUTE
#define NOD_REGISTER_NODE(REGISTER_FUNC)
void append(const T &value)
void foreach_attribute(const FunctionRef< void(const AttributeIter &)> fn) const
bool contains(StringRef name) const
AttributeAccessor attributes() const
virtual std::optional< AttributeAccessor > attributes() const
bool remove(const StringRef name)
const bke::CurvesGeometry & strokes() const
void error_message_add(const NodeWarningType type, StringRef message) const
T extract_input(const UString identifier)
T get_input(const UString identifier) const
void used_named_attribute(StringRef attribute_name, NamedAttributeUsage usage)
void set_output(const UString identifier, T &&value)
MutableAttributeAccessor(void *owner, const AttributeAccessorFunctions &fn)
bool match(StringRef query) const
static std::optional< StringPattern > from_str(StringPatternMode mode, StringRef pattern, std::string &r_error)
std::optional< StringRef > exact_pattern() const
bool attribute_name_is_anonymous(const StringRef name)
bool allow_procedural_attribute_access(StringRef attribute_name)
void node_register_type(bNodeType &ntype)
static void node_declare(NodeDeclarationBuilder &b)
static void remove_attributes_recursive(GeometrySet &geometry_set, RemoveAttributeParams ¶ms)
static void node_geo_exec(GeoNodeExecParams params)
static void node_register()
static void remove_attributes(const bke::AttributeAccessor &accessor, FunctionRef< MutableAttributeAccessor()> get_write_accessor, RemoveAttributeParams ¶ms)
const EnumPropertyItem string_pattern_mode_items[]
void geo_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
Instances * get_instances_for_write()
bool has(const GeometryComponent::Type component_type) const
const GeometryComponent * get_component(GeometryComponent::Type component_type) const
GreasePencil * get_grease_pencil_for_write()
static constexpr int _180
std::string ui_description
NodeGeometryExecFunction geometry_node_execute
const char * enum_name_legacy
NodeDeclareFunction declare
Set< std::string > failed_attributes
Set< std::string > removed_attributes