OPM Formula to catch Name to cell name

Hi Gents

I am looking for a method in OPM, when we placed a support location, is possible to catch the support number of the support location to the cell name? e.g. in element properties, 

Cell Name = Name as shown the illustrated fig below, can you give some tips how can I make it? I know there maybe some function in class editor, it maybe can add some formula/expression.

I want the parameter "Cell Name" got the name as in OPM support location attribute automatically.

 3107.Empty.dgn

Parents
  • Hi You,

    Thank you for raising your query in Bentley Plant Forum. 

    From the image, I understand that you want to update the value of Cell Name with Tag Information, while the cell name will remain constant based on the cell being used.

    Can you please provide us the reason behind this requirement.

    Regards | Swapnil Joshi

  • Hi Sir

    The reason is because I found the model will always show as a name "Cell" in our review model tree, e.g. Navisworks.

    but if I give a name to the cell, the cell name will be shown in the model tree, instead of "Cell".

    But in this case we have define the cell name manually both in OPM TAG and Element properties. that is double work.

    So I wondering if I can add some ECexpression etc within Class Editor, to let the Cell Name = TAG. that will be perfect!

    Do you understand?

    Answer Verified By: You Quanwu 

  • Cell Name is a Microstation property and OPM doesnt have control over it because its not available in OPM Schema. But if you try to rename the CellName from Element Info by Double Clicking the name "SP-3" it takes that name into your Cell Name property. So OPM is not doing a good job of reading the actual cell name and putting it on the Microstation Cell Name property. You can fix this by writing an MDL application which will 1) scan every component in the DGN 2) Read Its Name/TAG property 3) Write it on the Cell Name property. 

    Answer Verified By: Rahul Kumar 

  • Hi Sir

    can you show me some code for this? I just need a short sample and then I can deep in further myself.

    If that possible?

  • You need to do something like below.

    ScanCriteria* pScanCriteria = mdlScanCriteria_create();

    mdlScanCriteria_addSingleElementTypeTest (pScanCriteria, CELL_HEADER_ELM);
    mdlScanCriteria_setReturnType (pScanCriteria, MSSCANCRIT_RETURN_FILEPOS, FALSE, TRUE);
    mdlScanCriteria_setRangeTest (pScanCriteria, NULL); //no range test
    mdlScanCriteria_setModel (pScanCriteria, ACTIVEMODEL);
    /* loop through all Titel cell elements in file */
    do
    {

    //once you get a cell name here..you need to use EC Framework APIs to extract the EC data and get the Name of the element.

    and then use MDL APIs for changing the cell name Property.

    }

    Answer Verified By: You Quanwu 

  • Hello Yuanwu,

    Here is the MVBA code for your reference.

    Sub FillCellNameAsTag()
        Dim Mycell As CellElement
        
        Dim ee As ElementEnumerator
        Dim sc As New ElementScanCriteria
        
        sc.ExcludeAllTypes
        sc.IncludeType msdElementTypeCellHeader
        Set MyEnum = ActiveModelReference.Scan(sc)
        
        Do While MyEnum.MoveNext
            Set Mycell = MyEnum.Current
            Select Case GetCellProperty(Mycell, "SUPPORT_NAME")
                   Case "NotAvailable"
                   Case Else
                        SetCellProperty Mycell, "CellName", GetCellProperty(Mycell, "NAME")
            End Select
        Loop
    End Sub
    
    Function GetCellProperty(CellEle As Element, PropertyNameString As String) As String
        Dim OPH As PropertyHandler
        Set OPH = CreatePropertyHandler(CellEle)
        On Error Resume Next
        GetCellProperty = "NotAvailable"
        OPH.SelectByAccessString (PropertyNameString)
        GetCellProperty = OPH.GetValue
    End Function
    
    Sub SetCellProperty(CellEle As Element, PropertyNameString As String, PropertyValue As String)
        Dim OPH As PropertyHandler
        Set OPH = CreatePropertyHandler(CellEle)
        OPH.SelectByAccessString (PropertyNameString)
        OPH.SetValue PropertyValue
    End Sub
    

Reply
  • Hello Yuanwu,

    Here is the MVBA code for your reference.

    Sub FillCellNameAsTag()
        Dim Mycell As CellElement
        
        Dim ee As ElementEnumerator
        Dim sc As New ElementScanCriteria
        
        sc.ExcludeAllTypes
        sc.IncludeType msdElementTypeCellHeader
        Set MyEnum = ActiveModelReference.Scan(sc)
        
        Do While MyEnum.MoveNext
            Set Mycell = MyEnum.Current
            Select Case GetCellProperty(Mycell, "SUPPORT_NAME")
                   Case "NotAvailable"
                   Case Else
                        SetCellProperty Mycell, "CellName", GetCellProperty(Mycell, "NAME")
            End Select
        Loop
    End Sub
    
    Function GetCellProperty(CellEle As Element, PropertyNameString As String) As String
        Dim OPH As PropertyHandler
        Set OPH = CreatePropertyHandler(CellEle)
        On Error Resume Next
        GetCellProperty = "NotAvailable"
        OPH.SelectByAccessString (PropertyNameString)
        GetCellProperty = OPH.GetValue
    End Function
    
    Sub SetCellProperty(CellEle As Element, PropertyNameString As String, PropertyValue As String)
        Dim OPH As PropertyHandler
        Set OPH = CreatePropertyHandler(CellEle)
        OPH.SelectByAccessString (PropertyNameString)
        OPH.SetValue PropertyValue
    End Sub
    

Children