Export 3D object, Mathematica - export

I've been researching this, but I cannot find a simple example for how to do this. I would like to export a 3D object as an .obj into a specified folder.

Export["Your file name.obj", "Your 3D object"]
You can find examples here:
http://reference.wolfram.com/mathematica/ref/format/OBJ.html

Related

Get Array from Nifti File using PyVista

im new to programming and im working with a MRI dataset (.nii) in PyVista
Im trying read the Nifti File and extract an array so i can compare two MRIs based on the differences in the array and visualise it with PyVista.
PyVista is mostly based on the VTK library so maybe there is a function in VTK but im a bit helpless looking through the Docs.
I found a solution in nibabel to access an array:
img = nib.load(example_filename)
a = np.array(img.dataobj)
But with that i still can't access the PyVista Array to highlight the differences.
Thank you for your help in advance!
We need to perform two distinct operations:
retrieving the intensity values from your NIfTI dataset using, for instance, nibabel
plotting the 3D numpy array using, for instance, PyVista. Take a look at the PyVista documentation here and here for further details. You will have to add origin, spacing, etc. but for the sake of simplicity I am going to omit them.
Here is the code:
import nibabel as nb
example = nb.load("/nifti/path/example.nii.gz")
intensities = example.get_fdata()
grid = pv.UniformGrid()
grid.dimensions = np.array(values.shape) + 1
grid.cell_data["intensities"] = intensities.flatten(order="F")
grid.plot(volume=True, cmap="bone")

Issue with writeVideo/ VideoWriter MATLAB

I'm a beginner so sorry in advance for the mistakes.
I have a set of data from a camera recording saved in a 4D array with these dimensions (250x300x10603x12).
The first is the dimensions of the video (pixels). The 10603 are the FrameRatexTime. 12 are the subjects I recorded.
I extract one subject at a time for analysis in this way:
subj1 = data(:,:,:,1);
This brings me to an array containing the frames of subject 1, which I can display with implay.
Now I would like to write a video of this new array and save it in .avi format, I use this code:
v = VideoWriter('subj1.avi')
open(v)
writeVideo(v,subj1)
close(v)
but it keeps giving me this error
Error using VideoWriter/writeVideo (line 410) IMG must be an array of
either grayscale or RGB images.
In fact, looking at the shape of the array, there is nothing that points to a grayscale or RGB index. How can I get a .avi file in this case? Do I have to transform the array?
Why does it still display the video with implay?
clarification: the fact that I have to transform the array into an .avi file is because I will have to analyse it by exporting it to Python with OpenCv.
In fact, if I export the .mat file directly to Python, I can't get the list of Frames.
Matlab's documentation for writeVideo says that for a sequence of grayscale images like you have, it is expecting a "height-by-width-by-1-by-frames" array. You are only passing it "height-by-width-by-frames".
So, you need to reshape your subj1. Maybe try doing it like this:
newsubj = zeros(250, 300, 1, 10603)
newsubj(:,:,1,:) = subj1
and then save newsubj instead of subj1:
writeVideo(v,newsubj)
Finally, I think you may get some lossy compression when you save as an avi, so it may not be the best way to export it from Matlab and importing it to Python.

How to compress game data in one file

I'm trying to make game like "Duke Nukem 3D". I will have many maps in my game and each map will have it's own (and no more!) data files such as textures, sounds and so on, that's why I need to compress all these data files to one "map" file.
So, let's image that I want to test my maps one by one, and after compiling my code I want to test my first map with her textures and sounds, And when I type in my command line something like this: ./game_name "mymap.rce" or ./game_name "mymap.zip" my game must start with map what I typed and this map must have textures and sounds which I compressed with her.
You can download demo here.
To run demo you can type this for example: ./rce demo1.rce
So, I just made my archiver(without compress). If you need it, you can find it here.

In Sketchup, is it possible to automate dwg 2D line exports of scenes as you can with view.write_image?

I would like to have a one click solution for exporting my Sketchup Pro 8 Scenes to individual 2D dwg files, similar to that using view.write_image?
Thanks
Unfortunately the SketchUp Ruby API doesn't expose any means of exporting 2D DWGs. You can only export 3D.
I think You can use sketchup-dxf-stl-exporter to control your export in .dxf format. For example you can move all you 2D entities to a special layer
autocad_entities = Array.new
Sketchup.active_model.entities.each do |entitie|
autocad_entities.push entitie if entitie.layer.name == 'AutoCad Layer'
end
and use skp_to_dxf.rb to export these entities.
Hope it help you.

Conversion of .SLDDRW(solidworks) into .IGES (.IGS)

How to save SolidWorks 2D drownings (.SLDDRW) into IGES file.
I know how to conwert 3D drownings, but in 2D there is no IGES in Save As.
Should be some way because at the begining IGES was created for 2D.
IGES can be exported only from part or assemblies. I'd suggest the following workaround:
Save a drawing in DXF/DWG format.
Open saved DXF/DWG file.
In DXF/DWG Import dialog select radio button 'Import to a new part as' and either option under it.
Press Finish button. A new part or assembly should be created.
Now you can export in IGES format. Just make sure that in IGES Export options 'IGES wireframe (3D curves)' is checked.
Good luck!

Resources