WIP Beta released Blender Script to Export Nodes and Beams

Discussion in 'Utilities and programming' started by rmikebaker, Dec 30, 2013.

?

Would you find this script useful?

  1. Yes

    378 vote(s)
    96.4%
  2. Not really

    14 vote(s)
    3.6%
  1. rmikebaker

    rmikebaker
    Expand Collapse

    Joined:
    Oct 27, 2013
    Messages:
    36

    ** 1/4/2014 - BETA 0.0.1 RELEASED **

    Ok - so I've decided to release a beta to the wild
    :D

    I'm certain it's not perfect, so if you try it out and find issues, or have suggestions, please let me know. I'll do what I can to address them in a timely manner. Here's the basic stuff you need to know to start using it:

    View attachment export_jbeam_0.0.1.zip

    INSTALLATION


    • FIRST - I'VE ONLY TESTED THIS WITH THE LATEST VERSION OF BLENDER. IF YOU HAVE AN OLDER VERSION, IT MAY OR MAY NOT WORK. BLENDER IS FREE, SO YOU CAN EASILY GO DOWNLOAD A NEW VERSION.
    • Download the .ZIP and extract the .py file to your hard drive somewhere.
    • In Blender, go to AddOns, inside of User Preferences, and click "Install from File...". Browse and select the .py file, and then click the "Install from File..." button.
    • Now, in AddOns, click "User" under "Categories". The Export Jbeam (.jbeam) add-on should show up in the list. Click the checkbox out to the right to enable it.
    • Don't forget to click the "Save User Settings" button.

    USAGE


    • First, you need to make sure you save the Blender scene you're working on, to your hard drive. The exporter will complain if you don't.
    • If you want to prefix an object's nodes with a particular value, select the object, and in the Properties Window on the right side of the screen, scroll to the bottom, and add a custom property to the object called 'JbeamNodePrefix', with the value you want to use.
    • Now, to export one or more objects (presumably, node/beam structures), make sure they are the only selected objects.
    • In the 3D view, press the spacebar, and in the search window, type "Export jbeam". You should see the jbeam exporter (with version number) show up in the list. Press Enter to run the exporter.
    • A separate file for each object (named "<objectname>.jbeam") will be created in the folder where your .blend file is saved.
    • Open each file, and copy the node and beam entries over to the "real" .jbeam file(s) for your vehicle.

    NOTES



    • [*=left]The export script will only export MESH objects.
      [*=left]I added some basic error handling, so if you make it go crazy, just let me know what you did, and I'll try to add some code to deal with it if I can.
      [*=left]If there are any Blender/Python guru's out there who want to take this script and improve it for the community, feel free. I'm releasing it as essentially open-source.

    Hope this is helpful, although it may be getting less so with each new version of Greg Blast's editor ;)
    Great work Greg!



    LATEST - 1/1/2014:

    I think I've tackled the memory issue I was having.

    I've added the ability for the script to read a custom property on the node/beam object in Blender, that's then used to prefix the node names. The property is called 'JbeamNodePrefix', so if set on the object, it will be used to prefix the names of all the nodes. Also, after the prefix, I'm adding a 'l' or 'r' to indicate whether the node has a positive X value or a negative X value. If the X value is 0, I don't add anything.

    So, you could model the frame structure, and prefix all nodes with 'fr', model the body, and prefix all those nodes with 'b', and so on. Nodes numbers increase as you move from front to back (-Y to +Y), from left to right (+X to -X), and from bottom to top (-Z to +Z).

    The script acts upon all selected objects, and creates a separate file for each object, in the folder where the .blend file is saved. So if you have two objects selected, say, 'frame' and 'body', it would create two files, 'frame.jbeam' and 'body.jbeam' in the folder where you saved your .blend file.

    Using a simple icosphere that I moved and scaled a bit, here's a portion of what was generated (using a prefix of 'ico-' for the nodes):

    //--Nodes--
    ["ico-0",0.0,-3.83,1.637],
    ["ico-l1",0.444,-3.59,2.356],
    ["ico-r2",-0.444,-3.59,0.919],

    .
    .
    .
    //--Beams--
    ["ico-r11","ico-20"],
    ["ico-l14","ico-l7"],
    ["ico-l4","ico-r2"],
    ["ico-l18","ico-l7"],
    ["ico-l26","ico-l33"],
    ["ico-r22","ico-20"],
    .
    .
    .

    I think I'm close to releasing this as a beta, but wanted to provide a little more of the details to see if I'm going down a good path or not.


    ORIGINAL POST IS BELOW:


    As an experimental complement to Greg Blast's very nice vehicle editor program, I wanted to see if I could create some basic node/beam structures in Blender, and export them to be shoved into a .jbeam file. After some hair-pulling and cursing, I've got a script that does what I wanted, although it does have a slight side-effect due to Blender's odd internal handling of things, which I'll explain shortly.

    Here's a couple of screenshots to show an icosphere in Blender, and then the exported nodes/beams in Greg Blast's vehicle editor. No way I could do that by hand in his editor, so must have come from Blender ;)

    I'm a Blender noob, so someone with more knowledge could probably take a look at the script and give some pointers.

    So, that's the good. Now, the not-so-good (AFAIK).

    Blender will keep certain objects in memory, even if they're not being used, and you can mark objects, meshes, etc. to be saved in your .blend file, even if they have no 'users'. So, the reason I mention it, is because I couldn't find a (good/easy) way to get the transformed mesh data for an object without making a copy of the object, and then removing it from the scene after exporting the data. Once it's removed, it has zero users, so if you save your file, Blender won't save it, and when you reload your file, it won't be there. But, as long as you continue to export objects without saving and reloading your file, you'll have additional meshes being stored in memory. If you click the mesh drop-down for an object, you'll see them listed :mad:

    Perhaps someone with more Blender knowledge could comment as to whether there's an easier way to accomplish this.

    Also, I'm just sorting the nodes based on their location, and assigning them IDs based on their index (i.e. - "n0", "n1", etc.), which isn't optimal. If you load them into Greg's editor, you can easily rename them, but that could start to be a pain.

    Just wanted to see if any Blender users out there would find this useful. If so, please let me know...

    EDIT1: After some more tinkering around, I think I've found a way to clean up the memory, or at least it seems like it is. Positive progress :)
     

    Attached Files:

    • BlenderExportTest-1.png
    • BlenderExportTest-1a.png
    #1 rmikebaker, Dec 30, 2013
    Last edited: Jan 5, 2014
    • Like Like x 3
  2. GregBlast

    GregBlast
    Expand Collapse

    Joined:
    Aug 12, 2013
    Messages:
    224
    Well as I shown you I can display models exported from Blender in other formats than Collada. So you could actually work directly on the model in my editor as well.

    But it's a sure thing that a script that generates your nodes and beams is gonna be the fastest way. However you'll always be restricted to some basic geometry. I can't think of a script that would create a good node / beam structure for an entire vehicle body.

    Anyways maybe you should talk to Ivankio because he made the same kind of things for Maya. He could create a foot ball (or football ball, or soccer ball, ... soccer foot ball ? whatever lol) that was working fine immediately after exporting from Maya. But still as I said you'll remain limited to basic geometry unless you can create a very complex script.
     
  3. rmikebaker

    rmikebaker
    Expand Collapse

    Joined:
    Oct 27, 2013
    Messages:
    36
    Hey Greg - Thanks for the comments. Yes, I hope you add support to your editor for loading actual model meshes (.OBJ, etc.) that can be visible alongside the node/beam structure. That's the key, whether it's in a modeling program, editor, or whatever.

    Creating the nodes/beams is still going to be a manual process. I didn't mean to imply that the actual model mesh would be magically transformed into a node/beam structure by the script. Not at all. Just that you could create additional objects in Blender to represent the nodes/beams, and then export those objects as a list of nodes and beams, so you could copy/paste them into your .jbeam file. Make sense?

    My script doesn't even create a valid .jbeam file - just a list of nodes and beams - that's it.

    Imagine the icosphere I posted as being the jbeam structure for some other, more complicated mesh. That was the idea I was getting at. Just that you could create it alongside your real model mesh, to make things easier.

    Oh, and my comment about not being able to create it with your editor, I just meant that due to the icosphere geometry, it would take me (personally) a bit of time to create it manually. It's a base object type in Blender, so I just had to point/click to get one in my scene. I didn't create it by hand.
     
  4. GregBlast

    GregBlast
    Expand Collapse

    Joined:
    Aug 12, 2013
    Messages:
    224
    Yeah I just meant it's not about manually creating it from mind but with the model inside. I showed you a pic already with your model inside the editor so all I need myself to release that feature is to be able to test on an obj/3ds with correct scale and that I can eventually get working in-game (maybe a static thing like the flipramp).

    Also I will be adding the possibility to generate some predefined mesh-based node/beam structures like a cube, a sphere etc... I don't know about the icosphere though.

    But with your script if you don't expressly aim at a working node/beam structure then you can actually generate a basic structure for a whole vehicle. At least the nodes. I guess you can get a low-poly version of your model and generate nodes for all points. And well the beams for the low-poly might be good as a base structure (which will still need to be reinforced a lot later on though).
     
  5. Cardinal799

    Cardinal799
    Expand Collapse

    Joined:
    Oct 15, 2013
    Messages:
    1,070
    Wouldn't there somehow be a way to make Blender create N/Bs from the visual mesh? I know that would be an ass to code, I think, but if you simply selected, say, the main frame and hood, it would only code the main frame and hood? Suspension would be completed with the tool in this thread, as Blender probably will not be able to tell the difference between a leaf spring and a double wishbone setup. :p
     
  6. rmikebaker

    rmikebaker
    Expand Collapse

    Joined:
    Oct 27, 2013
    Messages:
    36
    If you look at nodes/beams in Greg's Editor (3D view) and then compare them to the actual 3D model mesh, it might be a stretch to auto-magically generate them. Not saying it's beyond the realm of possibility, but probably beyond what I'd attempt to do.

    You could select vertices from your model mesh, and have the exporter just use those as the nodes. But, it would have to make some assumptions about the beams (i.e. - what's connected to what). Could get ugly.

    There are some possibilities for improvement though, and I'm already looking at a few enhancements before doing a beta release.

    Thanks for the suggestion/question. I want to make this useful, so everyone feel free to provide input and suggestions as you think of them.

    I still think Greg Blast's editor is the ultimate tool though. If/when I generate nodes/beams from Blender, I'm still going to be using Greg's editor afterwards...
     
  7. Cardinal799

    Cardinal799
    Expand Collapse

    Joined:
    Oct 15, 2013
    Messages:
    1,070
    That sounds great!
    Also, any progress on the motorhome? :3
     
  8. rmikebaker

    rmikebaker
    Expand Collapse

    Joined:
    Oct 27, 2013
    Messages:
    36
    Yeah, I need to post an update with pics :)
     
  9. logoster

    logoster
    Expand Collapse

    Joined:
    Sep 5, 2012
    Messages:
    2,082
    question, will this script auto detect nodes and beam positions based on the model? or would it basicly be like a 3d node/beam editor? (like the editorizer from rigs of rods)
     
  10. rmikebaker

    rmikebaker
    Expand Collapse

    Joined:
    Oct 27, 2013
    Messages:
    36
    See post #6.

    No "auto-magic" generation of nodes/beams. You would build a simple node/beam structure in Blender alongside your 3D model mesh, and then export the vertices/edges (i.e. - nodes/beams) for use inside of a .jbeam file.
     
  11. GregBlast

    GregBlast
    Expand Collapse

    Joined:
    Aug 12, 2013
    Messages:
    224
    I think I have some enemies... don't you ?
     
  12. BoaMan

    BoaMan
    Expand Collapse

    Joined:
    Aug 4, 2013
    Messages:
    35
    If you released this I'd love it. It'd simplify the process if I could make the nodes/beams in my editor and then just have them immediately out.
     
  13. rmikebaker

    rmikebaker
    Expand Collapse

    Joined:
    Oct 27, 2013
    Messages:
    36
    Original post updated with latest info...
     
  14. ultranew_b

    ultranew_b
    Expand Collapse

    Joined:
    Nov 12, 2013
    Messages:
    140
    This is brilliant !

    I will def try this out !

    :D
     
  15. Narwhal

    Narwhal
    Expand Collapse

    Joined:
    Aug 4, 2013
    Messages:
    1,698
    this is awesome!!!!
    i am making a bus in blender (i have the rear end of it jbeamed) and this would help so much.

    keep up the good work!
     
  16. rmikebaker

    rmikebaker
    Expand Collapse

    Joined:
    Oct 27, 2013
    Messages:
    36
    Beta v0.0.1 Released

    Updated first post with beta release info. Enjoy !
     
  17. ryakra

    ryakra
    Expand Collapse

    Joined:
    Aug 5, 2013
    Messages:
    213
    Re: Beta v0.0.1 Released

    I just tested it on a car model I had, and it froze blender.
    I waited a few minuets and it didn't recover, I checked in task manager and the memory it was using wasn't going up or down which means it was a full freeze.
    If you can tell me where a log would be I could try and sent it to you for some debuging. (I am using the latest! 2.69 to be exact)
     
  18. rmikebaker

    rmikebaker
    Expand Collapse

    Joined:
    Oct 27, 2013
    Messages:
    36
    Re: Beta v0.0.1 Released

    Did you try to export a large model, or just a simple node/beam structure? The script isn't super efficient, so exporting something with a lot of vertices/edges will take a bit of time - don't know how long.

    Try exporting something simple first, like a cube or something, to make sure it's at least functioning...
     
  19. Tatangjose

    Tatangjose
    Expand Collapse

    Joined:
    Jul 4, 2013
    Messages:
    40
    i am super greatful tou made a blender n/b maker. i use it to make the n/b of all my projects in ROR this would be an incredible help!! are you planning on having the node numbers visible?
     
  20. rmikebaker

    rmikebaker
    Expand Collapse

    Joined:
    Oct 27, 2013
    Messages:
    36
    Re: Beta v0.0.1 Released

    Did you get the export script working?
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice