@@ -909,7 +909,8 @@ void addNodeModelToXML(const TreeNodeManifest& model,
909909void addTreeToXML (const Tree& tree,
910910 XMLDocument& doc,
911911 XMLElement* rootXML,
912- bool add_metadata)
912+ bool add_metadata,
913+ bool add_builtin_models)
913914{
914915 std::function<void (const TreeNode&, XMLElement*)> addNode;
915916 addNode = [&](const TreeNode& node,
@@ -991,7 +992,7 @@ void addTreeToXML(const Tree& tree,
991992 std::map<std::string, const TreeNodeManifest*> ordered_models;
992993 for (const auto & [registration_ID, model] : tree.manifests )
993994 {
994- if (temp_factory.builtinNodes ().count (registration_ID) == 0 )
995+ if (add_builtin_models || ! temp_factory.builtinNodes ().count (registration_ID))
995996 {
996997 ordered_models.insert ( {registration_ID, &model} );
997998 }
@@ -1052,15 +1053,15 @@ Tree buildTreeFromFile(const BehaviorTreeFactory& factory,
10521053 return parser.instantiateTree (blackboard);
10531054}
10541055
1055- std::string WriteTreeToXML (const Tree &tree, bool add_metadata)
1056+ std::string WriteTreeToXML (const Tree &tree, bool add_metadata, bool add_builtin_models )
10561057{
10571058 XMLDocument doc;
10581059
10591060 XMLElement* rootXML = doc.NewElement (" root" );
10601061 rootXML->SetAttribute (" BTCPP_format" , 4 );
10611062 doc.InsertFirstChild (rootXML);
10621063
1063- addTreeToXML (tree, doc, rootXML, add_metadata);
1064+ addTreeToXML (tree, doc, rootXML, add_metadata, add_builtin_models );
10641065
10651066 XMLPrinter printer;
10661067 doc.Print (&printer);
0 commit comments