Script fails to change all block parameters

711
5
Jump to solution
11-18-2016 06:59 PM
RobertYu
New Contributor III

Hello,

I have a simple python script that changes the block type.  When I run it, it seems to skip some of the blocks.

To run, just load the attached script and run it.  It looks for all the blocks and changes it.

0 Kudos
1 Solution

Accepted Solutions
RobertYu
New Contributor III

Ah. figured it out.  I needed to add this line:

ce.setAttributeSource(block,"/ce/block/type", "USER")

View solution in original post

0 Kudos
5 Replies
selvavinayagamkanagavel2
New Contributor

Hi

I think you need to check the blocks of CE whether all the closures were exactly made, and reiterate to get the entire blocks.

Dr. Selvavinayagam

0 Kudos
RobertYu
New Contributor III

Thank you for the response.

In my example, I have 9 blocks.  When I run the script, it works on 8 of them.  The 9th one does not change.

However, I can select the block and change the type manually using the UI.

I'll give your suggestion a try, nonetheless, thank you.

-Robert

0 Kudos
RobertYu
New Contributor III

After some more experiments, I found that if I select the block that did not respond to the script, and

update it manually using the UI, the block will then respond to the script thereafter.  This seems like a bug,

or there is something I am not doing correctly.

0 Kudos
RobertYu
New Contributor III

Ah. figured it out.  I needed to add this line:

ce.setAttributeSource(block,"/ce/block/type", "USER")

0 Kudos
CherylLau
Esri Regular Contributor

This is a bit tricky.  When setting attributes in Python, it's the user set values of these attributes that are changed.  The default values for the attribute type are not changed.  So, if you have a block with the attribute type whose source is "default", its value won't change.  If you have a block with the attribute type whose source is a user-set value (bold in the Inspector), then this value will change.  Basically, this means that in Python you have to set the attribute value and set the source to be "USER" as you've figured out.