I am attempting to make a script which will pull NURBS data from Blender text file, I have managed to extract the control points for the generation of the structure. But, I need it to perform the generation automatically. I made a loop which runs the function and puts the result into a cell array, that way I call later call on it as " crv{1},crv{2}" etc. and for graphing purposes.
However, each time I run the script, it will only keep the last loop results and result in my "crv" cell array saying "1×7" but then listing the results as " [] [] [] [] [] [] [1×1 struc]" if I run it for 7 loops, the data is properly recorded in the last entry but all of the others are empty.
Unless you have the NURBS/Geopdes package installed, running the code yourself will not work.
I would like to know if their is a better way to create structures in a loop than this, I know dynamically creating variables is a huge no-no, but I can't think of what else to do if the cell array method doesn't work.
<<
>>
close all; clear; clc;content = fileread( 'TEST_CUBE.txt' ) ;expr = '[^\n]*v [^\n]*';matches = regexp(content,expr,'match');n = numel(matches);for i = 1:n expression = 'v '; replace = ''; matches(i) = regexprep(matches(i),expression,replace);endfor ii = 1:n for i = ii C = cell2mat(matches(i)); end NUM = str2num(C); Ctrl{i} = NUM;endfor i = (n-1) crv{i} = nrbline([Ctrl{1,i}(1,1) Ctrl{1,i}(1,2) Ctrl{1,i}(1,3)],[Ctrl{1,i+1}(1,1) Ctrl{1,i+1}(1,2) Ctrl{1,i+1}(1,3)]); nrbctrlplot(crv{i});hold on;end
Best Answer