Turning attributes off in CADWorx P&ID Professional

This week on the forums, Kather asked a question that piqued my curiosity.  The question was, “Is there a way to globally turn off attributes in a drawing file.”  I remembered that a while back a solution had been presented to filter out existing items in the plant database by Steven Hollinger.  So, I wanted to apply this to the status field for CADWorx P&ID.

It turns out that Microsoft has published a knowledge base article on filtering out for bitwise integers, which explains how to use SQL in Access to isolate values.

So, that was geek talk…what does it mean?  Well, P&ID use the value 128 in the status field to indicate whether a block should have the attribute values filled in from the database.  You can’t use simple math for various programming reasons, so we had to jump through a hoop to find out if the flag is set.

In any case, here are the solutions I found. 

This will turn the attributes on for valves in a drawing that has PID2 in the drawing name:
UPDATE [Components-Valves] SET [Components-Valves].STATUS_ = CInt(([Components-Valves]![STATUS_]))+"128"
WHERE ((((CInt([Components-Valves]![STATUS_])\128) Mod 2)=0) AND (([Components-Valves].DWG_NAME_) Like "*PID2*"));

This will turn the attributes off for valves in a drawing that has PID2 in the drawing name:
UPDATE [Components-Valves] SET [Components-Valves].STATUS_ = CInt([Components-Valves]![STATUS_])-"128"
WHERE ((((CInt([Components-Valves]![STATUS_])\128) Mod 2)=1) AND (([Components-Valves].DWG_NAME_) Like "*PID2*"));

See this post to learn how to use the SQL query:
http://www.pdoteam.com/index.php/2009/11/sharing-sql-queries/