I'm working on a Dynamo script for Civil 3D, and I need your help to create a
Python node that does the following:
1.It should take as input a LIST of existing COGO points with the HANDLES as
KEYS and the NAME of the points as VALUES, NOT A DICTIONARY.
2.It should allow me to input a string specifying the COGO points I want to
RENAME. If it's a single point, I'll write just one (e.g., sp05), and if there are
multiple points, I'll use a sequence (e.g., sp12-sp15).
3.Another input should allow me to enter a string specifying the new NAMES
that will replace the points mentioned in step 2 (e.g., sp03-sp06).
For example, if I need to rename multiple points from the INPUT LISTS, which
contains the following:
208CCD9 -> sp05
208CE2A -> sp13
208CE2B -> sp14
208CDDC -> sp06
208CCD8 -> sp04
208CCD7 -> sp03
208CCD6 -> sp02
208CCD5 -> sp01
208CDDD -> sp07
208CDDE -> sp08
208CDDF -> sp09
208CDE0 -> sp10
208CDE1 -> sp11
208CE29 -> sp12
208CE2C -> sp15
I should replace the following NAMES/VALUES: [sp12, sp13, sp14, sp15] with
[sp03, sp04, sp05, sp06] as mentioned in steps 2 and 3. Resulting in
something like this:
208CCD9 -> sp05
208CE2A -> sp13 -> sp04
208CE2B -> sp14 -> sp05
208CDDC -> sp06
208CCD8 -> sp04
208CCD7 -> sp03
208CCD6 -> sp02
208CCD5 -> sp01
208CDDD -> sp07
208CDDE -> sp08
208CDDF -> sp09
208CDE0 -> sp10
208CDE1 -> sp11
208CE29 -> sp12 -> sp03
208CE2C -> sp15 -> sp06
But to make the exercise simple you can ordered the values list like [sp01,
sp02, sp03, sp04, sp05, sp06, sp07, sp08, sp09, sp10, sp11, sp12, sp13,
sp14, sp15]
However, since duplicate values [NAMES] are not allowed, the values from
the original list that were not modified should be renamed as well except for
those values minor to the input sp03 in this case. The remaining points
[sp03, sp04, sp05, sp06, sp07, sp08, sp09, sp10, sp11] will become [sp07,
sp08, sp09, sp10, sp11, sp12, sp13, sp14, sp15].
208CCD5 -> sp01 -> sp01
208CCD6 -> sp02 -> sp02
208CCD7 -> sp03 -> sp07
208CCD8 -> sp04 -> sp08
208CCD9 -> sp05 -> sp09
208CDDC -> sp06 -> sp10
208CDDD -> sp07 -> sp11
208CDDE -> sp08 -> sp12
208CDDF -> sp09 -> sp13
208CDE0 -> sp10 -> sp14
208CDE1 -> sp11 -> sp15
208CE29 -> sp12 -> sp03
208CE2A -> sp13 -> sp04
208CE2B -> sp14 -> sp05
208CE2C -> sp15 -> sp06
Assume like the values we replace [sp12,sp13,sp14,sp15] for [sp03, sp04,
sp05, sp06] were moved after the sp02 in the original values sorted, like this
[sp01, sp02, [values replaced = sp03, sp04, sp05, sp06], sp03, sp04, sp05,
sp06, sp07, sp08, sp09, sp10, sp11] so that is why you have to change from
sp03 to sp11 in order to get continuation, like this [sp01, sp02, [values
replaced= sp03, sp04, sp05, sp06], sp07, sp08, sp09, sp10, sp11, sp12,
sp13, sp14, sp15]
208CCD5 -> sp01 -> sp01
208CCD6 -> sp02 -> sp02
208CE29 -> sp12 -> sp03
208CE2A -> sp13 -> sp04
208CE2B -> sp14 -> sp05
208CE2C -> sp15 -> sp06
208CCD7 -> sp03 -> sp07
208CCD8 -> sp04 -> sp08
208CCD9 -> sp05 -> sp09
208CDDC -> sp06 -> sp10
208CDDD -> sp07 -> sp11
208CDDE -> sp08 -> sp12
208CDDF -> sp09 -> sp13
208CDE0 -> sp10 -> sp14
208CDE1 -> sp11 -> sp15
But The final output list of NAMES should maintain the original order base on
the HANDLES mentioned above, while only replacing the necessary values,
resulting in:
208CCD9 -> sp09
208CE2A -> sp04
208CE2B -> sp05
208CDDC -> sp10
208CCD8 -> sp08
208CCD7 -> sp07
208CCD6 -> sp02
208CCD5 -> sp01
208CDDD -> sp11
208CDDE -> sp12
208CDDF -> sp13
208CDE0 -> sp14
208CDE1 -> sp15
208CE29 -> sp03
208CE2C -> sp06