[To...] Posted December 14, 2022 Share Posted December 14, 2022 I recently helped someone on Facebook develop a curve on a cylinder using Excel. He did not have a model. The unique thing was he needed to move in the Z so it was a 2d helical curve. Then, I created a program in Python that creates a text file that can be read into a curve feature. It was my very first project using python. Below is a a link to the .exe on my google drive. Please feel free to try and share. https://drive.google.com/file/d/1zWUy0B ... sp=sharingCreate Curve Points.pdf319508578_181188614589276_6673600375303947328_n.jpg Link to comment Share on other sites More sharing options...
[Ri...] Posted December 15, 2022 Share Posted December 15, 2022 Link to comment Share on other sites More sharing options...
[SH...] Posted December 15, 2022 Share Posted December 15, 2022 Python is basically c programming?? Link to comment Share on other sites More sharing options...
[Ma...] Posted December 15, 2022 Share Posted December 15, 2022 Let's say, programming languages are divided mainly as C type and Pascal type. Python is more likely like LUA or PHP - need interpreter for compile. C, C++ and C# are so similar and yet so different languages. Google says: Please sign in to view this quote. Link to comment Share on other sites More sharing options...
[To...] Posted December 15, 2022 Author Share Posted December 15, 2022 Please sign in to view this quote. I zipped it up. Let me know if you are still having a problem. https://drive.google.com/file/d/1gkf-mE ... sp=sharing Link to comment Share on other sites More sharing options...
[To...] Posted December 15, 2022 Author Share Posted December 15, 2022 I've created a folder which may allow you to download. Previously will probably not work as I have the files into a folder. https://drive.google.com/drive/folders/ ... sp=sharing On my original post, I added a sketch of what user was trying to accomplish. And a pdf of the excel process I considered showing the user how to create a CAD cylinder feature in Calypso, but trying to explain how to get a section cut at an angle thru his required points was going to be a bit of a challenge. Not impossible but thought excel would be the easier way for his application. Using the point generator in Calypso, does anyone know how to handle the changes in Z to create the same helical curve?calypso point generator.JPG Link to comment Share on other sites More sharing options...
[Ma...] Posted December 15, 2022 Share Posted December 15, 2022 After some searches i came with formula to generate evolvent curve. Link to comment Share on other sites More sharing options...
[Ri...] Posted December 15, 2022 Share Posted December 15, 2022 Please sign in to view this quote. Yeah - still a no-go. Email it to me please. Lol. Link to comment Share on other sites More sharing options...
[Th...] Posted December 15, 2022 Share Posted December 15, 2022 You may be able to share the source code file instead of the executable. I'm not really sure why this is getting ToS'd. Link to comment Share on other sites More sharing options...
[To...] Posted December 15, 2022 Author Share Posted December 15, 2022 I think I might have better luck with my OneDrive. https://1drv.ms/u/s!Ao0fMwRu8Hq4gawpOf- ... Q?e=C6cC8K Link to comment Share on other sites More sharing options...
[To...] Posted December 15, 2022 Author Share Posted December 15, 2022 Please sign in to view this quote. Be gentle. This is my first project and the goal was to make it work. I'm guessing I may have some room to "trim the fat". --------------------------------------------------------------------------------------------- import math file_name = input('Enter desired file name: ') curve_radius = float(input('Enter curve radius: ')) angle_start = math.radians(float(input('Enter starting angle: '))) angle_start_deg = math.degrees(angle_start) angle_end = math.radians(float(input('Enter ending angle: '))) angle_end_deg = math.degrees(angle_end) angle_increment = math.radians(float(input('Enter angle increment: '))) angle_increment_deg = math.degrees(angle_increment) angle_range = math.degrees(float(angle_end - angle_start)) number_points = int((math.radians(angle_range / angle_increment)+1)) z_start = float(input('Enter starting Z value: ')) z_end = float(input('Enter ending Z value: ')) z_delta = z_end - z_start z_increment = z_delta / (number_points - 1) print('-' * 50) print(f'Curve Radius = {curve_radius:.4f}') print(f'Start Angle = {angle_start_deg:.4f}') print(f'End Angle = {angle_end_deg:.4f}') print(f'Angle Range = {angle_range:.4f}') print(f'Angle Increment = {angle_increment_deg:.4f}') print(f'Number of Points = {number_points}') print(f'Z Start = {z_start:.4f}') print(f'Z End = {z_end:.4f}') print(f'Z Range = {z_delta:.4f}') print(f'Z Increment = {z_increment:.8f}') heading = ['XNOM', 'YNOM', 'ZNOM', 'UNOM', 'VNOM', 'WNOM'] print('\t'.join(map(str,heading))) with open(file_name + '.txt', 'w') as f: f.write("\t".join(heading)) f.write('\n') angle_current = angle_start z_current = z_start for i in range(0, int(number_points)): xnom = math.cos(angle_current) * curve_radius ynom = math.sin(angle_current) * curve_radius znom = z_current unom = math.cos(angle_current) vnom = math.sin(angle_current) wnom = float(0) print(f"{xnom:.8f}\t{ynom:.8f}\t{znom:.8f}\t{unom:.8f}\t{vnom:.8f}\t{wnom:.8f}") angle_current = angle_current + angle_increment z_current = z_current + z_increment with open(file_name + '.txt', 'a') as f: f.write(f'{xnom:.8f}\t{ynom:.8f}\t{znom:.8f}\t{unom:.8f}\t{vnom:.8f}\t{wnom:.8f}\n') input() Link to comment Share on other sites More sharing options...
[Je...] Posted December 15, 2022 Share Posted December 15, 2022 Please sign in to view this quote. . That's so cool, Tom. Definitely a great skill to develop. How did you get started in Python and why? . Link to comment Share on other sites More sharing options...
[To...] Posted December 15, 2022 Author Share Posted December 15, 2022 Please sign in to view this quote. Thanks Jeff. Back in 81-84, I majored in computer science but couldn't keep up going to school at night while working fulltime as a cnc programmer/machinist. I loved programming but didn't want to start over in a new career as an entry-level programmer. Always had a desire to get back into it. I've been dabbling with python here and there during this past year but never had a reason to build a program until now...lol PCM has been calling me to do something but just waiting for the right something. Link to comment Share on other sites More sharing options...
[Gu...] Posted December 16, 2022 Share Posted December 16, 2022 The point generator can generate a curve with a mathematical formula. Some examples: CALYPSO curve with Point generator Formel mit OK schließen / Close the formula with OK 1.) einen Spirale als Kurve definieren / define a spiral as a curve -------------------------------- Start index 1 End index 3600 Increment 1 point((cos(index) *(0.5 * index)) , (sin(index)*(0.5* index)) ,0 ,0,0,1) 2.) einen Spirale in Z (wie ein Gewindebohrer) als Kurve definieren / define a spiral in Z (like a tap) as a curve ---------------------------------------------------------------- Start index 1 End index 1440 Increment 10 point(sin(index),cos(index),(index *(1/360)),0,0,1) //oder point(sin(index),cos(index),(index *(1/360)),sin(index),cos(index),0) 3.) einen Kreis als Kurve definieren / define a circle as a curve -------------------------------- Start index 1 End index 360 Increment 1 point(sin(index),cos(index),0,0,0,1) 4.) eine Parabel als Kurve definieren / define a parabola as a curve ---------------------------------- Start index -10 End index 10 Increment 0.1 point(index,squared(index),0,0,0,1) Link to comment Share on other sites More sharing options...
[No...] Posted December 16, 2022 Share Posted December 16, 2022 Please sign in to view this quote. So it's like BASIC 🤠 Or not. I started to look into Python when we got our GOM scanner, but coming from BASIC, the way Python handles subscripts in string slicing and counters in FOR loops drove me nuts. This is so error-prone when for decades you've been used to the convention that counting from 1-10 literally meant starting at 1 and ending at 10. In Python it means ending at 9. 😮 Well, but that's not why I rarely use it. I just don't find the time. Link to comment Share on other sites More sharing options...
[Ma...] Posted December 16, 2022 Share Posted December 16, 2022 Please sign in to view this quote. Nowadays are all loops starting from 0 ( if we speak about FOR x IN y - loops ) Defining classical ( int a = 1; a <=10; a++ ) will give you 1-10 loop ( perhaps this code is not suitable for python - didn't use this lang ) Link to comment Share on other sites More sharing options...
[To...] Posted December 16, 2022 Author Share Posted December 16, 2022 Please sign in to view this quote. Thank you Guenter. That was too easy....lol ,(index *(1/360)) is what I was looking for. I was too focused on producing correct z value. I wasn't thinking I could move the curve in Z once curve was created. I think I can still put a start Z in this formula. ,xxx + index *(1/360) where xxx = Z starting height, correct? Link to comment Share on other sites More sharing options...
[Ma...] Posted December 16, 2022 Share Posted December 16, 2022 If you are satisfied with Z step, then you can write any additional number to add up. You can edit nominals after creation too ( transform, rotate, ...). Link to comment Share on other sites More sharing options...
[To...] Posted December 16, 2022 Author Share Posted December 16, 2022 * * * UPDATE * * * I don't think (index * (1/360)) will work if I need to control the range in Z, i.e. Let's say I want to start at Z0 and end at Z25. The Z formula needs to take the difference in Z divided by the number of steps. Are there a variable names for Start Index, End Index or Step so I could calculate the number of steps in order to calculate the Z step?Screenshot 2022-12-16 092420.jpg Link to comment Share on other sites More sharing options...
[Ma...] Posted December 16, 2022 Share Posted December 16, 2022 If you want height then you have to work with number of steppes and height - so here is only for Z value // 25 = height //1440 = no steppes index * 25/1440 Link to comment Share on other sites More sharing options...
[To...] Posted December 16, 2022 Author Share Posted December 16, 2022 Please sign in to view this quote. Thank you Martin, but I'm asking if I can call the variable names in the point generator window.Screenshot 2022-12-16 093530.jpgScreenshot 2022-12-16 093419.jpg Link to comment Share on other sites More sharing options...
[Ma...] Posted December 16, 2022 Share Posted December 16, 2022 I am not sure what you mean. I have holiday vacation until january, so i can not help you exactly, but if you can right click to open formula window, then maybe - but i think PCM would work here ( based on sin, cos functions ). Try something. Only sure variable is "index" Link to comment Share on other sites More sharing options...
[To...] Posted December 16, 2022 Author Share Posted December 16, 2022 Shouldn't the x value be calculated from cos of index and y from sin of index? for example point(5*cos(index),5*sin(index),0,0,0,1)Screenshot 2022-12-16 093530.jpg Link to comment Share on other sites More sharing options...
[To...] Posted December 16, 2022 Author Share Posted December 16, 2022 Please sign in to view this quote. Nothing in formula section leads me to believe that I can do what I am looking for. Have a wonderful holiday.... Link to comment Share on other sites More sharing options...
[Kl...] Posted December 20, 2022 Share Posted December 20, 2022 Hi, The point generator only allows "implicit" formulas In the present case the counter should run from a start angle to an end angle, with the direction of rotation changing after 180° of the angle range. Such complex formulas must be calculated in the PreParameter. ZigZagCylinder.zip Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in