Can anyone help me with a script to rotate 3D and move step files based on footprint values, to make them KLC compliant?

I have a decent collection of 3D models that could be added to KiCAD: https://github.com/StefanHamminga/kicad-packages3D

One thing stopping inclusion to the official libs right now is that they are not oriented / positioned correctly for the KLC’s taste. For most of these I have reorientation and offset data in the 3D model fields of the corresponding footprints: https://github.com/StefanHamminga/kicad-footprints

Would anyone have a script or be willing to help out with a script that can orient these properly so they can be offered up for inclusion in the official libraries? I suppose it would need to use either FreeCAD or some other CAD engine? My FreeCAD experience is extremely limited so I don’t really know where to start with that.

FreeCAD and StepUp workbench. Do a search and you’ll find instructions.

I think he knows what is to do, but he needs help scripting it for bunch of models (probably something that either @maui @BlackCoffee @qu1ck could give some pointer on how to do)

On the high level what the script would need to do is read the footprint, extract the model transform data, apply the transformation to model itself and (optionally) zero out the transform in the footprint.
Transforming the model needs to happen in 3d CAD, likely freecad scripting, I don’t have any experience with that.

But before you do any of that I would talk to librarians to see whether models would be accepted, there may be other issues which you should know about before you spend time fixing orientation.

FreeCAD uses Python for scripting and it can already read KiCAD’s Boards, Footprints and 3D Models (using the StepUp workbench), i am guessing that the script would need to read a footprint and the 3D model associating with it, apply the modification from the footprint (are the offset and rotation values saved on the footprint?) to the model and save the model again. I know that StepUp can do all this steps, I do not know how to script them, maybe there is a logger somewhere in FreeCAD that let you see what command was used for each button click.

The fact that the models are not oriented correctly can be an indicator that you downloaded third party models from somewhere and then converted them for use in kicad. If this is indeed the case then this is a much bigger showstopper than the models not being aligned correctly (the official library does not accept models that are not designed by the contributor for licensing reasons).

Note: It is not certain from the information given that the above does indeed apply. But i want to avoid you possibly investing unnecessary time.

Following the link:

2 Likes

As pointed out I try to strictly separate my own designs from 3rd party models for that reason.
Also orientation is slightly more tied to the CAD program used to design the part (and specific it’s up axis convention) than author identity.

@Rene_Poschl Are you still running the library? If so, you seem to be opposed to me trying to contribute these models. As you rightfully stated nobody wants to waste their time, so if you’re opposed please let me know so nobody will put in unneeded effort.

Rene isn’t the library head anymore.

Not at all. He just asked to ensure that everyone knows the situation. The situation is clear after der.ule’s and your latest posts.

The time of library maintainers is limited and critical bottleneck for the libraries, therefore it’s very important that those who want to contribute follow all instructions, procedures, KLC etc. very strictly. Every rejected contribution is time wasted, and may consequently cause unrelated otherwise acceptable contributions to stand in the queue even longer. This has been discussed many times but we don’t know if you a familiar with these things.

BTW, I’m not a library maintainer or contributor but have followed the discussions.

1 Like

Well, the question I would’ve understood, but the strange assumption linking part orientation to authorship got me wondering if there’s some issue I’m missing.

It think it’s natural to expect that if one person makes models they are consistent. Making them over time and with different tools of course explain differences. I, too, browsed some of your directories quickly but didn’t read the readme first. I noticed that the selection of file formats was inconsistent and wondered why.

To make it clear: nothing of this is relevant for you to get your contributions through or diminish the value of your work. The only requirement is that all contributions obey the library standards and contribution process standards.

1 Like

Model additions are welcome, of course.

However, people (for some reason I don’t really get) quite regularly try to sneak in manufacturer models by just importing the manufacturer STEP into FreeCAD, saving as .FCStd and selling that as their “source” file. Wrong orientation is an indicator of that, which is why we’re cautious, that’s all.

Some kind of actual source file (that can be edited if models turn out to be wrong later, for example) is required, BTW. Doesn’t have to be FreeCAD although an open source or at least freely available application is preferred, for obvious reasons.

1 Like

StefanHamminga,

Thank you for hosting these 3D models and for posting the URL. I copied one text file from your site and posted it into FreeCAD 0.18.
I saw the resulting step file model and was able to rotate it. Looks good. So far, that is the extent of my FreeCAD knowledge. Don’t know python. Now I have incentive to use git!

I don’t think people try to sneak in models (at least not on purpose). I generally assume it is in most cases just a lack of knowledge regarding how licensing works in general. A lot of people seem to assume that as long as they put in some work (example convert it to a different file format) then they are free to redistribute the work of others.

They simply never think about what the requirement for licensing means (i was the same a few years ago but expiriences like the ones i made while on the library team taught me to be wary about this issue).

Yes this is why i asked about the origin of the files and why i wanted @StefanHamminga to be informed about potential licensing questions. And yes i could have worded this differently.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.