Export xyz coordinates

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
jgg
Posts: 3
Joined: Sun Jun 13, 2021 1:46 pm

Export xyz coordinates

Post by jgg »

I layout a 3 dim drawing of a yagi antenna using draft workbench - In order to model the antenna in NEC software, I need to specify the beginning and end of each wire element as xyz coordinates. I believe a python macro should be able to export the element coordinates to a text file or csv file. I have tried to do so but my ability with Python & Freecad in general is quite limited. Any help will be most appreciated!
Thanks - Joe
mario52
Veteran
Posts: 4692
Joined: Wed May 16, 2012 2:13 pm

Re: Export xyz coordinates

Post by mario52 »

hi

tray Macro_FCInfo Image (for unique object)

mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
drmacro
Veteran
Posts: 8983
Joined: Sun Mar 02, 2014 4:35 pm

Re: Export xyz coordinates

Post by drmacro »

In the Addon manager there is also WireXYZ which imports, but can easily modified to export:

Pertinent parts of the changed code:

Code: Select all

obj = App.getDocument(docname).getObject("<<your object name here>>")
outfile = "<<your file name here>>"
file = open(outfile, "w")
for vct in obj.Points:
	print(*vct,sep=' ')
	X,Y,Z = vct
	file.write(' '.join([str(n) for n in vct]))
	file.write('\n')
file.close()	
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
jgg
Posts: 3
Joined: Sun Jun 13, 2021 1:46 pm

Re: Export xyz coordinates

Post by jgg »

Thanks very much for the quick repies & answers - those who devote their time & effort to help others will be blessed!
Thanks again!
Joe
Post Reply