Jump to content

Turning a contour trace into mtext data


Recommended Posts

Posted

Hi all,

 

I am creating 2D shapes, some solid and some with hollows in them.

 

Currently, we create regions, run massprop command and then apply math to the area to generate a weight for the shape and manually type onto the model space.

 

I would like to use the contours I have created (both int and ext) to generate various data that is then put to an MText input on the mouse to be placed in the drawing as needed. 

 

Once the contours for the shape are created, I would like to then be able to list the following data from it:

 

Weight (Simple area x density calc)

Shape Area

Inside Perimeter

Outside Perimeter

 

Does anyone know of the script to achieve this or any sort of guidance at all would be greatly appreciated. 

Posted

Sounds like TIN modelling, then can get volumes etc. Have you looked at TIN's Triangular Irregular Network. There is some free software here "TriangV0.5.9.lsp" version may be newer.

Posted

Hi Bigal,

 

Not sure what you are talking of here. 

 

See below for  a quick eg of what I am trying to do ie: Work out the weight of a simple 2D shape

 

image.thumb.png.c3ef69e4bc71c592c6b7870787981cef.png

 

I can do it all long hand but want CAD to do this for me in a quick button press. 

 

Basically, I want to be able to select the outer shape (red) and then select any inner shapes (blue). CAD will then work out the area of the shapes and then also the weight. Once known, give it to me on an MText input so I can put it on the drawing. 

 

It is simple to do when using square shape but when shape is irregular, it is difficult. 

Posted (edited)

So currently you are calculating weight manually?

Edited by ammobake
Posted

@JimmyCoxy

Assuming the shapes are closed polylines you can use the area command with the following sequence.

Give the area command followed by A (add) then O (object) pick the outer boundary, hit the space bar then S (subtract)   then O (object)  and pick the inner boundaries and you will see the Total area = ... .   Swipe the area value and use Ctrl-C to copy it to the clipboard then give the mtext  (or text) command and paste the area value with Ctrl-V you copied.  Of course the process could be streamlined with a vlisp program.

 

image.png.58a41f3a555f188225492bed6e35a8ee.png

Posted

A TIN of the shape would be like the pyramid solid option. You can then get a volume. A function of the difference of 2 surfaces.

 

image.png.8891e6f2737659088e3501c16d51d403.png

 

 

Posted

@lrm

 

That is exactly what I am trying to do with an added step of multiplying the worked out area by a material density (known number) to give me a weight value too. 

 

If it is also possible to add in data from an AMINERTIA command such as Ixx and Iyy values, that would also help greatly. 

 

The lisp file is exactly the sort of thing I need but am unable to do this myself as have never attempted before and don't even know where to start. 

Posted

Perhaps the following CalWeight program will help.  No error checking is done.  It assumes you will be selecting 2 closed polylines.

 

(vl-load-com)
(defun c:CalWeight (/ den util area1 area2 wgt pt)
  (setq den (getreal "\nEnter material density."))
  (setq	util (vla-get-utility
	       (vla-get-activedocument
		 (vlax-get-acad-object)
	       )
	     )
  )
  (vla-getentity util 'obj1 'ip "\nSelect Outer Shape. ")
  (vla-getentity util 'obj2 'ip "\nSelect Inner Shape: ")
  (setq area1 (vlax-curve-getArea obj1))
  (setq area2 (vlax-curve-getArea obj2))
  (setq wgt (* den (- area1 area2)))
  (setq pt (getpoint "\nSpecify where to place text?"))
  (command "_text" pt "" "" wgt)
  (princ)
)

 

Posted

I think this lisp would need some updating to include more geometry data per the ops post.

 

Also, Calweight requires a "material density" input but it isn't clear what this is asking for.

"\nEnter material density."))

Is this looking for specific gravity/Relative density?  In what units?
Specific gravity calculations require a source material, like water, and then you can correctly represent your material's specific gravity as a ratio.

 

IMO, Ideally, the lisp would be a block creation string creating an mleader callout with all the data points needed by the op - with a weight calc that requires a specific gravity ratio be input in whatever the current drawing units are.  It could then run the calc based on the volume of the 3dsolid and automatically insert the weight value in the correct location on the block.

 

-ChriS

Posted (edited)

This could be done easily with Lee Mac's Fieldmath function and add to a Multileader. First create an Area field in the Multileader, Then use Lee's function to add the material density constant to the Area. You will have to add it as a separate text then copy it into the Multileader below the original field. When copying you can used right-click > "Edit field" and add a prefix to the Fields. Then just add the Density line into it manually. I'm sure this could be done with a whole Visual / Auto LISP solution, but I don't have time to code it for you.

 

ScreenShot 12-15-20 at 02.18.14 PM.png

 

ScreenShot 12-15-20 at 02.20.35 PM.png

 

ScreenShot 12-15-20 at 02.27.50 PM.png

 

ScreenShot 12-15-20 at 02.29.41 PM.png

Edited by pkenewell

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...