Home | Tutorials | Wiki | Issues
Ask Your Question

splinting a complex SDF into several smaller SDFs.

asked 2018-12-17 08:16:32 -0600

I'm starting now and to facilitate my studies I would like to split SDF files into groups, separated by folders, but I do not want to create a template for each SDF.Is it possible in the same model I have several SDFs, and one main that I load is too?Thankful.

edit retag flag offensive close merge delete

1 Answer

Sort by ¬Ľ oldest newest most voted

answered 2018-12-17 10:54:51 -0600

Do you want to split them in the model level, or an even lower level, like links?

If you want to split by models, you can put each model in a directory, then include them all into the same world SDF using the <include> tag. You can use the same idea to nest models into each other.

If you want a more granular split, you won't be able to do it without using another script language, since SDF doensn't support top-level tags besides <world>, <model>, <light> and <actor>.

Personally, I like using ERB (sudo apt install ruby2.3 ruby2.3-dev or the latest available version):


  # Relative path from where the script is being run to the script's directory
  DIR = File.dirname(__FILE__)

  # Helper function to import another erb file
  def fromFile filename
    return ERB.new(File.read(filename), nil, nil, '_sub01').result(binding)

<model name="model_name">
    <%= fromFile(DIR + "/link1.erb") %>
    <%= fromFile(DIR + "/link2.erb") %>
    <%= fromFile(DIR + "/link3.erb") %>


<link name="link1">

Then run erb model.erb > model.sdf.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-12-17 08:16:32 -0600

Seen: 28 times

Last updated: Dec 17 '18