AutoCAD Land Desktop (Read Only)
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Parcel API BUG? Rename Won't Work!

12 REPLIES 12
Reply
Message 1 of 13
Oberer
268 Views, 12 Replies

Parcel API BUG? Rename Won't Work!

I'm sure you guys have had fun trying to work with this file.
I wrote some code hoping to make renumbering parcels a bit more user friendly. The code below will change the block attribute as well as invoke the Parcels.Rename method. When using this method, it seems to corrupt the parcel file (can't get the lot info any more).
What am I missing?
TIA!

sorry for the bad word wrap. i've pasted the code into the attached txt file if you want to see it more clearly...


( I realize the code is quite "primative." it will certainly blow up if trying to rename a parcel to one that already exists. Any other code help would be greatly appreciated!)

'works with block only - leaves project file out of sync!

Public Sub Renumber_Parcels()
Dim oSelectionSet As AcadSelectionSet 'selection set of parcel blocks
Dim oEntity As AcadEntity
Dim oBlockReference As AcadBlockReference 'each block
Dim vBlockAttributes As Variant 'blocks attributes
Dim iAttributeCounter As Integer
Dim iBlocksModifiedCounter As Integer
Dim iTextModifiedCounter As Integer
Dim sResults As String
Dim iNumberToAdd As Integer
Dim sCurrentParcelValue As String
Dim sCurrentParcelNumber As String
Dim sNewParcelValue As String
Dim vTextPosition1 As Variant
Dim vTextPosition2 As Variant
Dim sOutput As String 'output
Dim oParcel As AeccParcel
Dim oParcels As AeccParcels

' intialize counters
iBlocksModifiedCounter = 0
iAttributeCounter = 0

' get a collection of parcel blocks to modify
Set oSelectionSet = getParcelBlocks

' get number to modify with
iNumberToAdd = InputBox("Enter number to add (use a negative to subtract):")

' if parcel blocks are found
If oSelectionSet.Count > 0 Then
Set oParcels = AeccApplication.ActiveProject.Parcels
' for each object selected
For Each oEntity In oSelectionSet
'if this is a block
If TypeOf oEntity Is AcadBlockReference Then
Set oBlockReference = oEntity
' get the blocks attributes
vBlockAttributes = oBlockReference.GetAttributes
' search for the "lot number" attribute
For iAttributeCounter = LBound(vBlockAttributes) To UBound(vBlockAttributes)
' find the attribute for the lot number
If UCase(vBlockAttributes(iAttributeCounter).TagString) = "LOTDES" Then
' get the current value
sCurrentParcelValue = vBlockAttributes(iAttributeCounter).TextString
' get the current parcel
For Each oParcel In oParcels
If oParcel.Name = sCurrentParcelValue Then
Exit For
End If
Next

' search for extra chars in the label
' search for the "#" first. if the parcel is underlined and has the # sign,
' this will take care of it
vTextPosition1 = InStr(1, sCurrentParcelValue, "#", vbTextCompare)
' search only for the underline
vTextPosition2 = InStr(1, sCurrentParcelValue, "%%U", vbTextCompare)
If vTextPosition1 > 0 Then
' current parcel number
sCurrentParcelNumber = Mid(sCurrentParcelValue, vTextPosition1 + 1, Len(sCurrentParcelValue))
' create new parcel label
sNewParcelValue = Mid(sCurrentParcelValue, 1, vTextPosition1) & sCurrentParcelNumber + iNumberToAdd
' modify block
vBlockAttributes(iAttributeCounter).TextString = sNewParcelValue
sOutput = sOutput & sCurrentParcelValue & "->" & sNewParcelValue & vbNewLine
iBlocksModifiedCounter = iBlocksModifiedCounter + 1
' if the underline was found
ElseIf vTextPosition2 > 0 Then
' current parcel number
sCurrentParcelNumber = Mid(sCurrentParcelValue, vTextPosition2 + 3, Len(sCurrentParcelValue))
' create new parcel label
sNewParcelValue = Mid(sCurrentParcelValue, 1, vTextPosition2 + 2) & sCurrentParcelNumber + iNumberToAdd
' modify block
vBlockAttributes(iAttributeCounter).TextString = sNewParcelValue
sOutput = sOutput & sCurrentParcelValue & "->" & sNewParcelValue & vbNewLine
iBlocksModifiedCounter = iBlocksModifiedCounter + 1
' didn't find a "#" or "%%U", so it should be a number
ElseIf IsNumeric(sCurrentParcelValue) = True Then
' current parcel number
sCurrentParcelNumber = sCurrentParcelValue
' create new parcel label
sNewParcelValue = sCurrentParcelValue + iNumberToAdd
' modify block
vBlockAttributes(iAttributeCounter).TextString = sNewParcelValue
sOutput = sOutput & sCurrentParcelValue & " -> " & sNewParcelValue & vbNewLine
iBlocksModifiedCounter = iBlocksModifiedCounter + 1

Else
MsgBox "Unable to change Parcel: " & sCurrentParcelValue
End If

If Not oParcel Is Nothing Then
oParcels.Rename sCurrentParcelValue, sNewParcelValue
End If

End If
Next iAttributeCounter
End If
Next oEntity

' no blocks found to modify
Else
sResults = "No parcel label blocks were found/selected to update."
MsgBox sResults, vbInformation, "No Parcel Labels Selected"
End If

' display any results
If iBlocksModifiedCounter > 0 Then
sResults = "[" & CStr(iBlocksModifiedCounter) & "] parcel blocks(s) updated." & vbNewLine
End If

If iTextModifiedCounter > 0 Then
sResults = "[" & CStr(iTextModifiedCounter) & "] parcel text label(s) updated." & vbNewLine
End If

If sResults <> vbNullString Then
MsgBox sResults & "LOT CONVERSION: " & vbNewLine & sOutput
End If

' release objects from memory
Set oEntity = Nothing
Set oBlockReference = Nothing
Set oSelectionSet = Nothing
Set oParcels = Nothing
If Not oParcel Is Nothing Then
Set oParcel = Nothing
End If



End Sub
12 REPLIES 12
Message 2 of 13
Oberer
in reply to: Oberer

my apologies. I should have started with the most simple code and proceeded. I had already written the attribute renumber when i realized i should also be modifing my project file. I took a step back and tried to run the code from help.
I'm getting the same results - a bad parcel def.



BTW: LDD 3, SP 2, XP SP 2

Sub Example_Rename_Parcels()

' This example starts by creating a Parcel named "NewParcel".
' The new Parcel name displayed. Finally, the new Parcel is renamed
' to "OldName" and is displayed again.
Dim parcels As AeccParcels
Dim parcel As AeccParcel
Set parcels = AeccApplication.ActiveProject.parcels


' ' Rename the new Parcel to "OldParcel"
parcels.Rename "BNDRY #3", "BNDRY #3dt"

MsgBox "The Parcel name is: " & parcel.Name, vbInformation, "Rename Example"

End Sub
Message 3 of 13
Anonymous
in reply to: Oberer

Hi, I haven't tried to test your code, but the line: > > parcels.Rename "BNDRY #3", "BNDRY #3dt" doesn't look sensible as it seems to be trying to rename "parcels" rather than an individual "parcel" Possibly parcel.Rename "BNDRY #3", "BNDRY #3dt" would work, or try something along the lines of: For Each parcel in parcels if parcel.name = "Newparcel" then parcel.name = "OldParcel" end if next -- Laurie Comerford CADApps www.cadapps.com.au "Oberer" wrote in message news:6346821.1103036748453.JavaMail.jive@jiveforum2.autodesk.com... > my apologies. I should have started with the most simple code and proceeded. I had already written the attribute renumber when i realized i should also be modifing my project file. I took a step back and tried to run the code from help. > I'm getting the same results - a bad parcel def. > > > > BTW: LDD 3, SP 2, XP SP 2 > > Sub Example_Rename_Parcels() > > ' This example starts by creating a Parcel named "NewParcel". > ' The new Parcel name displayed. Finally, the new Parcel is renamed > ' to "OldName" and is displayed again. > Dim parcels As AeccParcels > Dim parcel As AeccParcel > Set parcels = AeccApplication.ActiveProject.parcels > > > ' ' Rename the new Parcel to "OldParcel" > parcels.Rename "BNDRY #3", "BNDRY #3dt" > > MsgBox "The Parcel name is: " & parcel.Name, vbInformation, "Rename Example" > > End Sub
Message 4 of 13
Oberer
in reply to: Oberer

Hi Laurie. that code was taken straight from my LDD help flie.

Here's there sample code:
(so you can see why i'm asking if there's something wrong with the API. it doesn't seem to work)

Sub Example_Rename_Parcels()

' This example starts by creating a Parcel named "NewParcel".
' The new Parcel name displayed. Finally, the new Parcel is renamed
' to "OldName" and is displayed again.
Dim parcels As AeccParcels
Dim parcel As AeccParcel
Set parcels = AeccApplication.ActiveProject.Parcels

' ' Add a new Parcel name "NewParcel"
Set parcel = parcels.Add("NewParcel")

MsgBox "The Parcel name is: " & parcel.Name, vbInformation, "Rename Example"

' ' Rename the new Parcel to "OldParcel"
parcels.Rename "NewParcel", "OldParcel"

MsgBox "The Parcel name is: " & parcel.Name, vbInformation, "Rename Example"

End Sub
Message 5 of 13
Anonymous
in reply to: Oberer

Laurie's right, you're looking at the wrong object. The Parcels collection won't have a method like rename, only the individual Parcel will. When you type "parcels." does rename show up in the list of accepted methods and properties? I'd bet that the "parcel." list would show a function for rename. I don't think there's a bug in the API, there's just a mistake in the sample code. -- James Wedding, P.E. Technology Manager Associate Jones & Boyd, Inc. Dallas, TX XP/2 on P4-3.4/1G LDT2005+C3D2005
Message 6 of 13
Anonymous
in reply to: Oberer

Nope, Oberer's right. The Collection holds the Rename method.......and if you use it you can no longer access the Parcel's data......in LDD3 anyway -- Jeff check out www.cadvault.com "James Wedding" wrote in message news:41bf55d2$1_3@newsprd01... > Laurie's right, you're looking at the wrong object. The Parcels collection > won't have a method like rename, only the individual Parcel will. > > When you type "parcels." does rename show up in the list of accepted > methods and properties? I'd bet that the "parcel." list would show a > function for rename. I don't think there's a bug in the API, there's just > a mistake in the sample code. > > > -- > James Wedding, P.E. > Technology Manager > Associate > Jones & Boyd, Inc. > Dallas, TX > XP/2 on P4-3.4/1G > LDT2005+C3D2005 >
Message 7 of 13
Anonymous
in reply to: Oberer

Well damn then, it's a bug then. Why would you want to rename the collection? Seems odd. One more reason to just skip to C3D. -- James Wedding, P.E. Technology Manager Associate Jones & Boyd, Inc. Dallas, TX XP/2 on P4-3.4/1G LDT2005+C3D2005
Message 8 of 13
Oberer
in reply to: Oberer

Jeff writes:
Nope, Oberer's right. The Collection holds the Rename method.......and if
you use it you can no longer access the Parcel's data......in LDD3 anyway.
>Thanks Jeff. I was simply copying the help file.

Re: Parcel API BUG? Rename Won't Work!
Well damn then, it's a bug then. Why would you want to rename the
collection? Seems odd.

One more reason to just skip to C3D.
>Or perhaps ask ONCE again, why does ACAD not test/develop their tools and offer patches/updates.
Yeah, it would be "easier" to go with the ol' microsoft approach, just keep updating...
Message 9 of 13
Anonymous
in reply to: Oberer

Hi, Does it occur to you that you may have been amongst the first users ever to do this and that the bug had never been identified and pointed out to Autodesk? There aren't huge numbers of developers using the Land Desktop APIs and unless there is strong enough requirement to make waves about a problem, some may simply give up and go do something else.. For example have you reported it to their bug site? Although many Autodesk staffers read these NGs, posting here does not constitute a bug report. -- Laurie Comerford CADApps www.cadapps.com.au "Oberer" wrote in message news:30166049.1103141234852.JavaMail.jive@jiveforum1.autodesk.com... > Jeff writes: > Nope, Oberer's right. The Collection holds the Rename method.......and if > you use it you can no longer access the Parcel's data......in LDD3 anyway. > >Thanks Jeff. I was simply copying the help file. > > Re: Parcel API BUG? Rename Won't Work! > Well damn then, it's a bug then. Why would you want to rename the > collection? Seems odd. > > One more reason to just skip to C3D. > >Or perhaps ask ONCE again, why does ACAD not test/develop their tools and offer patches/updates. > Yeah, it would be "easier" to go with the ol' microsoft approach, just keep updating...
Message 10 of 13
Anonymous
in reply to: Oberer

While skipping to Civil3D sounds nice, it is not anywhere near what is needed to do complete plans. Until alignments are shared like LDT, it is not practical, and I cannot have users using two softwares to do design. So Autodesk is obligated to fix LDT until Civil3D is actually ready to replace LDT. I do not like how Civil 3D is being marketed right now. The uneducated person (not the people in this discussion...) will think its ready to go based on the hype I have seen. It is simply only ready for surveyors and graders, not final design. People like James W seem to be using it for final design (I could be wrong), but I am guessing this is because they are the only one working on the project. It must be totally awkward having everything in one drawing. This shows how clever they are to make this work at all, you would have to have multiple layouts in one drawing and all kinds of poisinous stuff going on. Thats ok for graders, but does not fly with a team. Also, the way I see people annotating with the way Civil3D is right now, it is no better than LDT. The labels are not reactive. They do not update when the profile changes. So labels similar to what Mapcad has done are not in the product yet. These things will go away soon I hear, but I think Autodesk would be wiser to be more specific on what Civil 3D can and cannot do in its marketing. It only irritates people that do know what it cannot do. (Or it irritates people like me who are not sure and are dissapointed when they see the truth) I had hoped alignments could be shared so that was a big eye opener when I found they could not... Oberer |>Jeff writes: |>Nope, Oberer's right. The Collection holds the Rename method.......and if |>you use it you can no longer access the Parcel's data......in LDD3 anyway. |>>Thanks Jeff. I was simply copying the help file. |> |>Re: Parcel API BUG? Rename Won't Work! |>Well damn then, it's a bug then. Why would you want to rename the |>collection? Seems odd. |> |>One more reason to just skip to C3D. |>>Or perhaps ask ONCE again, why does ACAD not test/develop their tools and offer patches/updates. |>Yeah, it would be "easier" to go with the ol' microsoft approach, just keep updating... James Maeding jmaeding at hunsaker dot com Civil Engineer/Programmer
Message 11 of 13
Anonymous
in reply to: Oberer

I agree totally with this. People underestimate the need for us to push on Autodesk to fix things that come up. They do fix things and are helpful if you provide good info. I have a few API bugs that are not being addressed though as the developers are on Civil3D now. So its a mix on if they fix things... Its like the animal is too big now. Releasing fixes is a huge task even though the fix is probably easy many times. "Laurie Comerford" |>Hi, |> |>Does it occur to you that you may have been amongst the first users ever to |>do this and that the bug had never been identified and pointed out to |>Autodesk? There aren't huge numbers of developers using the Land Desktop |>APIs and unless there is strong enough requirement to make waves about a |>problem, some may simply give up and go do something else.. |> |>For example have you reported it to their bug site? Although many Autodesk |>staffers read these NGs, posting here does not constitute a bug report. James Maeding jmaeding at hunsaker dot com Civil Engineer/Programmer
Message 12 of 13
Oberer
in reply to: Oberer

"Does it occur to you that you may have been amongst the first users ever to do this and that the bug had never been identified and pointed out to Autodesk? "

I've clearly demonstrated my coding limitations a number of times here, so i can easily say "no, i never considered that." To me, a piece of software that's been out for YEARS isn't exactly a "beta" anymore. I'd also tend to think the guy who wrote the help file would actually have tried the code???
Or better yet, the developer would have tried his/her method as well.

Believe me, i can clearly see in my own struggles to accomplish the most basic of tasks programatically how difficult writing such an app is. however, it's also why (you'd think) they've been the industry leader for such a long time.

thanks for the responses, especially those regrarding civil 3d. we're still wary of the upgrade until the dust settles a bit more...
Message 13 of 13
kowboy
in reply to: Oberer

I just received a demo version of Civil 3d. It is totally unworkable for reliably creating and editing parcels. The parcel manager crashes constantly. Spend more time rebooting and trying to reconstruct two days work with only little luck.

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

Post to forums  

Autodesk Design & Make Report