CamBam
News:
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
September 26, 2017, 15:19:03 pm


Login with username, password and session length


Pages: 1 [2]
  Print  
Author Topic: Area enclosed by a polyline script  (Read 4904 times)
Bob La Londe
CNC Jedi
*****
Offline Offline

Posts: 2896


^ 8.5 pounds on my own hand poured bait.


View Profile WWW
« Reply #15 on: August 04, 2017, 16:21:30 pm »

Thanks, Dave.  That's good confirmation.

I might add that to the toolbar as a plugin.  My most frequent use of it would be to calculate the weights of various parts.

Many of my mechanisms have 'balanced' parts, or use scales the limits of which can be exceeded if the weights of holders, etc. become too much.

It's easy to calculate the mass of a regular shape, but not oddball geometries.

LLoyd

I often have to calculate the weight of cast lead objects.  Since I am almost always working from a 3D model in ViaCad I use its built in (verify volume) function and use .41lbs per cubic inch.  Then * 16 for ounces.  I have a little cheater spread sheet in the tools on my desk top that I can just plug a bunch of values into when I have a lot of grunt work for various sizes of the same object. 

Logged

Getting started on CNC?  In or passing through my area?
If I have the time I'll be glad to show you a little in my shop. 

Some Stuff I Make with CamBam
http://www.CNCMOLDS.com
kvom
CNC Jedi
*****
Offline Offline

Posts: 1383


View Profile
« Reply #16 on: August 05, 2017, 00:42:37 am »

Solidworks has the same area and volume calcs plus densities of lots of materials.
Logged
EddyCurrent
CNC Jedi
*****
Offline Offline

Posts: 3066



View Profile
« Reply #17 on: August 05, 2017, 20:54:38 pm »

I know many CAD programs have this facility but CamBam did not.

David,

Bugs should be fixed now. I tried to follow Lloyd's script as close as possible but added the, view.StartThinking(false); message, unfortunately I forgot to add, view.StopThinking(); when an error was found.  
I've changed the program logic slightly too.

1. You can select multiple objects
2. Translation code added to messages

Edit: attachment removed, see later post for new version
« Last Edit: August 09, 2017, 09:25:10 am by EddyCurrent » Logged
dave benson
CNC Jedi
*****
Offline Offline

Posts: 771


View Profile
« Reply #18 on: August 06, 2017, 00:35:02 am »

Hi Eddy

Just ran the plugin and selected a few shapes, and what would be handy is a cancel button (in case you have selected too many entities and wanted to abort) , and instead of popping up a new message box for each entity perhaps listing them on the first message box.

Dave
Logged
EddyCurrent
CNC Jedi
*****
Offline Offline

Posts: 3066



View Profile
« Reply #19 on: August 06, 2017, 09:31:16 am »

Dave,

I've never had luck adding a Cancel button to the thinking message.
If you use, view.StartThinking(true); it adds the Cancel button but I think you have to add an event handler for this. Do you have any example code to make this work ?
Logged
dave benson
CNC Jedi
*****
Offline Offline

Posts: 771


View Profile
« Reply #20 on: August 06, 2017, 13:04:23 pm »

HI Eddy
No when I came to do this in the collision detector I used a background worker because i wasn't sure how to do it either
but I think CB runs a  task on a different thread (threading) and I think now I could work it out given a little time
and I will look at it as soon as I work out what to do with the break edges plugin as with using a style as I've discovered that while the tool number and profile are specified in the style the cutter V angle is not and neither is the tool library that the tool data comes from.
CB looks for the tool library in the part and if the field is null then it uses the default library, which is ok if your tool is in the default library, but I've organised my libraries by tool type drills in one and end mills in another, and so the style library data (tool index) would point to the wrong tool if you don't enter the tool library that you use in the part. so it looks like I'll have to add another drop down to enter the tool library to go along with the style library, which sorta seems the long way around. Roll Eyes

Dave
Logged
dh42
Administrator
CNC Jedi
*****
Offline Offline

Posts: 4628



View Profile WWW
« Reply #21 on: August 06, 2017, 22:57:50 pm »

Hello Eddy

I falls on another problem ..

A new key is added in the translation list for each new object that is 'measured' with the plugin.

++
David



* areabug.png (28.24 KB, 1050x671 - viewed 17 times.)
Logged
EddyCurrent
CNC Jedi
*****
Offline Offline

Posts: 3066



View Profile
« Reply #22 on: August 07, 2017, 08:11:51 am »

David,

I don't know why, I've added the source project if you have time to look. Everything is in Class1.cs and Notepad++ is fine to read it with.

* AreaCalc_source_v1.2.zip (9.86 KB - downloaded 11 times.)
Logged
dh42
Administrator
CNC Jedi
*****
Offline Offline

Posts: 4628



View Profile WWW
« Reply #23 on: August 07, 2017, 15:23:31 pm »

Hello

Ok, I'll have a look  ... Wink

++
David
Logged
dh42
Administrator
CNC Jedi
*****
Offline Offline

Posts: 4628



View Profile WWW
« Reply #24 on: August 09, 2017, 00:17:59 am »

Hello

Currently, I can't find how that works with variable in the text  Huh ... but I found another problem with translation in the  Spiral Toolpath from Profile plugin ; there is also texts that are added for nothing.

I just send an email to Andy to know if he can help.

++
David


* Sans titre-1.png (19.18 KB, 1023x701 - viewed 14 times.)
« Last Edit: August 09, 2017, 00:40:39 am by dh42 » Logged
dh42
Administrator
CNC Jedi
*****
Offline Offline

Posts: 4628



View Profile WWW
« Reply #25 on: August 09, 2017, 01:07:50 am »

Quote
I don't know why

I know why, but I don't how how to use the right way as in:

 "The file '{0}' already exists! Overwrite existing file?"

where the '{0}' is replaced by a variable in the translation list

the reason because your code adds a new entry each time is because, each time the text is different because the value in ent.ID and other variable change, and off course, each time you get a different string to translate.

Code:
MessageBox.Show(TextTranslation.Translate("Area enclosed by polyline ID# " + ent.ID + " = " + string.Format("{0:N6}", Math.Abs(Area)) + " ^2 drawing units." + Environment.NewLine + "Perimeter Length of polyline ID# " + string.Format("{0:N6}", perimeter) + " drawing units."));

I think that currently, the way is to split each 'static' text as an entry in the translation list, so the code become:

Code:
MessageBox.Show(TextTranslation.Translate("Area enclosed by polyline ID# ") + ent.ID + " = " + string.Format("{0:N6} ", Math.Abs(Area)) + TextTranslation.Translate("^2 drawing units.") + Environment.NewLine + TextTranslation.Translate("Perimeter Length of polyline ID# ") + string.Format("{0:N6} ", perimeter) + TextTranslation.Translate("drawing units"));

I use one TextTranslation.Translate() function per 'static' text and I don't translate the texts that can change.

I also move the space before the "^2 drawing units." and " drawing units." string to the end of the previous text to avoid text that start with a space.

I remove the dot at the end of "drawing units.", because "drawing units" already exists in the translation list, so it will not be translated again.

Tested with a visual basic translation of this line of code .. and it seems to works.

++
David

Edit: What is your C# version ?  I can't open the .sln file with mine (visual C# 2010 express)


« Last Edit: August 09, 2017, 01:16:19 am by dh42 » Logged
EddyCurrent
CNC Jedi
*****
Offline Offline

Posts: 3066



View Profile
« Reply #26 on: August 09, 2017, 09:24:24 am »

David,

Thank you for finding the answer, I'll have to remember that trick in future.

version 1.3 attached.

I use VS 2015 Community

* AreaCalc_v1.3.zip (3.49 KB - downloaded 12 times.)
« Last Edit: August 13, 2017, 21:49:04 pm by EddyCurrent » Logged
dave benson
CNC Jedi
*****
Offline Offline

Posts: 771


View Profile
« Reply #27 on: August 09, 2017, 11:01:59 am »

HI Eddy
PM sent maybe twice  Roll Eyes I've answered re the cancel button.
Logged
dh42
Administrator
CNC Jedi
*****
Offline Offline

Posts: 4628



View Profile WWW
« Reply #28 on: August 12, 2017, 04:16:54 am »

Hello Eddy

I just see another little bug (exist in previous version), the polyline # is missing in the perimeter line. (maybe it's not needed to write the ID twice ?)



++
David
« Last Edit: August 12, 2017, 04:53:44 am by dh42 » Logged
EddyCurrent
CNC Jedi
*****
Offline Offline

Posts: 3066



View Profile
« Reply #29 on: August 13, 2017, 21:50:23 pm »

David,

You testing is very good  Wink
I just updated the v1.3 in my previous post, it should be okay now (I hope)



* area.jpg (34.83 KB, 800x300 - viewed 13 times.)
« Last Edit: August 13, 2017, 21:57:36 pm by EddyCurrent » Logged
Pages: 1 [2]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.135 seconds with 18 queries.

Copyright © 2008 HexRay Ltd. | Sitemap