Quantcast
Channel: MicroStation Programming Forum - Recent Threads
Viewing all articles
Browse latest Browse all 7260

RE: Tags vs Text in Cells

$
0
0

[quote user="Jon Summers"]

Editing a Title Block

Using tags, you search for the tag whose name is revision_no (or whatever you named it).  Then you update the value of that tag to contain the new revision number.  If subsequently you want to update the revision, you do the same search again.  Because the tag's name never changes and is unique you can always find the same tag to update its value.

Using text, you search for what?  There are probably several text elements in your title block, so you have to figure out programmatically how to choose the right one.  Write and test a method to find text element containing revision_no and change the text.  That works the first time, but what happens when you want to revise the drawing?  How can you distinguish between different text elements?

[/quote]

With regular text elements in cells you are correct but I believe Matt was suggesting something like this (theoretical!)

Parent Cell:

  • Contains child cells laid out in the arrangement to suit the titleblock

Child Cells:

  • Model name (Cell name) equivalent to what the text represents and contains 1 text element per cell
  • 1 Child cell per titleblock text item.

In code create 3No. Element Enumerators and 3No. Scan Criteria like so:

Dim oEE1 as ElementEnumerator
Dim oEE2 as ElementEnumerator
Dim oEE3 as ElementEnumerator
Dim oSC1 as ScanCriteria
Dim oSC2 as ScanCriteria
Dim oSC3 as ScanCriteria

Dim oMSApp As MicroStationDGN.Application
Dim oCellParent as CellElement
Dim oCellChild as CellElement
Dim oText as TextElement

Set oMSApp = New MicroStationDGN.Application

Set oSC1 = oMSApp.CreateObjectInMicroStation("MicroStationDGN.ElementScanCriteria")
Set oSC2 = oMSApp.CreateObjectInMicroStation("MicroStationDGN.ElementScanCriteria")
Set oSC3 = oMSApp.CreateObjectInMicroStation("MicroStationDGN.ElementScanCriteria")

oSC1.ExcludeAllTypes
oSC1.ExcludeAllClasses
oSC1.IncludeClass msdElementClassPrimary
oSC1.IncludeType msdElementTypeCellHeader

oSC2.ExcludeAllTypes
oSC2.ExcludeAllClasses
oSC2.IncludeClass msdElementClassPrimary
oSC2.IncludeType msdElementTypeCellHeader

oSC3.ExcludeAllTypes
oSC3.ExcludeAllClasses
oSC3.IncludeClass msdElementClassPrimary
oSC3.IncludeType msdElementTypeText

etc...

  1. Enumerate through all Cell Elements, use oSC1 to check the value of the oEE1.current = name of titleblock cell
  2. If found, Enumerate through child cell elements using oSC2, create a variant array from excel table header names and use a for loop to check the current array item's value against the value oEE2.current .
  3. When 2. finds a match enumerate through any text elements with oSC3 and retrieve the value of any found text elements via oEE3.current.
  4. Change Text value and use ReplaceCurrentElement to update child and parent cells.

That might be a bit pseudo code and admittedly have no evidence to prove it works but it makes sense in head at least. If the theory is sound perhaps there is a more elegant approach to coding it (e.g. can you get away with using only 1 Element Enumerator and use 1 scan criteria for enumerating through parent and child cells?)

I still prefer Tags even though their usability with Excel is a little flaky due to MS.


Viewing all articles
Browse latest Browse all 7260

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>