Giter Club home page Giter Club logo

Comments (2)

yuvaltassa avatar yuvaltassa commented on June 26, 2024

This is not a bug, but a somewhat annoying thing that pymjcf does for reasons that are not relevant here. You can do some post processing to remove them like:

from lxml import etree

print('Remove class="/".')
  xml_string = model.to_xml_string('float', precision=3, zero_threshold=1e-7)
  root = etree.XML(xml_string,
                   etree.XMLParser(remove_blank_text=True))
  default_elem = root.find('default')
  root.insert(3, default_elem[0])
  root.remove(default_elem)

  print('Remove hashes from filenames.')
  meshes = [mesh for mesh in root.find('asset').iter() if mesh.tag == 'mesh']
  for mesh in meshes:
    name, extension = mesh.get('file').split('.')
    mesh.set('file', '.'.join((name[:-41], extension)))

  print('Get string from lxml.')
  xml_string = etree.tostring(root, pretty_print=True)
  xml_string = xml_string.replace(b' class="/"', b'')

from dm_control.

hubernikus avatar hubernikus commented on June 26, 2024

Alternatively use the function mjcf.export_with_assets(..):

mjcf.export_with_assets(torso.mjcf_model, self.mjcf_root, "mwe.xml")

That will not require any post processing, but will create duplicates of your mesh with the correct name in the specified folder.

from dm_control.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.