<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://communities.bentley.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Set Tag Values in Selected Element Only</title><link>https://communities.bentley.com/products/programming/microstation_programming/f/microstation-programming---forum/87212/set-tag-values-in-selected-element-only</link><description>Hi All, 
 Having a problem with setting a tag value through VBA. 
 I want to only set a single TagSet, but it has the same name as another set placed on the design already. 
 The Cell is called &amp;quot;DM1&amp;quot; and contains a TagSet called &amp;quot;Deco&amp;quot;. This cell needs</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>Re: Set Tag Values in Selected Element Only</title><link>https://communities.bentley.com/thread/248656?ContentTypeID=1</link><pubDate>Thu, 20 Jun 2013 12:06:20 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:1cac56ed-7281-46fb-8f43-620de358c290</guid><dc:creator>Jon Summers</dc:creator><description>&lt;p&gt;[quote user=&amp;quot;Rob Golding&amp;quot;] Are tags the best way to go about this?[/quote]&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t know your requirements, so can&amp;#39;t comment.&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s a review of &lt;a title="LA Solutions: Databases and MicroStation" href="http://www.la-solutions.co.uk/content/Databases/Databases.htm"&gt;MicroStation and Databases&lt;/a&gt;, which covers both DGN internal and external data.&lt;/p&gt;
&lt;p&gt;[quote user=&amp;quot;Rob Golding&amp;quot;] i only chose Tags because i don&amp;#39;t really know of a better solution[/quote]&lt;/p&gt;
&lt;p&gt;It&amp;#39;s best to go for a solution that (a) you understand and (b) is exposed to VBA.&amp;nbsp; Not all data models are currently possible using VBA.&amp;nbsp; For example, &lt;em&gt;EC Schemas&lt;/em&gt; (&lt;a title="Bentley Systems: i-Models" href="http://www.bentley.com/en-GB/Products/ProjectWise+Navigator/i-model.htm"&gt;i-Models&lt;/a&gt;) are pretty new and a C++ API was published in autumn 2012.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>Re: Set Tag Values in Selected Element Only</title><link>https://communities.bentley.com/thread/248653?ContentTypeID=1</link><pubDate>Thu, 20 Jun 2013 10:43:14 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:8a86b348-d716-4487-aa7c-4676f296def9</guid><dc:creator>Rob Golding</dc:creator><description>&lt;p&gt;Thanks Jon,&lt;/p&gt;
&lt;p&gt;Apologies for the delay, have been on leave.&lt;/p&gt;
&lt;p&gt;I will continue to play around with Tags, but from your vast experience, are Tags the best way to go about this? Or is there another way to misc data inside of an element?&lt;/p&gt;
&lt;p&gt;Again i only chose Tags because i don&amp;#39;t really know of a better solution so i am interested to see what others think, i would prefer to not refer to any external files and contain all the data inside of the DGN.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>Re: Set Tag Values in Selected Element Only</title><link>https://communities.bentley.com/thread/246325?ContentTypeID=1</link><pubDate>Wed, 29 May 2013 12:40:51 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:94d96a72-7369-450d-a578-94d7aedb320a</guid><dc:creator>Jon Summers</dc:creator><description>&lt;p&gt;[quote user=&amp;quot;Rob Golding&amp;quot;] Each streetlight it contains 3 parts... a pole, bracket and light. [/quote]&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create a Tag Set s&lt;em&gt;treet-furniture&lt;/em&gt;
&lt;ul&gt;
&lt;li&gt;For that Tag Set define Tags &lt;em&gt;pole&lt;/em&gt;, &lt;em&gt;bracket&lt;/em&gt; and &lt;em&gt;light&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Place some lighting cells
&lt;ul&gt;
&lt;li&gt;Attach Tag Set s&lt;em&gt;treet-furniture&lt;/em&gt; to each cellusing MicroStation&amp;#39;s Tags toolbox&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Use &lt;a href="http://www.la-solutions.co.uk/content/FlexiTable.htm" title="LA Solutions: FlexiTable" target="_blank"&gt;FlexiTable &lt;/a&gt;to extract tag data
&lt;ul&gt;
&lt;li&gt;Alternatively, use MicroStation&amp;#39;s built-in tag reporting tools&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I&amp;#39;ve created an example for you. In the attached &lt;span style="font-family:courier new,courier;"&gt;street-lighting.zip&lt;/span&gt;, there&amp;#39;s a DGN file. It contains a Tag Set definition, &lt;em&gt;street-furniture&lt;/em&gt; having tags as above. The default DGN model has some cell placements with some tags attached. &lt;a href="http://www.la-solutions.co.uk/content/FlexiTable.htm" title="LA Solutions: FlexiTable" target="_blank"&gt;FlexiTable&lt;/a&gt; created a tag report and saved it in Excel format.&lt;/p&gt;
&lt;!-- signoff --&gt;
&lt;p&gt;Regards, Jon Summers &lt;br /&gt; &lt;a href="http://www.la-solutions.co.uk"&gt;LA Solutions&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description><enclosure url="https://communities.bentley.com/cfs-file/__key/telligent-evolution-components-attachments/00-343173-01-00-00-24-63-25/street_2D00_furniture.zip" length="36939" type="application/zip" /></item><item><title>Re: Set Tag Values in Selected Element Only</title><link>https://communities.bentley.com/thread/246318?ContentTypeID=1</link><pubDate>Wed, 29 May 2013 10:50:26 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:718e6018-d533-49a9-9d07-020fcf01c74a</guid><dc:creator>Rob Golding</dc:creator><description>&lt;p&gt;[quote user=&amp;quot;Michael Stark&amp;quot;]&lt;/p&gt;
&lt;p&gt;[quote user=&amp;quot;Rob Golding&amp;quot;]Once the Value for the tags are set, they should not change until removed from the design.[/quote]&lt;/p&gt;
&lt;p&gt;Unfortunately this is the only thing that cannot be asured and the reason why many programmers do not use tags, if consistency is required.&lt;/p&gt;
&lt;p&gt;While the idea of using tags for displayable informations is a good one, you must be aware that each information might be manipulated by the user. Even parts, or the whole tag can be deleted by mistake, so you need a little goodwill. On the other hand, while there are other solutions for storing additional data, it is more difficult to get those data displayed, so if you trust your users that far, tags will be fine.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;
&lt;p&gt;[/quote]&lt;/p&gt;
&lt;p&gt;I&amp;#39;m undecided on what to do so suggestions are certinitley welcome!&lt;/p&gt;
&lt;p&gt;Basically what i&amp;#39;m trying to achieve, is to somehow store Data on these cells (the bracket and light information) so that when i run my program to scan the drawing for the data, it knows that for those particular cells what the bracket and lights are and can print it into a text file.&lt;/p&gt;
&lt;p&gt;Its for a street light design program i&amp;#39;ve been asked to modify (but i&amp;#39;m rewriting as the old one was a pain).&amp;nbsp;Tags were the quickest and easiest way i could think of to do it.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;For each streetlight it contains 3 parts... a pole, bracket and light.&lt;/p&gt;
&lt;p&gt;The easiest thing for me to do is create 3 cells and place them all at the same location at the same time so that the user only sees 1. BUT what if one of them is moved? They all have to move... if i group them then the cell loses its name.&lt;/p&gt;
&lt;p&gt;Once the data is on the drawing, my program then goes and finds the cells and prints the quantity to a text file which is then imported into another program (all of that is already done and working).&lt;/p&gt;
&lt;p&gt;I&amp;#39;m just trying to work out the best way to store the bracket and light information, whilst still being able to easily locate the data when generating the text file.&lt;/p&gt;
&lt;p&gt;I did think about if the tags were deleted. Was going to look at locking them once placed, but then they can&amp;#39;t be moved if interfere with other elements.&lt;/p&gt;
&lt;p&gt;If anyone can think of a better or easier way then please let me know!! Any help is greatly appreciated!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>Re: Set Tag Values in Selected Element Only</title><link>https://communities.bentley.com/thread/246075?ContentTypeID=1</link><pubDate>Mon, 27 May 2013 13:16:58 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:8bb80985-bf33-4e0e-8dca-c88c77892e20</guid><dc:creator>Michael Stark</dc:creator><description>&lt;p&gt;[quote user=&amp;quot;Rob Golding&amp;quot;]Once the Value for the tags are set, they should not change until removed from the design.[/quote]&lt;/p&gt;
&lt;p&gt;Unfortunately this is the only thing that cannot be asured and the reason why many programmers do not use tags, if consistency is required.&lt;/p&gt;
&lt;p&gt;While the idea of using tags for displayable informations is a good one, you must be aware that each information might be manipulated by the user. Even parts, or the whole tag can be deleted by mistake, so you need a little goodwill. On the other hand, while there are other solutions for storing additional data, it is more difficult to get those data displayed, so if you trust your users that far, tags will be fine.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>Re: Set Tag Values in Selected Element Only</title><link>https://communities.bentley.com/thread/245846?ContentTypeID=1</link><pubDate>Fri, 24 May 2013 12:11:46 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:02c2491d-a043-4c33-850a-fc41b3495877</guid><dc:creator>Jon Summers</dc:creator><description>&lt;p&gt;[quote user=&amp;quot;Rob Golding&amp;quot;] I will try&amp;nbsp;IPrimitiveCommand[/quote]&lt;/p&gt;
&lt;p&gt;There are plenty of examples in VBA help, and here&amp;#39;s a &lt;a title="LA Solutions: VBA create shape example" href="http://www.la-solutions.co.uk/content/MVBA/MVBA-CreateShape.htm"&gt;create shape example&lt;/a&gt;.&amp;nbsp; As Jan wrote, when you place a cell that contains tags, the tags are copied from the cell definition and placed as new elements in the DGN model.&amp;nbsp; You need to edit those new tag elements to assign them the right values.&amp;nbsp; &lt;a title="LA Solutions: VBA ShapeTagger" href="http://www.la-solutions.co.uk/content/MVBA/MVBA-TagBulkAttach.htm"&gt;ShapeTagger &lt;/a&gt;shows how to update tags on an element.&lt;/p&gt;
&lt;p&gt;This &lt;a title="LA Solutions: Tag Data Overview" href="http://www.la-solutions.co.uk/content/MVBA/MVBA-TagDataOverview.htm"&gt;tag data overview&lt;/a&gt; may help.&lt;/p&gt;
&lt;p&gt;[quote user=&amp;quot;Rob Golding&amp;quot;]Hopefully this image is of some help[/quote]&lt;/p&gt;
&lt;p&gt;An illustration is often useful.&amp;nbsp; A DGN model is usually better, because then we can poke around.&amp;nbsp; In this instance, it&amp;#39;s hard to read dark blue text on a black background &amp;mdash; it would be so much easier to read had you used a white background for your DGN model.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>Re: Set Tag Values in Selected Element Only</title><link>https://communities.bentley.com/thread/245839?ContentTypeID=1</link><pubDate>Fri, 24 May 2013 10:50:40 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:c0bf99d0-0751-40cf-baa7-65795aa9ad7e</guid><dc:creator>Jan Šlegr</dc:creator><description>&lt;p&gt;Hi Rob,&lt;/p&gt;
&lt;p&gt;[quote user=&amp;quot;Rob Golding&amp;quot;]&lt;/p&gt;
&lt;p&gt;Hopefully this image is of some help. All cells below are the identical (cell is DM1)... when the Cell was created i attached the tagSet &amp;quot;Deco&amp;quot; which contains 3 tags.&lt;/p&gt;
&lt;p&gt;[/quote]&lt;/p&gt;
&lt;p&gt;Yes, it&amp;#39;s clear now. It means the situation is quite standard and in my opinion it&amp;#39;s the most simple case comparing to other options, because the tags are attached to the cell already.&lt;/p&gt;
&lt;p&gt;[quote user=&amp;quot;Rob Golding&amp;quot;]i will try&amp;nbsp;IPrimitiveCommand.... i have only ever used Primitives once (based on the advice of another user on this forum) but will give it a go![/quote]&lt;/p&gt;
&lt;p&gt;If you did it once, you will do it again, I am sure :-)&lt;/p&gt;
&lt;p&gt;I recommend to check examples in MicroStation VBA help, e.g. &amp;quot;Line Element Creation Command&amp;quot; example is quite close to what you need to do.&lt;/p&gt;
&lt;p&gt;A notice:&lt;/p&gt;
&lt;p&gt;You have to write the cell at first and to change tags value in the second step, not in the inverse order. It&amp;#39;s because tags cannot be attached to element that doesn&amp;#39;t exist in design file already. So if you create cell object using some from&amp;nbsp;CreateCellElement methods, tags in fact doesn&amp;#39;t exist (or are not accessible) despite of they are attached to the cell in the cell library. After ActiveModelReference.AddElement is used, MicroStation does all steps required to attach tags to written cell exactly as it was in the cell library automatically. And it&amp;#39;s the right time to change tags values.&lt;/p&gt;
&lt;p&gt;HTH Jan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>Re: Set Tag Values in Selected Element Only</title><link>https://communities.bentley.com/thread/245838?ContentTypeID=1</link><pubDate>Fri, 24 May 2013 10:32:39 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:11b98de5-ed59-4c29-ad1d-7bd1f3ea7df3</guid><dc:creator>Rob Golding</dc:creator><description>&lt;p&gt;[quote user=&amp;quot;Jan Slegr&amp;quot;]&lt;/p&gt;
&lt;p&gt;What exactly does it mean? Tags are grouped into Tag Sets, which work as templates. Different Tag Sets with the same name cannot exist in the same design file. Of course the same Tag Set can be attached to many elements and Tags can have different values (but because they are created based on the same template, they all have the same structure and behaviour).&lt;/p&gt;
&lt;p&gt;[/quote]&lt;/p&gt;
&lt;p&gt;My bad, worded that wrong. I want to change a Single tagSet... not tag.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Hopefully this image is of some help.&lt;/p&gt;
&lt;p&gt;All cells below are identical (cell is DM1)... when the Cell was created i attached the tagSet &amp;quot;Deco&amp;quot; which contains 3 tags.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://communities.bentley.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Discussions-Components-Files/343173/6835.Poles.JPG" border="0" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;The values in the tags are set based on inputs from VBA (i have that part all working). Once the Value for the tags are set, they should not change until removed from the design.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;BUT... i need to place the exact same cell (DM1) onto the design numerous times after the first one is placed, however the Tag values must be different&lt;/p&gt;
&lt;p&gt;[quote user=&amp;quot;Jan Slegr&amp;quot;]&lt;/p&gt;
&lt;p&gt;That&amp;#39;s because your code looks weird. What I think you should do:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Implement cell placement in &amp;quot;standard VBA way&amp;quot;, which means to implement IPrimitiveCommand class.&lt;/li&gt;
&lt;li&gt;In IPrimitiveCommandEvents_DataPoint event, you will write your cell into design file.&lt;/li&gt;
&lt;li&gt;Next step will differ a bit if the cell has tags attached already (tags were attached when the cell was created in a cell library) or if you have to attach tag set to the cell.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;With regards,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; Jan&lt;/p&gt;
&lt;div&gt;&lt;/div&gt;
&lt;p&gt;[/quote]&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks Jan, i will try&amp;nbsp;IPrimitiveCommand.... i have only ever used Primitives once (based on the advice of another user on this forum) but will give it a go!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>Re: Set Tag Values in Selected Element Only</title><link>https://communities.bentley.com/thread/245832?ContentTypeID=1</link><pubDate>Fri, 24 May 2013 09:57:30 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:37ac43a1-c0e4-4c7d-93df-860bf547114a</guid><dc:creator>Jan Šlegr</dc:creator><description>&lt;p&gt;Hi Rob,&lt;/p&gt;
&lt;p&gt;[quote user=&amp;quot;Rob Golding&amp;quot;]I want to only set a single TagSet, but it has the same name as another set placed on the design already.[/quote]&lt;/p&gt;
&lt;p&gt;What exactly does it mean? Tags are groupped into Tag Sets, which work as templates. Different Tag Sets with the same name cannot exist in the same design file. Of course the same Tag Set can be attached to many elements and Tags can have different values (but because they are created based on the same template, they all have the same structure and behaviour).&lt;/p&gt;
&lt;p&gt;[quote user=&amp;quot;Rob Golding&amp;quot;]The Cell is called &amp;quot;DM1&amp;quot; and contains a TagSet called &amp;quot;Deco&amp;quot;. This cell needs to be placed many times on the same design. I thought about using tags to try to store additional information in each cell that i can then extract with VBA.[/quote]&lt;/p&gt;
&lt;p&gt;It&amp;#39;s for 100% valid request and correct idea, I use this approach in several customers&amp;#39; macros too.&lt;/p&gt;
&lt;p&gt;[quote user=&amp;quot;Rob Golding&amp;quot;]Problem i have is that i can set the tag value once when placing the cell. When i place the next cell the values don&amp;#39;t change (as I&amp;#39;m assuming its &amp;quot;resetting&amp;quot; the first cell&amp;#39;s tags)[/quote]&lt;/p&gt;
&lt;p&gt;That&amp;#39;s because your code looks weird. What I think you should do:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Implement cell placement in &amp;quot;standard VBA way&amp;quot;, which means to implement IPrimitiveCommand class.&lt;/li&gt;
&lt;li&gt;In IPrimitiveCommandEvents_DataPoint event, you will write your cell into design file.&lt;/li&gt;
&lt;li&gt;Next step will differ a bit if the cell has tags attached already (tags were attached when the cell was created in a cell library) or if you have to attach tag set to the cell.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;With regards,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; Jan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>