Author Topic: how to do this code  (Read 4415 times)

0 Members and 1 Guest are viewing this topic.

kimmy

  • Guest
how to do this code
« on: April 27, 2011, 04:59:19 AM »
hi,everybody,who can tell me how to do this vba code for picture!
Click the select button to select multiple cad closed graph, then calculate the sum of the selected graphics display area to the back of the data box! Set price in the Price column. Total field = unit area and in addition

 thanks

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: how to do this code
« Reply #1 on: April 27, 2011, 08:21:21 AM »
Just so I'm clear... you select multiple closed polylines??  And it totals the area of them??
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

Bob Wahr

  • Guest
Re: how to do this code
« Reply #2 on: April 27, 2011, 08:48:20 AM »
Also do you need all of the code, some of it, what?   Do you know how to do the selection set for polylines?  Basically your process is as follows:

dim sset as selectionset
dim objent as acadentity
dim answer as double

Create selection set including polylines and lw polylines

for each objentity in sset
  answer = answer + objent.area
next objent

kimmy

  • Guest
Re: how to do this code
« Reply #3 on: April 27, 2011, 08:54:31 PM »
Just so I'm clear... you select multiple closed polylines??  And it totals the area of them??
yes,that is!

kimmy

  • Guest
Re: how to do this code
« Reply #4 on: April 27, 2011, 09:03:12 PM »
Also do you need all of the code, some of it, what?   Do you know how to do the selection set for polylines?  Basically your process is as follows:

dim sset as selectionset
dim objent as acadentity
dim answer as double

Create selection set including polylines and lw polylines

for each objentity in sset
  answer = answer + objent.area
next objent

thanks!! but how to do this result show in textbox of code
« Last Edit: April 27, 2011, 11:24:16 PM by kimmy »

Bob Wahr

  • Guest
Re: how to do this code
« Reply #5 on: April 27, 2011, 11:47:20 PM »
textbox1.value = answer

kimmy

  • Guest
Re: how to do this code
« Reply #6 on: April 28, 2011, 02:19:45 AM »

kimmy

  • Guest
Re: how to do this code
« Reply #7 on: April 28, 2011, 04:23:16 AM »
textbox1.value = answer
Private Sub cdmpick11_Click()
  frmMain.Hide
Dim SS As AcadSelectionSet

Set SS = ThisDrawing.SelectionSets.Add("SS")
SS.SelectOnScreen
Dim object As AcadEntity
Dim Marea As Double

For Each object In SS
  Marea = Marea + object.area
Next
SS.Delete ' to delete selection set exist
tabaa11.Value = Marea
deep10.Value = ThisDrawing.Utility.GetString(0, vbCrLf & "enter mill deep(mm)<5>:")
fee10 = (tabaa10 - tabaa11) * (deep10 / 0.25) * 0.0357 * 0.01
  frmMain.Show
End Sub

Private Sub cdmpick12_Click()
 frmMain.Hide
Dim SS As AcadSelectionSet

Set SS = ThisDrawing.SelectionSets.Add("SS")
SS.SelectOnScreen
Dim object As AcadEntity
Dim Marea As Double

For Each object In SS
  Marea = Marea + object.area
Next
SS.Delete ' to delete selection set exist
tabaa12.Value = Marea
  frmMain.Show
End Sub

Private Sub cdmpick13_Click()
 frmMain.Hide
Dim SS As AcadSelectionSet

Set SS = ThisDrawing.SelectionSets.Add("SS")
SS.SelectOnScreen
Dim object As AcadEntity
Dim Marea As Double

For Each object In SS
  Marea = Marea + object.area
Next
SS.Delete ' to delete selection set exist
tabaa13.Value = Marea
deep11.Value = ThisDrawing.Utility.GetString(0, vbCrLf & "enter mill deep(mm)<5>:")
fee11 = (tabaa12 - tabaa13) * (deep11 / 0.07) * 0.05 * 0.01
Tfee = (fee1 + fee2 + fee10 + fee12) * 1
  frmMain.Show
End Subhow to do change the deep. then update the fee! and the "Tfee = (fee1 + fee2 + fee10 + fee12) * 1" how to do? This user isn't currently ignored!
 thanks
« Last Edit: April 28, 2011, 04:58:44 AM by kimmy »

Bob Wahr

  • Guest
Re: how to do this code
« Reply #8 on: April 28, 2011, 11:17:43 AM »
Give this a try
Code: [Select]
Private Sub deep10_Change()
  If deep10 = vbNullString Then deep10.value = 0
    If Not IsNumeric(deep10) Then
      deep10.value = 0
  End If
fee10 = (tabaa10 - tabaa11) * (deep10 / 0.25) * 0.0357 * 0.01
End Sub

If it were me, I would do away with the autocad prompt for depth, and just have the user fill it in on the form, but that's your call.

One thing that you need to do though is either filter your selection set so that only objects with an area property can be selected, or check inline before trying to access the area property.  If the user had selected a line for example, your program would crash as is.