Assigning objects on specific layer to a payitem with a CSV Mapping

Hi all,

This is my first graph moving forward with Dynamo.

I’m trying to accomplish a graph that will grab all the objects on a layer and assign them on a payitem. (See printscreen)

The thing is that i haven’t found nothing that can assign a payitem number on the QTO function of Civil 3D.

And my knowledge on doing python is a bit limited but I always like a new challenge.

Maybe just some guidance on how to accomplish this ?

I’ve only seen function that can assign to an area but i’d need to assign to lines, etc
image

I’ve found method the method (function) that can assign a payitem by object

image

Pay Item IDs are stored in XData so you can add / modify there

We now have illuminated parking lines
image

Multiple IDs
EDIT Correcting line 2
image

image

2 Likes

Hi @Mike.Buttery

Thank you for pointing me onto the solution of what i’m accomplishing.

This brings me up to a sub-question :
Trying to “join” that integer (2 - in your example)

Why is it always 2 ?

And how can i join it with my list strings of payitme numbers

I’m having a little hard time playing with lists right now

This may be usefull to see the error message :

image

Hi @Mike.Buttery

I’ve been trying to make this one work today and i feel i’m almost there (See picture)

We can see in the output of my code in the codeblock that i have a correct list in the “5 list”

And it assigns in the modelspace the payitem to those items.

I just don’t understand why my “for” isn’t working properly in there

It shouldnt put all “null” from index 0 to 4 in the output

What am i missing ?

Btw, thanx in advance to anyone who cares to barge in this post !

The QTO Manager is using the XData to store information - the XData of an object is a collection of ResultsBuffers as a RegisteredApp (Basically an id). A results buffer has two properties - the Value Type (DXFCode) and the Value. Using the following code we can find the Type (don’t forget to import System)

codes = IN[0] if isinstance(IN[0], list) else [IN[0]]
OUT = [System.Enum.GetName(DxfCode, code) for code in codes]

image

I’m not super au fait with the QTO so I am assuming the integer is some internal type for the QTO. The second string is the Pay Item Id code.

I must apologise for the incorrect multi-code solution - should look like this
image

I did a bit more digging in the API and it is possible to add and modify Pay Item Ids with the QTOUtility Class which is not implemented as part of the Camber QTO nodes

Example code below with import traceback added to imports

objects = IN[0]
payitemids = IN[1] if isinstance(IN[1], list) else [IN[1]]  # string, list of strings
deleteallids = IN[2]  # bool

with adoc.LockDocument():
    with adoc.Database as db:

        with db.TransactionManager.StartTransaction() as t:
            output = []
            for obj in objects:
                try:
                    id = obj.InternalObjectId
                    if deleteallids:
                        QTOUtility.DeleteAllPayItemsIds(id)
                    for pid in payitemids:
                        QTOUtility.AddPayItemId(id, pid)
                    output.append(id)
                except:
                    output.append(traceback.format_exc())
            t.Commit()

# Assign your output to the OUT variable.
OUT = payitemids, output
3 Likes

Good morning @Mike.Buttery

Thanx for all this information ! I did found some information but you digged deep !

Let me explain a bit what my graph does :

It takes a CSV file that maps Layers & Payitem codes
In the process, the graph selects and assigns payitem codes on objects per layer

So i need to keep things dynamic and not fixed (the number of codes for example)

I’m almost there and was able to make it almost work, except that my “for” statement doesn’t seem to work properly (See printscreen) :

We can we that it adds the last combination of integer (int 2) and the string for the payitem code

Does someone see something not working properly in my printscreen for the for statement why it only passes at the last for looping the information into the list ?

Are you trying to achieve something like this?
image

Yes but the list needs to be dynamicly populated by the CSV

image

That’s why i’m trying a for approach in a codeblock that builds the list correctly

The nodes should work dynamically connect your code block to the List.Map

Before i try to switch and use list.map node, i want to give a last chance to what i’ve done until now
I feel like i’m missing something a little detail and it doesnt work

Can you give a look this printscreen, do you see something wrong with my for statement ? (On printscreen just below)

image

It gives me this result :
image

And I really just want to generate a list like this (And that’s what the ObjectExtensions.AddXData is excepting)

Cause the list of object selected is the same number of layers to the list to associate its polyline with a payitem code:

There is only one value in l i.e 5 - Code below is iterates over a range of index numbers
image

1 Like

Eureka, it works !

I knew i wasn’t crazy and i was mising a detail !

Thank you @Mike.Buttery !

3 Likes

Hi, can i get the node please ? Thanks :smiley: