Macro Automatic drawing

Need help, or want to share a macro? Post here!
triplus
Posts: 9464
Joined: Mon Dec 12, 2011 4:45 pm

Macro Automatic drawing

Postby triplus » Sat Dec 22, 2012 4:43 am

I create a lot of SVG drawings lately and i was thinking how to automate creation of drawing to save time. I like Insert an orthographic projection ... in Drawing Workbench but ATM two things prevent me from getting perfect results with press on the button.

-Auto scale/position usually leaves too much blank space when i use blank template and i have to play around with numbers manually.
-Axonometric tab is empty for now and for Isometric View i have to insert/scale/position it manually.

This two things it's easy to do manually but when i have multiple parts and want to make more drawings it takes quite a while to finish this task. I guess in the future it will take less time to achieve this but for now i looked how i could improve the process of creating the drawing. I found this macro:

https://sourceforge.net/apps/mediawiki/ ... ic_drawing

It should do exactly what i am looking for but the problem is views are often not scaled and position correctly. Now the question did anybody improved this macro and is wiling to share it in a way it always produce good results? Correct scale and position of all 4 views.
User avatar
jriegel
Site Admin
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: Macro Automatic drawing

Postby jriegel » Sat Dec 22, 2012 12:06 pm

Werner did some time ago a feature to include a icon size pictures in the GuiDocument at safe time.
Im not sure its still active!? There you can simply with zip-lib extract that picture out of a saved document.

Drawing is to fat for save time IMO...
Stop whining - start coding!
triplus
Posts: 9464
Joined: Mon Dec 12, 2011 4:45 pm

Re: Macro Automatic drawing

Postby triplus » Sat Dec 22, 2012 4:39 pm

Basically i create technical documentation in LibreOffice and LibreOffice has SVG support and this combination works great for me especially because there is a lot of software this days that support SVG and i can do a lot of operations on the exported SVG drawing easily.

About save time size you probably mean the size of .fcstd file if it has one or more drawings in it? To be honest i sometimes have .fcstd file with multiple parts in it and multiple drawings of it in the same file and the size is still small by my standards. And i like the fact i can open this file in FreeCAD later on and everything is embedded in it.

About the picture embedded in .fcstd file yes this still exist but i find SVG drawing with 4 views much better for my needs as embedded image in .fcstd file is great for thumbnail support for example but for technical documentation SVG drawing (for example using standard 4 views) is needed.

This macro:

https://sourceforge.net/apps/mediawiki/ ... ic_drawing

Would work great in my opinion if two things would be improved:

1.) User would input "center point" of view (X and Y coordinate) and created view would have "center point" exactly on that coordinate.
2.) Scale with current macro is often "off" and this should be changed.

I tried to achieve this but for now i didn't make it. I use paper sizes from A6 to A3 and i don't mind if macro does not detect paper size and i would have to input this information (different macro each page) manually for each page.
User avatar
jriegel
Site Admin
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: Macro Automatic drawing

Postby jriegel » Sat Dec 22, 2012 6:42 pm

Ah, I didn't get you at the first time. I thought you want do a automatic save into the FCStd.

Code which is able to auto create such a drawing would be cool. I would insert this code into drawing or PartDesign.
One way to calculate a better projection is to use the bounding box of the parts. There you have a more exact size and position.
Stop whining - start coding!
User avatar
jriegel
Site Admin
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: Macro Automatic drawing

Postby jriegel » Sat Dec 22, 2012 6:43 pm

Ok, I see the script already use the bounding box. Then I don't understand the problem!?
Stop whining - start coding!
triplus
Posts: 9464
Joined: Mon Dec 12, 2011 4:45 pm

Re: Macro Automatic drawing

Postby triplus » Sat Dec 22, 2012 10:42 pm

Then I don't understand the problem!?
It doesn't work most of the times.

Default macro + default Cylinder:

Image

Default macro + default Box:

Image

Changed paper size to A6 size + default box:

Image

Scale, position... is off. It's not "one click" solution and i didn't figure it out how to change the macro manually (for each paper size) to work reliable and to produce good results with one click on the button. I was close when part was close to point (0, 0, 0) but then i noticed if part position changes (X Y Z) it influences position in the drawing too and that was the sign i probably will not be able to achieve reliable results with my current knowledge of making FreeCAD macros for this task.
User avatar
jriegel
Site Admin
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: Macro Automatic drawing

Postby jriegel » Sun Dec 23, 2012 1:43 pm

Ah Ok,
the cylinder already looks good, only the position need tweaking.

With the bounding box you can also get the min max position for the part. There you can adjust the view postion.

For different paper sizes you have to change the size of the view, since our SVG templates are scaled in mm and there fore
is a A6 four time smaller then a A3....
Stop whining - start coding!
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Macro Automatic drawing

Postby NormandC » Sun Dec 23, 2012 7:23 pm

The description in the Macro page indicates
Needs some modification to be perfectly effective.
I used this macro in the past before the Multiple views GUI tool was added. I always had to do some tweaking of the views. I tried to hack the macro but without success. One thing that annoyed me was that it didn't use standard scaling (1:2, 1:10, etc.)

I know it's possible to tweak this, but not by me. ;)
triplus
Posts: 9464
Joined: Mon Dec 12, 2011 4:45 pm

Re: Macro Automatic drawing

Postby triplus » Sun Dec 23, 2012 11:16 pm

I used this macro in the past before the Multiple views GUI tool was added.
Yes i agree Insert an orthographic projection ... is great feature but for now Axonometric tab is empty and auto scale/position usually leaves too much blank space when i use blank template and i have to play around with numbers manually. It's not hard to input another view and make isomeric view out of it and then position and scale all views but it's time consuming if let's say 10 drawings has to be created and there are usually not final drawings but some phase in development of the part and i just want quick drawing of it.
With the bounding box you can also get the min max position for the part. There you can adjust the view postion.


Great tip and i actually did get some results with this additional information for 3 views but then i got stuck on isometric view. I can't figure out how to adjust isometric view reliably.
User avatar
jriegel
Site Admin
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: Macro Automatic drawing

Postby jriegel » Wed Dec 26, 2012 11:01 am

triplus wrote: Great tip and i actually did get some results with this additional information for 3 views but then i got stuck on isometric view. I can't figure out how to adjust isometric view reliably.
Mhh, from the top of my head i don't know a simple method either. I think here you need some serious vector calculus....
Stop whining - start coding!