Utility search

Utility search
I was wondering if there is a utility that can generate a cylinder of a given radius, centered on the line between two points. If I had this would be so helpful. The cylinder result would come out as an n-ncyli.dat file. Generated from the first point with the same orientation as the line.
Re: Utility search
Do you want to use a single cyli primitive (in this case I have nothing to offer... except a bit of trig calculations!), or build a cylindrical tube with curved path? in the later case, my PathTruder utility will do the trick.
Re: Utility search
Why not using standard cyl primitives?
Also if you need customized primitives you can give PrimGen2 a try.

I hope I have understand your request correctly.
Re: Utility search
Imagine you have two points not on the same plane. Ex (-5.477,-45.783,260.680) and (13.732,-13.601,231.425). And you want a cylinder that runs from one point to the other. So I need something that would generate the orientation for the primitive 4-4cyli.dat starting from one of the given points. End at the other point.
Re: Utility search
This perl script might do the trick. Given two points and a radius it will return the type 1 line to draw a cylinder of radius rad between the two points.

sub help {
print "
Usage: CyliPoints.pl x1 y1 z1 x2 y2 z2 rad
(all points must be specified)

Returns the ldraw code for a cyli prim of radius rad
pointing from (x1,y1,z1) to (x2,y2,z2)

use Math::Trig;


sub pointstr {
    my ($x,$y,$z)=@_;
    return sprintf("%.3f %.3f %.3f ", $x, $y, $z);

sub matstr {
    my ($M11,$M12,$M13,$M21,$M22,$M23,$M31,$M32,$M33)=@_;
    return sprintf("%.4f %.4f %.4f ", $M11, $M12, $M13)
    .sprintf("%.4f %.4f %.4f ", $M21, $M22, $M23)
    .sprintf("%.4f %.4f %.4f ", $M31, $M32, $M33);

sub dot {
    my ($x1,$y1,$z1,$x2,$y2,$z2)=@_;
    return ($x1*$x2+$y1*$y2+$z1*$z2);

sub norm {
    my ($x,$y,$z)=@_;
    if ($r>1e-5) {
    return ($x/$r,$y/$r,$z/$r,$r);
    } else {
    return (0,1,0,0);

if ($#ARGV<6) { &help(); exit; }
my ($x1,$y1,$z1,$x2,$y2,$z2,$rad)=@ARGV;

my $dx=$x2-$x1;
my $dy=$y2-$y1;
my $dz=$z2-$z1;


my ($xn,$yn,$zn,$rn)=&norm($dx,$dy,$dz);
my ($xp,$yp,$zp,$rp)=&norm($rxz,$dy,0);
my ($xnp,$ynp,$znp)=&norm($dx,0,$dz);
my ($xpp,$ypp,$zpp)=&norm($xp,0,$zp);


printf("0 // Angle in xy plane: %.4f\n",$angxy/$pi*180.0);
printf("0 // Angle in xz plane: %.4f\n",$angxz/$pi*180.0);




print "1 16  ".&pointstr($x1,$y1,$z1)." "
Re: Utility search
Thank you for the Perl script. It would be extremely helpful if knew anything about Perl. Or scripts in general. That type of programming I am not quite clear on. I tried to learn C++ years ago. But did not stay with it long enough to fully absorb the concept.
Re: Utility search
Ahhh. I figured you must have been scripting to generate your parts.

The one does do precisely what you ask.

If you're using windows you could install ActivePerl. If you then download the script and save it with a .pl extension it should just run from the command prompt.

Re: Utility search
Who? What? Well I downloaded Active Perl. But download the script from where? And open it with what? In my mind I need to open it with something to save it as a .pl file. I am sorry, but I literally know nothing about all of this.

The main software I use in authoring a part is: Turbo Cad and Microsoft Excel. With Turbo Cad I can draw what I need and pull the points off the drawing. But it is only 2D. This makes what I am doing difficult.
Re: Utility search
Sorry, I meant just copy it straight from my post, paste it to 'CyliPoints.pl' (or something) and then run it.

1) Go to notepad
2) Copy the code from above and paste it into notepad\
3) Save as CyliPoints.pl in a directory [DIR] you can get to easily
4) Open a command prompt and cd to [DIR]
5) Just type "CyliPoints.pl X1 Y1 Z1 X2 Y2 Z2 Rad" at the command prompt and copy the output

Re: Utility search
Thank you. This is just what I needed.
Re: Utility search
I believe it might have problems if Y2<Y1. In that case switch the two points around.
« Next Oldest | Next Newest »

Forum Jump:

Users browsing this thread: 1 Guest(s)
Forum Jump:

Users browsing this thread: 1 Guest(s)