Home AutoCad VB Calculate Solids Mass and Volume
20 | 05 | 2012
This site has been updated and renewed. You have followed an old link.

Click here to go to the new site

http://www.visiblevisual.com/jupgrade

Calculate Solids Mass and Volume PDF Print E-mail
User Rating: / 2
PoorBest 
Tutorials

Code below lets you select a 3d Solid and the code will calculate the Volume. When you enter a Density then the Mass can be calculated too.

View source
Sub MassPropD()
 
 
 
	Dim oSS As AcadSelectionSet
 
	Dim iFilterCode(0) As Integer
 
	Dim vFilterValue(0) As Variant
 
 
 
	'Errorhandler
 
	On Error Resume Next
 
	Application.ActiveDocument.SelectionSets("TempSS").Delete
 
	On Error GoTo 0
 
 
 
	TotalVolume = 0
 
	'Create a selection set
 
	Set oSS = Application.ActiveDocument.SelectionSets.Add("TempSS")
 
 
 
	iFilterCode(0) = 0: vFilterValue(0) = "3dsolid"
 
	'Filter on screen selection for 3d Solids
 
	oSS.SelectOnScreen iFilterCode, vFilterValue
 
	For Each ent In oSS
 
	TotalVolume = TotalVolume + ent.Volume
 
	Next ent
 
 
 
	Density = InputBox("Enter Material Density: ")
 
	Mass = Density * TotalVolume
 
 
 
	MsgBox "Calculated Totalvolume: " & TotalVolume & vbCrLf & _
 
	"Calculated Mass: " & Mass
 
 
 
	oSS.Delete
 
 
 
	End Sub

 

Add comment


Security code
Refresh

This site has been updated and renewed. You have followed an old link.

Click here to go to the new site

http://www.visiblevisual.com/jupgrade