3D new library for Mechanical CAD exporting and enclosure design

hi xavierw,

i think that has to do with FreeCAD - the problem is if you combine a object in FreeCAD with the union tool most of the time it works - but sometimes the colors are lost - i have not found a reliable way to reproduce this…
if you use the array modifier the colors are lost definitely.
so if - for some reason - in some way the importer tries to union the parts this could happen…
sunny greetings
stefan

Hi Stefan,

Thanks for your input. It’s strange as the components that lost there colour weren’t unioned. I need to do some more testing: I reckon it won’t always be the same components that lose their colour. Take the TO92 package - that’s a very simple model I drew myself.

TO92.zip (24.0 KB)
Zip file contains three files: to92.stp which is the raw file that I drew in Creo, then the TO-92_Inline…step the output of FreeCAD once aligned to the footprint and the resulting VRML file which appears fine in KiCAD 3D viewer.

did you exported the board fusing all the objects? fusion export option sometimes may produce weird result because of Open Cascade engine … particularly when object are detached or co-planar
http://forum.freecadweb.org/viewtopic.php?t=8451#p69489

not related to the size… I exported >100M without any issue…

here the two models and board produced by kicad StepUp exporter…

Result :smiley:
Those components were in fact fine, but it dawned on me that they went all wrong at the end. Turns out it was the horizontal resistor that was not unioned / fused which makes all the following step components lose their colour.

Having now fused that resistor and re-exported, it’s all OK :smile: - thanks for your help along this thread. I’ve been the biggest spammer with my newbie questions :blush: but hopefully it will help others.

Now to streamline my step / vrml files and try to get them at a managable size once FreeCADed!

that is a FreeCAD known beahviour
http://forum.freecadweb.org/viewtopic.php?t=6685
I don’t know if can be managed because of the OCE engine…

Thanks for pointing out the problem with FreeCAD bloating the STEP files. For me that means that I’ll have to go create a lightweight STEP library for kicad some time in the future. I already have an IGES library which is capable of creating PCB mechanical assembly models but (a) I need to make some large changes to kicad so that Export functions can be implemented by plugins and (b) my library has no provisions to actually display a model. Since I only work on the code in what little spare time I have, it will be a year or more before we see any such features in kicad. At least for now there’s FreeCAD, even if it bloats the models by a ridiculous amount.

@cbernardo I would say “At least for now there’s FreeCAD and kicad StepUp:wink:

this solution fills a big gap in MCAD exporting that was missing in kicad

FreeCAD is the only open source complete solution that can handle MCAD in a robust and solid way…
There is also a really complete python API which helps a lot kicad integration…
Moreover I investigated a bit more and FreeCAD is exporting STEP adding triangulation to brep model; probably there is a way to export STEP model removing those added information…

Maurice

on github now: JST PH 2.0 TOP through hole 2-16 pin, STEP + VRML…

PS: I found that I got the XH series wrong, need to redo those…

2 Likes

@Joan_Sparky you (forum?) save a lot in the jpg quality :slight_smile: Could you post better quality jpg renders? Perhaps better a PNG file?
Do you have an overview / page with all the models generated so far?

Those are just screenshots, not renders - I won’t really waste time on renders there.
I usually resize the shots from ~1200 px wide to 800, sharpen a bit and finito, just as an overview really.
Also, until 3 months ago I was still on DSL with maybe 200kBit down… now it is maybe 10-20 times faster for me, but not for all and bandwidth costs money everywhere… the website also doesn’t seem to be able to serve/load pictures wider than 2000 px without problems (see thread of me about print colors, where I posted a screenshot of pcbnew side-by-side with a scan)…

What detail are you missing? I can always put a zoomed in view into one of the corners if that solves your problem.

As for an overview… no, not really. No need/time to do this… is there a tool for that?
Arranging those 15 connectors there in Inventor did cost me 15 min, as I haven’t got the mass-import mastered yet, where it drops off the parts on a single 1D line instead of a 3D one (had to realign all parts).

That’s a render from within inventor… goes relatively fast, but I’m not looking forward to do this for all the models I’ve done so far…

Hm… maybe I can render a single unit each time instead of the screenshot of the whole series, would that suffice? Which picture size is preferred?

1 Like

I was just suggesting to put all this screenshots in a webpage or git hub? (dont know how it works)

I understand now you complain about the size of VRMLs :wink:

Please, notice the JPG compression in the files:


I dont know if that is the forum issue of the quality of the picture you upload?
I believe if you save it in PNG they will still have low size and keep the perfect quality.

Should be me… I think it’s set to 80% quality or something thereabouts.

Yes, would be nice to have pics that relate to the models for sure, but without an automatic way I’ll probably never get around to do it.
Maybe FreeCAD can do this?
@maui, do you know if that is possible, creating/saving a little pic of each module while it’s being scaled/converted that I could include into my script?
There seems to be some POVray link in FreeCAD…
Inventor does this autmoatically, as preview for when you load parts/assemblies from the convenient main menu.

@Joan_Sparky have a look here
http://forum.freecadweb.org/viewtopic.php?t=5917
and here
http://forum.freecadweb.org/viewtopic.php?t=1824
and here
http://forum.freecadweb.org/viewtopic.php?t=5020
PS nice models! :smile:

i have made a export button for freecad that exports me a selected object as step + takes a screenshot and saves it aside for quick ref.
image saving is easy:

def save_screenshot_of_objects(objects_to_include, filename):
    """save a screenshot from the given objects."""
    activeDoc = App.ActiveDocument
    # rembember the visibility of all objects in document:
    backupVisibilityTrue = []
    for obj in activeDoc.Objects:
        if obj.ViewObject.Visibility:
            backupVisibilityTrue.append(obj.Name)
            obj.ViewObject.Visibility = False
        #
    #
    # now all objects should be invisible.

    # now show all in objects_to_include:
    for obj in objects_to_include:
        obj.ViewObject.Visibility = True
    #

    # now make the screenshot
    width, height = Gui.activeDocument().activeView().getSize()
    Gui.activeDocument().activeView().saveImage(
        filename,
        width,
        height,
        'Transparent'
    )

    # now hide all in objects_to_include:
    for obj in objects_to_include:
        obj.ViewObject.Visibility = False
    #
    # now all objects should be invisible.

    # recreate original state
    for objName in backupVisibilityTrue:
        activeDoc.getObject(objName).ViewObject.Visibility = True
        App.Console.PrintMessage("objName():{}\n".format(objName))
    #

    # restore objects_to_include
    for obj in objects_to_include:
        Gui.Selection.addSelection(activeDoc.getObject(obj.Name))
    #

if i have some time i will upload my freecad macros…

1 Like

@Joan_Sparky, I’ve used your collection of transformer models, thanks :smile:
One strange problem with them though: when I open the STEP file in FreeCAD, I see it as two objects, and this doesn’t seem to go away when “unioning” them and saving the fuse as a single object; when I re-open it, it’s two objects again (the outer steel shell/pins and the internal windings).

A side effect of FreeCAD is that it generates very bloated STEP files so I’ve resorted to using Creo to manually align the STEP files and then just using FreeCAD with @maui’s macros to confirm alignment. However, I cannot seem to lose this dual-object thing. This causes the issue with losing colouring on the resulting STEP assembly. Also, it insists on “moving” the internal windings and making a mess of the whole thing.

Any ideas?

Wow, the coil package is not just moved, it’s rotated 90 degrees… look at the coil former there.
From the lessons learned with the MELF packages (parts where separated entities) I build any model solid in Inventor (extrusions etc. have overlap), so there shouldn’t be any possibility of parts to become loose.
I can confirm that FreeCAD sees two pieces there though - will investigate.

I found that a mirror operation that creates the copper-coil inset on the ‘other’ side of the coil package is causing this, if I suppress it and export a step model and import it into FreeCAD it’s just one object.
I can solve that, no problem.
I can’t explain why it separates like that though, as the creation of the coil package (with those separation planes) happens earlier and should be unrelated…

@xavierw
Somehow in your tool-chain something is applying moves/rotations to the 1st piece only and leaves the 2nd piece where it was… can you nail down or guess which step might cause that?

@maui
I should be able to avoid several-parts-per-model thing… we stumbled across this with the MELF I think. Can you check with StepUP if this is a potential problem with above transformer please? Thanks!

I changed the modelling slightly and found what might had been the problem… a projection sketch profile of the coil former had been used in the extrusion feature that creates the copper inset. Mirroring that causes the problem. I’ll have to repopulate the parametric tables with the different values for the series again to export every model for this change to take effect in the STEP/VRML files - will see if I can automate this a bit more, might be useful as one can see :blush:

I was more after some rendering automatism, not just plain screenshots :smile:

I found this here:
http://www.freecadweb.org/wiki/index.php?title=Raytracing_Module
which sounds pretty promising, when one scrolls down to the scripting part:
http://www.freecadweb.org/wiki/index.php?title=Raytracing_Module#Scripting

Maybe this can be adapted to create renders of each model in a comfortable size like 400x400 or somesuch…

@Joan_Sparky, I had cheated and used your great looking model for convenience: the transformer I actually use is a slightly larger one (a Vigortronix 12VA), but your model almost fitted so I used that, scaled it up to about 180% its size and rotated it to correspont with my footprint requirement. I guess the “seperation” means the outer shell is rotated and aligned with my footprint, the coil section was left behind…

@xavierw
please consider that to correctly export board and parts, every single 3D model has to be a single object (a fused/union object);
it is also a good habit, if you modify/create a library object, to check if the fusion process lead to an exported STEP model can be read as single object.
That will avoid problems in running the StepUp script…

@Joan_Sparky
I verified and e.g. EFD-x-x-x_series comes with 2 separated parts…
what I normally do, in case of detached parts to be fused, is to slightly enlarge one or add a small part to let the two objects to be connected, then I fuse them…
this trick normally will lead in a single object/part that can be loaded in FC and managed correctly by StepUp exporter

thanks guys for your work! :smile:
PS @everyone
I would like to have a collection of 3D screenshots of board exported to MCAD with StepUp script…
would you mind to post some screenshot or just send it by mail?
Thanks
Maurice :smile: