Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Parcel Areas

7 REPLIES 7
Reply
Message 1 of 8
Anonymous
371 Views, 7 Replies

Parcel Areas

I'm new into VBA programming. I did a tool that calculates the total area
by parcel styles within a specific site. Basically what I did is created a
loop and an IF statement to filter out parcels by styles, and after that put
the total parcel areas by style in an array for later use. Everyting seems
to work fine, but it takes forever to calculate the toal areas when I run
it, since it loops trhough out approx. 600 parcels. Should I be doing this
differently? Any ideas would be appreciated. Thanks
7 REPLIES 7
Message 2 of 8
Anonymous
in reply to: Anonymous

Hi Francisco,

600 parcels should be trivial.

It is more likely that you looping structures are inefficient.

Can post post your program and drawing (delete everything but the 600
parcels from the drawing then purge, to reduce overhead ) If the drawing is
still over about 200Kb, post it to the customer files rather than here.

--


Regards

Laurie Comerford

"Francisco J. Bobadilla" wrote in message
news:5860237@discussion.autodesk.com...
I'm new into VBA programming. I did a tool that calculates the total area
by parcel styles within a specific site. Basically what I did is created a
loop and an IF statement to filter out parcels by styles, and after that put
the total parcel areas by style in an array for later use. Everyting seems
to work fine, but it takes forever to calculate the toal areas when I run
it, since it loops trhough out approx. 600 parcels. Should I be doing this
differently? Any ideas would be appreciated. Thanks
Message 3 of 8
Anonymous
in reply to: Anonymous

Laurie,

I have posted the file to the customer files group. Here is the code I'm
using for my looping. Thanks for your help.

Option Explicit
Public txtbox As MSForms.TextBox
Public Sub CommandButton1_Click()
Me.OK.Enabled = True
Dim pstyle As String
Dim k As Integer
Dim n As Integer
Dim cvalue As String
Dim txtbox As MSForms.TextBox
Dim ctlLabel As MSForms.Control
n = g_oDocument.ParcelStyles.Count
For k = 0 To n - 1
pstyle = g_oDocument.ParcelStyles.Item(k).Name
Set ctlLabel = Me.Controls.Add("forms.Label.1")
With ctlLabel
.Name = pstyle & k
.Width = Me.Width
.TextAlign = fmTextAlignCenter
.top = 20 + (12 * k)
.Caption = pstyle
.Left = -15

.Height = 15
.Move -45
End With
Set txtbox = Me.Controls.Add(("Forms.textbox.1"), "txtbox" & k, Visible)
With txtbox

.Width = 60
.TextAlign = fmTextAlignCenter
.top = 20 + (12 * k)
.Left = 15
.Height = 15
.Move 115

txtbox.Text = "test" & k
End With
Next


End Sub


Private Sub OK_Click()
Dim k As Integer

Me.CommandButton1.Enabled = True
Dim txtbox As TextBox
Dim txt As TextBox
Dim cvalue As String
Dim CW As Double
Dim ck As Double
Dim totalarea As Double
Dim parea As AeccParcelStatistics
Dim area As Double
Dim z As Integer
area = 0
Dim j As Integer
j = g_oDocument.Sites.Item(0).Parcels.Count
n = g_oDocument.ParcelStyles.Count
For k = 0 To n - 1
Set txtbox = Me.Controls.Item("txtbox" & k)
cvalue = txtbox.Text
ReDim areasArray(n, 3)
areasArray(k, 1) = g_oDocument.ParcelStyles.Item(k).Name
For z = 0 To j - 1
If areasArray(k, 1) =
g_oDocument.Sites.Item(0).Parcels.Item(z).StyleName Then
area =
g_oDocument.Sites.Item(0).Parcels.Item(z).Statistics.area + area
Else
End If
Next
areasArray(k, 2) = area
areasArray(k, 3) = areasArray(k, 2) * CDbl(cvalue)
totalarea = totalarea + areasArray(k, 2)
ck = ck + areasArray(k, 3)

Next
CW = ck / totalarea
End Sub


Private Sub UserForm_Click()

End Sub



"Laurie Comerford" wrote in message
news:5860716@discussion.autodesk.com...
Hi Francisco,

600 parcels should be trivial.

It is more likely that you looping structures are inefficient.

Can post post your program and drawing (delete everything but the 600
parcels from the drawing then purge, to reduce overhead ) If the drawing is
still over about 200Kb, post it to the customer files rather than here.

--


Regards

Laurie Comerford

"Francisco J. Bobadilla" wrote in message
news:5860237@discussion.autodesk.com...
I'm new into VBA programming. I did a tool that calculates the total area
by parcel styles within a specific site. Basically what I did is created a
loop and an IF statement to filter out parcels by styles, and after that put
the total parcel areas by style in an array for later use. Everyting seems
to work fine, but it takes forever to calculate the toal areas when I run
it, since it loops trhough out approx. 600 parcels. Should I be doing this
differently? Any ideas would be appreciated. Thanks
Message 4 of 8
Anonymous
in reply to: Anonymous


Hi Francisco,

 

I didn't find your drawing, but can make a couple
of comments about the code:

 

 

' Loop through parcels
styles:

For k = 0 To n - 1
    Set txtbox =
Me.Controls.Item("txtbox" & k)
    cvalue =
txtbox.Text
    ReDim areasArray(n, 3) 
color=#ff0000> ' Note you are redimming this inside the
loop
'    and hence lose the data from the previous run
through the loop
    areasArray(k, 1) =
g_oDocument.ParcelStyles.Item(k).Name
    For z = 0 To j - 1 '
Loop through the parcels'
        If
areasArray(k, 1) = g_oDocument.Sites.Item(0).Parcels.Item(z).styleName
Then
            area
= g_oDocument.Sites.Item(0).Parcels.Item(z).Statistics.area +
area
    End If
   
Next
    areasArray(k, 2) = area
   
areasArray(k, 3) = areasArray(k, 2) * CDbl(cvalue)
   
totalarea = totalarea + areasArray(k, 2)
    ck = ck +
areasArray(k, 3)
Next

What you have done here is to use the
item with the smaller number of entries as the outer loop and then processed
every item in the inner loop for each of the items in the outer
loop.

 

Thus in total you will run through
the loop "NoOfParcels * NoOfStyles" times.

 

If you cycle through the parcels in
the outer loop and find the style for the parcel - on average you will find the
parcel style half way through the style count and hence you will go through the
loop about half the number of times - and with an overhead of checking to exit
the loop.

 

I've written some code to put the
data in a list box.  This does not requre the array to hold the data and is
certainly slower than using an array as I have to convert the data backwards and
forwards between values and strings.  I should have used a 'double array'
to hold the data till ready to write it to the form

 

For this you need a form with a
combobox from which to select the required site, a list box to display the data
and two command controls.  One to run the program and to exit the
form.

 

<Code start for
Module>

Option Explicit

 

Public g_oCivilApp As AeccApplication
Public
g_oAeccDoc As AeccDocument

size=2>
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
Start Civil 3D and create Civil 3D document
object.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function
getCivilObjects() As Boolean
Dim sAppName As String
Dim oApp As
AcadApplication
    Set oApp =
ThisDrawing.Application
    sAppName =
"AeccXUiLand.AeccApplication.5.0"
    Set g_oCivilApp =
oApp.GetInterfaceObject(sAppName)
    If g_oCivilApp Is
Nothing Then
        MsgBox "Error
creating " & sAppName & ",
exit."
        getCivilObjects =
False
        Exit
Function
    End If
    Set g_oAeccDoc =
g_oCivilApp.ActiveDocument
    getCivilObjects = True
End
Function

Sub Start()
Dim bParcelsFound As
Boolean
  getCivilObjects
  For Each oSite In
g_oAeccDoc.Sites
    If oSite.Parcels.Count > 0
Then
      bParcelsFound =
True
      Exit For
    End
If
  Next
  If bParcelsFound = False Then
   
MsgBox "No parcels found in drawing"
  Else
   
UserForm1.Show
  End If
End Sub
<End module
code>

 

<Start form code>
face=Arial color=#ff0000 size=2>
Private Sub
UserForm_Initialize()
Dim iStyleNum As Integer
Dim iParcelNum As
Integer
Dim bParcelsFound As Boolean
Dim oSite As AeccSite

 

  Me.Width = 400
  Me.ListBox1.Width =
220
  Me.ListBox1.ColumnCount = 3
  Me.ListBox1.ColumnWidths =
60
  Me.ListBox1.TextAlign = fmTextAlignRight
 
Me.ListBox1.ColumnHeads = False
  Me.ListBox1.Clear
 
Me.ListBox1.AddItem "NAME "
  Me.ListBox1.List(0, 1) = "STYLE"
 
Me.ListBox1.List(0, 2) = "AREA"
  For iStyleNum = 0 To
g_oAeccDoc.ParcelStyles.Count - 1
    Me.ListBox1.AddItem
"Test " & CStr(iStyleNum)
    Me.ListBox1.List(iStyleNum +
1, 1) = g_oAeccDoc.ParcelStyles.Item(iStyleNum).Name
   
Me.ListBox1.List(iStyleNum + 1, 2) = ""
  Next iStyleNum
 
Me.ListBox1.AddItem "Total"
  Me.ListBox1.List(iStyleNum + 1, 2) =
""

 

  cbSites.Clear
  For Each oSite In
g_oAeccDoc.Sites
    If oSite.Parcels.Count > 0
Then
      cbSites.AddItem
oSite.Name
    End If
  Next
 
cbSites.ListIndex = 0

 

End Sub

 


Private Sub OK_Click()
Dim i As Integer
Dim iParcelNum As
Integer
Dim iNumParcels As Integer
Dim iNumParcelStyles As Integer
Dim
oSite As AeccSite
Dim oParcel As AeccParcel
Dim dArea() As Double
Dim
dTotal As Double
' Select the site to process from the
sites list box
  Set oSite =
g_oAeccDoc.Sites.Item(cbSites.ListIndex)
  iNumParcels =
oSite.Parcels.Count
  iNumParcelStyles =
g_oAeccDoc.ParcelStyles.Count
  ReDim dArea(1 To
iNumParcelStyles)
' Loop through the parcels -- each
parcel only addressed once
  For iParcelNum = 0 To iNumParcels -
1
    Set oParcel = oSite.Parcels.Item(iParcelNum)

color=#008000> ' find the listindex in the listbox which matches the parcel
style
 ' The styles are addressed several times, but only till the style
for each parcel is found
    i =
1
    Do While Not oParcel.Style.Name = Me.ListBox1.List(i,
1)
      i = i + 1
   
Loop
 ' Add the cummulative area for that style to
the list box
    dArea(i) = dArea(i) +
oParcel.Statistics.area
  Next iParcelNum
'
Format the areas and add to the form
  For i = 1 To
Me.ListBox1.ListCount - 2
    If dArea(i) > 0
Then
      Me.ListBox1.List(i, 2) = Format(dArea(i),
"#0.000")
      dTotal = dTotal +
dArea(i)
    Else
     
Me.ListBox1.List(i, 2) = ""
    End If
   
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 2) =
Val(Me.ListBox1.List(Me.ListBox1.ListCount - 1, 2)) + Val(Me.ListBox1.List(i,
2))
  Next i
  Me.ListBox1.List(Me.ListBox1.ListCount - 1, 2) =
Format(dTotal, "#0.000")
End Sub

Private Sub cmdExit_Click()
  me.Hide
End
Sub

<End form code>

 

I made a drawing with 880 parcels with two of five
label styles used ( I had 11 and simply made a 20 * 4 array of them.)

 

My code took about 25 seconds for this data set
doing 1780 passes (most of the parcels were labelled with the second style)
through the loop whereas your code would have done 4400.

 

The screen grab shows the form I used.

 


--

 


Regards

 

Laurie Comerford

 

 


size=2>Laurie,

<snip>
Message 5 of 8
Anonymous
in reply to: Anonymous

Hi Francisco,

Your drawing is now available.

I noticed that you have put your code in the drawing. This is NOT a good
idea particularly if you want other users to open the drawing.

However I opened the drawing without enabling its macros and wblocked it to
a clean drawing.

My program ran in about 15 seconds on the wblocked drawing.


--


Regards

Laurie Comerford
"Francisco Bobadilla" wrote in message
news:5863610@discussion.autodesk.com...
Laurie,

I have posted the file to the customer files group. Here is the code I'm
using for my looping. Thanks for your help.

Option Explicit
Public txtbox As MSForms.TextBox
Public Sub CommandButton1_Click()
Me.OK.Enabled = True
Dim pstyle As String
Dim k As Integer
Dim n As Integer
Dim cvalue As String
Dim txtbox As MSForms.TextBox
Dim ctlLabel As MSForms.Control
n = g_oDocument.ParcelStyles.Count
For k = 0 To n - 1
pstyle = g_oDocument.ParcelStyles.Item(k).Name
Set ctlLabel = Me.Controls.Add("forms.Label.1")
With ctlLabel
.Name = pstyle & k
.Width = Me.Width
.TextAlign = fmTextAlignCenter
.top = 20 + (12 * k)
.Caption = pstyle
.Left = -15

.Height = 15
.Move -45
End With
Set txtbox = Me.Controls.Add(("Forms.textbox.1"), "txtbox" & k, Visible)
With txtbox

.Width = 60
.TextAlign = fmTextAlignCenter
.top = 20 + (12 * k)
.Left = 15
.Height = 15
.Move 115

txtbox.Text = "test" & k
End With
Next


End Sub


Private Sub OK_Click()
Dim k As Integer

Me.CommandButton1.Enabled = True
Dim txtbox As TextBox
Dim txt As TextBox
Dim cvalue As String
Dim CW As Double
Dim ck As Double
Dim totalarea As Double
Dim parea As AeccParcelStatistics
Dim area As Double
Dim z As Integer
area = 0
Dim j As Integer
j = g_oDocument.Sites.Item(0).Parcels.Count
n = g_oDocument.ParcelStyles.Count
For k = 0 To n - 1
Set txtbox = Me.Controls.Item("txtbox" & k)
cvalue = txtbox.Text
ReDim areasArray(n, 3)
areasArray(k, 1) = g_oDocument.ParcelStyles.Item(k).Name
For z = 0 To j - 1
If areasArray(k, 1) =
g_oDocument.Sites.Item(0).Parcels.Item(z).StyleName Then
area =
g_oDocument.Sites.Item(0).Parcels.Item(z).Statistics.area + area
Else
End If
Next
areasArray(k, 2) = area
areasArray(k, 3) = areasArray(k, 2) * CDbl(cvalue)
totalarea = totalarea + areasArray(k, 2)
ck = ck + areasArray(k, 3)

Next
CW = ck / totalarea
End Sub


Private Sub UserForm_Click()

End Sub



"Laurie Comerford" wrote in message
news:5860716@discussion.autodesk.com...
Hi Francisco,

600 parcels should be trivial.

It is more likely that you looping structures are inefficient.

Can post post your program and drawing (delete everything but the 600
parcels from the drawing then purge, to reduce overhead ) If the drawing is
still over about 200Kb, post it to the customer files rather than here.

--


Regards

Laurie Comerford

"Francisco J. Bobadilla" wrote in message
news:5860237@discussion.autodesk.com...
I'm new into VBA programming. I did a tool that calculates the total area
by parcel styles within a specific site. Basically what I did is created a
loop and an IF statement to filter out parcels by styles, and after that put
the total parcel areas by style in an array for later use. Everyting seems
to work fine, but it takes forever to calculate the toal areas when I run
it, since it loops trhough out approx. 600 parcels. Should I be doing this
differently? Any ideas would be appreciated. Thanks
Message 6 of 8
Anonymous
in reply to: Anonymous

Thanks for your comments Laurie. I did figure out a way to loop parcels
more efficiently. THis only takes probably 1-2 seconds at the most. I use
the For Each Parcel in aparcels function. Which aparcels is the total
collection of parcels and parcel is just a variable defined as parcel.
Seems to work pretty good even though took me the entire weekend to figure
it out. I didn't get your last comment about creating the code in the
drawing. Could you please explain this to me?. I'm new in VB and trying to
learn. The way I created this code was using the vbaide (VBA editor inside
autocad), and created a new project there. Thanks for your help I
appreciate it.
"Laurie Comerford" wrote in message
news:5863710@discussion.autodesk.com...
Hi Francisco,

Your drawing is now available.

I noticed that you have put your code in the drawing. This is NOT a good
idea particularly if you want other users to open the drawing.

However I opened the drawing without enabling its macros and wblocked it to
a clean drawing.

My program ran in about 15 seconds on the wblocked drawing.


--


Regards

Laurie Comerford
"Francisco Bobadilla" wrote in message
news:5863610@discussion.autodesk.com...
Laurie,

I have posted the file to the customer files group. Here is the code I'm
using for my looping. Thanks for your help.

Option Explicit
Public txtbox As MSForms.TextBox
Public Sub CommandButton1_Click()
Me.OK.Enabled = True
Dim pstyle As String
Dim k As Integer
Dim n As Integer
Dim cvalue As String
Dim txtbox As MSForms.TextBox
Dim ctlLabel As MSForms.Control
n = g_oDocument.ParcelStyles.Count
For k = 0 To n - 1
pstyle = g_oDocument.ParcelStyles.Item(k).Name
Set ctlLabel = Me.Controls.Add("forms.Label.1")
With ctlLabel
.Name = pstyle & k
.Width = Me.Width
.TextAlign = fmTextAlignCenter
.top = 20 + (12 * k)
.Caption = pstyle
.Left = -15

.Height = 15
.Move -45
End With
Set txtbox = Me.Controls.Add(("Forms.textbox.1"), "txtbox" & k, Visible)
With txtbox

.Width = 60
.TextAlign = fmTextAlignCenter
.top = 20 + (12 * k)
.Left = 15
.Height = 15
.Move 115

txtbox.Text = "test" & k
End With
Next


End Sub


Private Sub OK_Click()
Dim k As Integer

Me.CommandButton1.Enabled = True
Dim txtbox As TextBox
Dim txt As TextBox
Dim cvalue As String
Dim CW As Double
Dim ck As Double
Dim totalarea As Double
Dim parea As AeccParcelStatistics
Dim area As Double
Dim z As Integer
area = 0
Dim j As Integer
j = g_oDocument.Sites.Item(0).Parcels.Count
n = g_oDocument.ParcelStyles.Count
For k = 0 To n - 1
Set txtbox = Me.Controls.Item("txtbox" & k)
cvalue = txtbox.Text
ReDim areasArray(n, 3)
areasArray(k, 1) = g_oDocument.ParcelStyles.Item(k).Name
For z = 0 To j - 1
If areasArray(k, 1) =
g_oDocument.Sites.Item(0).Parcels.Item(z).StyleName Then
area =
g_oDocument.Sites.Item(0).Parcels.Item(z).Statistics.area + area
Else
End If
Next
areasArray(k, 2) = area
areasArray(k, 3) = areasArray(k, 2) * CDbl(cvalue)
totalarea = totalarea + areasArray(k, 2)
ck = ck + areasArray(k, 3)

Next
CW = ck / totalarea
End Sub


Private Sub UserForm_Click()

End Sub



"Laurie Comerford" wrote in message
news:5860716@discussion.autodesk.com...
Hi Francisco,

600 parcels should be trivial.

It is more likely that you looping structures are inefficient.

Can post post your program and drawing (delete everything but the 600
parcels from the drawing then purge, to reduce overhead ) If the drawing is
still over about 200Kb, post it to the customer files rather than here.

--


Regards

Laurie Comerford

"Francisco J. Bobadilla" wrote in message
news:5860237@discussion.autodesk.com...
I'm new into VBA programming. I did a tool that calculates the total area
by parcel styles within a specific site. Basically what I did is created a
loop and an IF statement to filter out parcels by styles, and after that put
the total parcel areas by style in an array for later use. Everyting seems
to work fine, but it takes forever to calculate the toal areas when I run
it, since it loops trhough out approx. 600 parcels. Should I be doing this
differently? Any ideas would be appreciated. Thanks
Message 7 of 8
Anonymous
in reply to: Anonymous

he meant to put the code in a dvb, not the drawing.
If you make a new project in the VBAMAN dialog, you can save it as a dvb once in the VBAIDE.
thx

Francisco Bobadilla
|>Thanks for your comments Laurie. I did figure out a way to loop parcels
|>more efficiently. THis only takes probably 1-2 seconds at the most. I use
|>the For Each Parcel in aparcels function. Which aparcels is the total
|>collection of parcels and parcel is just a variable defined as parcel.
|>Seems to work pretty good even though took me the entire weekend to figure
|>it out. I didn't get your last comment about creating the code in the
|>drawing. Could you please explain this to me?. I'm new in VB and trying to
|>learn. The way I created this code was using the vbaide (VBA editor inside
|>autocad), and created a new project there. Thanks for your help I
|>appreciate it.
|>"Laurie Comerford" wrote in message
|>news:5863710@discussion.autodesk.com...
|>Hi Francisco,
|>
|>Your drawing is now available.
|>
|>I noticed that you have put your code in the drawing. This is NOT a good
|>idea particularly if you want other users to open the drawing.
|>
|>However I opened the drawing without enabling its macros and wblocked it to
|>a clean drawing.
|>
|>My program ran in about 15 seconds on the wblocked drawing.
|>
|>
|>--
|>
|>
|>Regards
|>
|>Laurie Comerford
|>"Francisco Bobadilla" wrote in message
|>news:5863610@discussion.autodesk.com...
|>Laurie,
|>
|>I have posted the file to the customer files group. Here is the code I'm
|>using for my looping. Thanks for your help.
|>
|>Option Explicit
|>Public txtbox As MSForms.TextBox
|>Public Sub CommandButton1_Click()
|> Me.OK.Enabled = True
|> Dim pstyle As String
|> Dim k As Integer
|> Dim n As Integer
|> Dim cvalue As String
|> Dim txtbox As MSForms.TextBox
|> Dim ctlLabel As MSForms.Control
|> n = g_oDocument.ParcelStyles.Count
|> For k = 0 To n - 1
|> pstyle = g_oDocument.ParcelStyles.Item(k).Name
|> Set ctlLabel = Me.Controls.Add("forms.Label.1")
|> With ctlLabel
|> .Name = pstyle & k
|> .Width = Me.Width
|> .TextAlign = fmTextAlignCenter
|> .top = 20 + (12 * k)
|> .Caption = pstyle
|> .Left = -15
|>
|> .Height = 15
|> .Move -45
|> End With
|> Set txtbox = Me.Controls.Add(("Forms.textbox.1"), "txtbox" & k, Visible)
|> With txtbox
|>
|> .Width = 60
|> .TextAlign = fmTextAlignCenter
|> .top = 20 + (12 * k)
|> .Left = 15
|> .Height = 15
|> .Move 115
|>
|> txtbox.Text = "test" & k
|> End With
|> Next
|>
|>
|> End Sub
|>
|>
|>Private Sub OK_Click()
|>Dim k As Integer
|>
|>Me.CommandButton1.Enabled = True
|>Dim txtbox As TextBox
|>Dim txt As TextBox
|>Dim cvalue As String
|>Dim CW As Double
|>Dim ck As Double
|>Dim totalarea As Double
|>Dim parea As AeccParcelStatistics
|>Dim area As Double
|>Dim z As Integer
|>area = 0
|>Dim j As Integer
|>j = g_oDocument.Sites.Item(0).Parcels.Count
|>n = g_oDocument.ParcelStyles.Count
|>For k = 0 To n - 1
|> Set txtbox = Me.Controls.Item("txtbox" & k)
|> cvalue = txtbox.Text
|> ReDim areasArray(n, 3)
|> areasArray(k, 1) = g_oDocument.ParcelStyles.Item(k).Name
|> For z = 0 To j - 1
|> If areasArray(k, 1) =
|>g_oDocument.Sites.Item(0).Parcels.Item(z).StyleName Then
|> area =
|>g_oDocument.Sites.Item(0).Parcels.Item(z).Statistics.area + area
|> Else
|> End If
|> Next
|> areasArray(k, 2) = area
|> areasArray(k, 3) = areasArray(k, 2) * CDbl(cvalue)
|> totalarea = totalarea + areasArray(k, 2)
|> ck = ck + areasArray(k, 3)
|>
|>Next
|>CW = ck / totalarea
|>End Sub
|>
|>
|>Private Sub UserForm_Click()
|>
|>End Sub
|>
|>
|>
|>"Laurie Comerford" wrote in message
|>news:5860716@discussion.autodesk.com...
|>Hi Francisco,
|>
|>600 parcels should be trivial.
|>
|>It is more likely that you looping structures are inefficient.
|>
|>Can post post your program and drawing (delete everything but the 600
|>parcels from the drawing then purge, to reduce overhead ) If the drawing is
|>still over about 200Kb, post it to the customer files rather than here.
James Maeding
Civil Engineer and Programmer
jmaeding - at - hunsaker - dotcom
Message 8 of 8
Anonymous
in reply to: Anonymous

Thaks James. I thought that's what I did. I created a dvb, possibly left
the code in the drawing as well. Thanks
"James Maeding" wrote in message
news:5864481@discussion.autodesk.com...
he meant to put the code in a dvb, not the drawing.
If you make a new project in the VBAMAN dialog, you can save it as a dvb
once in the VBAIDE.
thx

Francisco Bobadilla
|>Thanks for your comments Laurie. I did figure out a way to loop parcels
|>more efficiently. THis only takes probably 1-2 seconds at the most. I
use
|>the For Each Parcel in aparcels function. Which aparcels is the total
|>collection of parcels and parcel is just a variable defined as parcel.
|>Seems to work pretty good even though took me the entire weekend to figure
|>it out. I didn't get your last comment about creating the code in the
|>drawing. Could you please explain this to me?. I'm new in VB and trying
to
|>learn. The way I created this code was using the vbaide (VBA editor
inside
|>autocad), and created a new project there. Thanks for your help I
|>appreciate it.
|>"Laurie Comerford" wrote in message
|>news:5863710@discussion.autodesk.com...
|>Hi Francisco,
|>
|>Your drawing is now available.
|>
|>I noticed that you have put your code in the drawing. This is NOT a good
|>idea particularly if you want other users to open the drawing.
|>
|>However I opened the drawing without enabling its macros and wblocked it
to
|>a clean drawing.
|>
|>My program ran in about 15 seconds on the wblocked drawing.
|>
|>
|>--
|>
|>
|>Regards
|>
|>Laurie Comerford
|>"Francisco Bobadilla" wrote in message
|>news:5863610@discussion.autodesk.com...
|>Laurie,
|>
|>I have posted the file to the customer files group. Here is the code I'm
|>using for my looping. Thanks for your help.
|>
|>Option Explicit
|>Public txtbox As MSForms.TextBox
|>Public Sub CommandButton1_Click()
|> Me.OK.Enabled = True
|> Dim pstyle As String
|> Dim k As Integer
|> Dim n As Integer
|> Dim cvalue As String
|> Dim txtbox As MSForms.TextBox
|> Dim ctlLabel As MSForms.Control
|> n = g_oDocument.ParcelStyles.Count
|> For k = 0 To n - 1
|> pstyle = g_oDocument.ParcelStyles.Item(k).Name
|> Set ctlLabel = Me.Controls.Add("forms.Label.1")
|> With ctlLabel
|> .Name = pstyle & k
|> .Width = Me.Width
|> .TextAlign = fmTextAlignCenter
|> .top = 20 + (12 * k)
|> .Caption = pstyle
|> .Left = -15
|>
|> .Height = 15
|> .Move -45
|> End With
|> Set txtbox = Me.Controls.Add(("Forms.textbox.1"), "txtbox" & k,
Visible)
|> With txtbox
|>
|> .Width = 60
|> .TextAlign = fmTextAlignCenter
|> .top = 20 + (12 * k)
|> .Left = 15
|> .Height = 15
|> .Move 115
|>
|> txtbox.Text = "test" & k
|> End With
|> Next
|>
|>
|> End Sub
|>
|>
|>Private Sub OK_Click()
|>Dim k As Integer
|>
|>Me.CommandButton1.Enabled = True
|>Dim txtbox As TextBox
|>Dim txt As TextBox
|>Dim cvalue As String
|>Dim CW As Double
|>Dim ck As Double
|>Dim totalarea As Double
|>Dim parea As AeccParcelStatistics
|>Dim area As Double
|>Dim z As Integer
|>area = 0
|>Dim j As Integer
|>j = g_oDocument.Sites.Item(0).Parcels.Count
|>n = g_oDocument.ParcelStyles.Count
|>For k = 0 To n - 1
|> Set txtbox = Me.Controls.Item("txtbox" & k)
|> cvalue = txtbox.Text
|> ReDim areasArray(n, 3)
|> areasArray(k, 1) = g_oDocument.ParcelStyles.Item(k).Name
|> For z = 0 To j - 1
|> If areasArray(k, 1) =
|>g_oDocument.Sites.Item(0).Parcels.Item(z).StyleName Then
|> area =
|>g_oDocument.Sites.Item(0).Parcels.Item(z).Statistics.area + area
|> Else
|> End If
|> Next
|> areasArray(k, 2) = area
|> areasArray(k, 3) = areasArray(k, 2) * CDbl(cvalue)
|> totalarea = totalarea + areasArray(k, 2)
|> ck = ck + areasArray(k, 3)
|>
|>Next
|>CW = ck / totalarea
|>End Sub
|>
|>
|>Private Sub UserForm_Click()
|>
|>End Sub
|>
|>
|>
|>"Laurie Comerford" wrote in message
|>news:5860716@discussion.autodesk.com...
|>Hi Francisco,
|>
|>600 parcels should be trivial.
|>
|>It is more likely that you looping structures are inefficient.
|>
|>Can post post your program and drawing (delete everything but the 600
|>parcels from the drawing then purge, to reduce overhead ) If the drawing
is
|>still over about 200Kb, post it to the customer files rather than here.
James Maeding
Civil Engineer and Programmer
jmaeding - at - hunsaker - dotcom

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report