DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

Macro use of a 'data' file...

Started by Flrn, April 22, 2020, 08:02:19 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Flrn

Might say that I need a 'little' help, but, more accurately, need a LOT of help, considering my lack of knowledge of  BasicCAD.

The intent of the (attempted) macro is to 'plot' points in Cartesian-coordinate, 3D space using an *.xyz 'data' file of those, comma-separated, xyz points, one 'set' per line.  Hopefully, will manage to include the (non-working) files involved: 4v.dcd, 4v.d3m, and 4v2.xyz.

The 3D, unitless 'drawing' is very simplistic: One red dot or PointMark, 0.05 in diameter, centered at the origin.  The attempted macro was intended to Open the *.xyz file and 'use' it, line-by-line, to 'locate'  black PointMarks in 3D space.  Those 'located' points were to be representative of the vertices of one-fifth of a geodesic dome.

When I attempted to 'run' the macro, it simply "dinged."  Took that to be a 'raspberry' from the software engineers telling me that my poor effort was "dingy."  Dcad2019, Win10Pro64.

Clearly, this question/plea is already too long, but if anyone might be interested, the basis for the 'xyz file' was a spreadsheet 'massaging' of "Phi and Theta spherical coordinates" taken from Hugh Kenner's excellent book "Geodesic Math-And How to Use It."  His general method involves considering domes/spheres with a unitary radius (in order to simplify formulas and make the data adaptable).

Many thanks,
Jim

PS: Learned belatedly that *.xyz files can't be attached, so, please change the extension of 4v2.txt back to 4v2.xyz after retrieval.  Thanks

Rob S

Others will be better qualified to analyze your macro, but do you realize Designcad can import your XYZ file directly?

Open a blank drawing, and file, import, select XYZ file type, and select your file.
User since forever

bdeck

#2
Hi Flrn,
I made 2 comments to your code that may help out.
I have not tested.
bd

PS: Oops.  Comments below corrected to show necessary space between <pointxyz  and [x, y, z]


open "i", 1, "*\Sample Macros\4v2.xyz"

'The following mindlessly copied...
Sys(36) = 1 'set silent mode for speed        'set to 0 for error messages during debugging

Do while not eof(1)
     input #1, x, y, z
          >Pointmark
          {   
               <type 5
               <size 0.05
               <[x, y, z]              'should be <pointxyz [x, y, z]
           }
Loop
Close #1
>FitToWindow
{
}
End

bdeck

#3
I had a chance to run the macro with the change noted above, and the only error was caused by the wrong extension on the file to be opened.

It doesn't matter which extension you use, but the extension in the "open" line must match the one on the file.

Here's how the code looked when I set the path for my own local scratch folder.

Image attached shows the output.

Stay well,
bd

PS, I also backed some extraneous spaces out of the data file. The corrected file (renamed) is attached.


open "i", 1, "c:\dc\scratch\4v2.txt"                      ' changed extension to the extension of the test file

Sys(36) = 1                  'set silent mode for speed

Do while not eof(1)
     input #1, x, y, z
          >Pointmark
          {   
               <type 5
               <size 0.05
               <Pointxyz [x, y, z]                   ' correct parameter, format can be found at beginning of macros17.hlp
           }
Loop
Close #1
>FitToWindow
{
}
Sys(36) = 0
End

Flrn

BD, thank you so much!  Thought i'd replied once, but can't find it in this thread.  First post noted need to change .txt extension (.xyz extension wouldn't attach/upload).  The 'output' pictured certainly looks like it should--even though some of the data points in the original .txt->.xyz file might be questionable.

Much appreciated!

Thank you,
Jim