How to set "Pinned" to yes

How to set "Pinned" to yes

studio-a-int
Advocate Advocate
3,714 Views
3 Replies
Message 1 of 4

How to set "Pinned" to yes

studio-a-int
Advocate
Advocate

Hello -

 

I'm iterating through a list of selected elements and I want to Pin/UnPin them.

 

If I run:

 

PIN_STATUS = [i.Pinned for i in my_selection]

 

I get a list of

 

[true, false, true, true, ... ]

 

In the API the method is 

 

Pinned { get; set; }

But I could not make it work.

 

(I have the transaction started and ended before and after)

 

Help greatly appreciated.

 

Thank you.

Accepted solutions (1)
3,715 Views
3 Replies
Replies (3)
Message 2 of 4

matthew_taylor
Advisor
Advisor

Hi @studio-a-int,

Unpinning works using this method:

 

Dim e As DB.Element = ...
If e.Pinned Then
       e.Pinned = False
...

So, this should work the other way...:

Dim e As DB.Element = ...
If not e.Pinned Then
       e.Pinned = True
...

Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
0 Likes
Message 3 of 4

studio-a-int
Advocate
Advocate

Found the solution:

 

[Element.Pinned.SetValue(i, True) for i in my_selection]

0 Likes
Message 4 of 4

studio-a-int
Advocate
Advocate
Accepted solution

Matt -

 

thanks for your reply.

 

As I mentioned, I found the right syntax right after posting.

 

And that is because, I'm using Python for initial coding work (takes a bit to translate from C# to Python).

 

PIN_SELECTION  = [Element.Pinned.SetValue(i, True) for i in my_selection]

 

or

 

UNPIN_SELECTION  = [Element.Pinned.SetValue(i, False) for i in my_selection]