Jump to content

[1.2-1.7] Blender (2.83+) .mu import/export addon


Recommended Posts

rhTnDOz.png

i used a UV preview tool in Unity to look at the UV data and the first UV channel is all over the place.
not even sure how that got created in the first place.
the second UV channel is a perfect match

do you guys have any idea what's causing it?
what should i do in blender to fix it?

Link to comment
Share on other sites

I apologize for any inconvenience due to forgetting to update, but the addon hasn't worked on Blender 2.80 (or 2.81) for a while. I don't know the status of 2.82, but 2.83 (and git master) are known to work.

Link to comment
Share on other sites

Hi @taniwha  I installed your add-on (amazing work btw) and I was able to import mu's and crafts from my ksp folder and import them to blender

My idea was to importa my crafts in blender and then export them to stl to be able to 3d print them but when I import them in my slicing software (cura if you are familiar with it) it says it cant load the stls I generated.  Now, I know this is outside your sphere of "support" for your add-on but I was wondering if maybe there were some thing that I need to do before being able to export to the stl or even when importing my craft

I neve used blender before so I dont understand the way it works (yet) but maybe there is something substantially wrong with what I am doing, can you help me?

Link to comment
Share on other sites

@Jangalit I really don't know, but perhaps the stl exporter doesn't like the collection instances I used to build the loaded craft.

  • At the top level is a single instance that instantiates the collection holding the assembled parts in your craft.
  • At that level each part is an instance of the collection holding the submodels
  • Each submodel is a collection of the objects in the relevant .mu file

My first guess is the stl exporter might not like that the collections holding the above collections are disabled for view, render and select (and are in a different scene, but). To enable the collections, go to the mu_utils scene (second dropdown from the right, top right corner), then in the outliner, go to the filter settings (funnel icon i n the top right) and enable selectable, viewport and render. You can then adjust the settings of the collections.

You might have to export from the mu_utils scene, and even from raw objects (ugh, that would not be fun). However, really, it seems to me to be a deficiency in STL itself.

Actually, I just had a crazy idea and tried it out and found it works: you can export the imported craft file as a .mu file (just make sure the craft object is selected). After exporting the craft file as a model, you can re-import the model and everything will be directly accessible. This works because I made export support collection instances for greebling and sub-model reuse.

The bold is the important bit, the rest is just informative for how things are laid out in blender.

Link to comment
Share on other sites

thank you for your detailed response, I am trying this as I type.

it was a great success, it worked as you said but there were still a couple of problems, when I exported and imported again my craft (a plane) as mu there were no differences in the model but when I exported it in stl and loaded in cura to slice it to 3d print it it was missing some parts like an engine, the nose cone and a large chunk of its left side and I dont know why but I was able to solve this loading the stl in my cad program and creating from scratch (and copy pasting) the missing parts

tomorrow I'll try to print it and if it is successfull it will be all thanks to you! thanks again, a lot

Link to comment
Share on other sites

@taniwha  sorry for tagging you again but you maybe wanted to know if I was successful or not ;)

 

it was a great success, the print came out perfectly, I had a small problem printing the air brakes because they are so thin that the printer couldnt do them but it came out great 

I plan to print some of my rockets and spaceship now :)

Link to comment
Share on other sites

1 hour ago, Jangalit said:

@taniwha  sorry for tagging you again but you maybe wanted to know if I was successful or not ;)

 

it was a great success, the print came out perfectly, I had a small problem printing the air brakes because they are so thin that the printer couldnt do them but it came out great 

I plan to print some of my rockets and spaceship now :)

Pictures, or it didn't happen. 

Link to comment
Share on other sites

  • 4 weeks later...

Traceback (most recent call last):
  File "C:\Program Files\Blender Foundation\Blender 2.83\2.83\scripts\addons\io_object_mu-master\import_craft\import_craft.py", line 106, in execute
    return import_craft_op(self, context, **keywords)
  File "C:\Program Files\Blender Foundation\Blender 2.83\2.83\scripts\addons\io_object_mu-master\import_craft\import_craft.py", line 80, in import_craft_op
    obj = import_craft(filepath)
  File "C:\Program Files\Blender Foundation\Blender 2.83\2.83\scripts\addons\io_object_mu-master\import_craft\import_craft.py", line 60, in import_craft
    part = gamedata.parts[pname].get_model()
  File "C:\Program Files\Blender Foundation\Blender 2.83\2.83\scripts\addons\io_object_mu-master\import_craft\part.py", line 70, in get_model
    Vector((1, 1, 1)) * scale)
  File "C:\Program Files\Blender Foundation\Blender 2.83\2.83\scripts\addons\io_object_mu-master\import_craft\part.py", line 76, in instantiate
    obj.instance_collection = self.model
ReferenceError: StructRNA of type Collection has been removed

location: <unknown location>:-1

bpy.ops.import_object.ksp_craft(filepath="D:\\Games\\steamapps\\common\\Kerbal Space Program\\Ships\\SPH\\Albatross 3.craft")

I'm getting these errors every time I try to import a craft file into blender. it worked for me once yesterday, and now I've been getting these same errors each time. I have no idea what to change, fix, or do differently.

Link to comment
Share on other sites

3 hours ago, FatherOfGold said:

Quick question, why is it that when I take an object and scale it, and then export as mu, it just exports the original object? If I export it as anything else it works just fine, but for some reason there's a problem with exporting as .mu

 

This part may be relevant to your issue:

On 7/26/2020 at 3:25 AM, taniwha said:

you can export the imported craft file as a .mu file (just make sure the craft object is selected).

 

Link to comment
Share on other sites

  • 4 weeks later...
On 8/19/2020 at 10:02 PM, icanhazurhp said:

I'm getting these errors every time I try to import a craft file into blender. it worked for me once yesterday, and now I've been getting these same errors each time. I have no idea what to change, fix, or do differently.

Same issue here, but moving the location of the .craft file I was reading seemed to fix my issue.

 

Additionally I'm getting this error with some AirplanePlus Parts

Traceback (most recent call last):
  File "C:\Users\#####\AppData\Roaming\Blender Foundation\Blender\2.83\scripts\addons\io_object_mu-master\import_craft\import_craft.py", line 109, in execute
    def import_craft_menu_func(self, context):
  File "C:\Users\#####\AppData\Roaming\Blender Foundation\Blender\2.83\scripts\addons\io_object_mu-master\import_craft\import_craft.py", line 83, in import_craft_op
    operator.report({'ERROR'}, e.message)
  File "C:\Users\#####\AppData\Roaming\Blender Foundation\Blender\2.83\scripts\addons\io_object_mu-master\import_craft\import_craft.py", line 62, in import_craft
    if root_pos == None:
KeyError: 'f5jet'

location: <unknown location>:-1

Help would be appreciated.

Edited by wetwetwet
Link to comment
Share on other sites

@wetwetwet First, that stack trace is horrible: I suspect something got corrupted as the line numbers are out.

Anyway, the craft you are attempting to import is looking for a part named "f5jet". It appears you have no such part in your GameData. Likely from a mod that is not installed.

Link to comment
Share on other sites

1 hour ago, taniwha said:

@wetwetwet First, that stack trace is horrible: I suspect something got corrupted as the line numbers are out.

Anyway, the craft you are attempting to import is looking for a part named "f5jet". It appears you have no such part in your GameData. Likely from a mod that is not installed.

The incorrect line numbers were from me modifying the code trying to find where the issue came from.

I should've been more clear, I have the mod "AirplanePlus" currently installed and that part is from that mod. The mod is installed correctly and the only unique thing about it is that none of the parts seem to populate the "ModuleManager.ConfigCache" file from which the GameData class calls.
 

Here's an example of the error within a normal non-modified plugin.

Traceback (most recent call last):
  File "C:\Users\#####\AppData\Roaming\Blender Foundation\Blender\2.83\scripts\addons\io_object_mu-master\import_craft\import_craft.py", line 106, in execute
    return import_craft_op(self, context, **keywords)
  File "C:\Users\#####\AppData\Roaming\Blender Foundation\Blender\2.83\scripts\addons\io_object_mu-master\import_craft\import_craft.py", line 80, in import_craft_op
    obj = import_craft(filepath)
  File "C:\Users\#####\AppData\Roaming\Blender Foundation\Blender\2.83\scripts\addons\io_object_mu-master\import_craft\import_craft.py", line 60, in import_craft
    part = gamedata.parts[pname].get_model()
KeyError: 'f5jet'

location: <unknown location>:-1

It's my hunch that since there seems to be no records of the parts in the ModuleManager.ConfigCache, your plugin isn't able to locate the correct models. I'm clueless as to why the ModuleManager.ConfigCache isn't populating with the parts though, since the mod functions perfectly fine in game. According to a friend, the issue with this mod and your plugin isn't isolated to me; so it seems to be reproduceable on multiple machines.

Edited by wetwetwet
Link to comment
Share on other sites

49 minutes ago, wetwetwet said:

t's my hunch that since there seems to be no records of the parts in the ModuleManager.ConfigCache, your plugin isn't able to locate the correct models.

Yes, this will be the cause. My plugin prioritizes ModuleManager.ConfigCache so that parts created via MM can be used. Thus, yes, the mystery comes down to why those parts are not in the cache. @blowfish do you have any suggestions?

As a workaround, you can remove the cache file (it will be regenerated the next time you run KSP), but if your craft files use any parts created by MM patches, then you'll still have problems.

Reading both the raw part config files and the MM cache file would make loading the first craft file even slower than it is.

Link to comment
Share on other sites

For anyone looking at trying to 3D print .craft files they make in KSP, here's my solution using this tool which should work even if you've never used blender in your life. I built this method after stumbling around for a while; there's probably a better way, but finding it would probably require spending thousands of hours to master Blender, and this seems to work pretty well.

1. Install the tool just like is presented in the original post, including a fresh copy of Blender 2.83 (NOT THE NEWEST VERSION, you need to specifically download 2.83 LTS)

2. Open Blender, and select and hit Delete on the cube, light, and camera that come in the default scene in the center. Alternatively, right click the objects in the top right list, and select delete. If delete isn't working, make sure your mouse is over the main view window; Blender can be a bit weird about what things do depending on where you have your cursor.

3. Select File - Import - KSP Craft (.craft), and wait. If everything works, you should see the craft in the middle of the scene. If you get flashing red warnings, go over the install steps and make sure every step is done perfectly. If it still doesn't work, you might have an issue with the craft file itself, especially if it uses mod parts. Not much to do but build a different craft, and try with unmodded KSP and parts.

4. Left click the model. It should highlight the whole thing. Then in the upper part of the main view window, click Object - Apply - Make Instances Real.

5. Select File - Export - Stl, and you're done!

Just in case you want to make some edits, like deleting RCS blocks or solar panels for easier printing, or removing some of the random extra things that get added on for some parts like landing gear, do the following additional steps:

6. Again in the upper part of the main view window, click Select - Select All by Type - Mesh. You should see only the craft highlighted, with all the extra random lines left black.

7. Click Select - Invert. Highlights should move from craft to everything else.

8. Hit Delete. You should now only see your craft, without all the random extra components KSP needs for lighting, movement, etc.

9. You can now just click on components on the craft, and hit delete to get rid of them. You can also slide them around, rotate them, or scale them using the tiles on the left side of the view window. Most of these work roughly the same as they do in KSP itself (If only KSP had a scale feature outside mods...)

10. When you're done, Select File - Export -Stl.

Of note, the Stl will not be a single solid object, and will instead be made up of a bunch of separate and slightly overlapping parts. I could still print these without issue, but you might have some issues as infill won't work perfectly in many programs. Still, it's better than 95% of other meshes you'll find online, since these at least tend to be watertight.

Hopefully this helps any random 3D printer people who stumble upon this tool, but aren't super knowledgeable about blender. I've had pretty good luck with this working for most stock crafts, and in theory it should be able to pull modded parts as well without too much trouble.

Link to comment
Share on other sites

Biggest thing to watch out for with UVs (especially when importing into blender) is KSP's dds files are upside down. My importer flips the texture mapping rather than the UVs or image so that things look right in when rendered in blender (but the UV editor will be a mess). This means that extra care must be taken when exporting, though just import->export should leave things in a working state.

Link to comment
Share on other sites

Aaah. That could explain the problem with my current version and the one I haven't published yet.

Thanks a lot. Right now, I am managing my texture outside Blender so I will try flipping them.

With the KSP/Specular shadder, Blender is showing two couples of X/Y inputs. What are they configuring ? Right now their values are (1,1) and (0,0).

Edited by DunaColonist
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...