This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Automatic Drawing Naming Standard

Former Member
Former Member
Hello! I just got m-files up and running, so I'm fairly new the VBscript on it. I'm hoping someone could help me out with my code.

I would like to automatically name all drawings in the class "Drawings" that are inserted based on two properties and an auto number.
Property 1: Drawing type (value list consisting of "ELE", "MEC", "CIV", "STR", etc.)
Property 2: Project (choose from list of existing Projects)
Auto-number: Counter which increments when documents by looking at other drawings of the same project having the same Property 1 & Property 2

For Example
Drawing 1
Drawing Type: ELE
Project: PARKING

=> Output: PARKING-ELE-01

Drawing 2
Drawing Type: ELE
Project: PARKING

=> Output: PARKING-ELE-02

Drawing 3
Drawing Type: MEC
Project: PARKING

=> Output: PARKING-MEC-01

And so on. So since a Document 1 exists with "PARKING" as a project and "ELE" as a drawing type, then Document 2 gets incremented by 1.

Is there anyone who has done something similar? I would really appreciate it if I could get some guidance with coding the Calculated Value (VBscript).

Thanks!

Parents
  • Former Member
    Former Member
    Hello!

    Thank you for helping me with by redirecting me to a similar post. I'm stuck with one more thing, so I'm resorting to your help. I have attached a simple structure to illustrate the hierarchy.

    When creating a new "Drawing" class, I would like the "Drawing Name" to automatically be calculated using VB based on the selection of the "Project" (ID 1016), "Drawing Type" (ID1020), "Drawing Size" (1021) and give an autonumber at the end in case different file with same selection exists.

    I am stuck with looking up the "Project Number" (ID 1017) based on the selection of "Project" (ID 1016).
    So far, I have the following code. I've looked through the forum with no answer. Could you please guide me? I appreciate your help

    Option Explicit

    'Extract current value of the Project property
    Dim cntname
    cntname = PropertyValues.SearchForProperty( 1016 ).TypedValue.DisplayValue

    'MISSING CODE: Want to lookup up automatically assigned "Project Number" (ID 1017), based on "Prject" (ID 1016)
    Dim projnum
    projnum =


    Dim drwtyp, drwsize
    drwtyp = PropertyValues.SearchForProperty( 1020 ).TypedValue.DisplayValue
    drwsize = PropertyValues.SearchForProperty( 1021 ).TypedValue.DisplayValue

    'custom numbering using VaultSharedVariables to store value for each Project
    Dim n, v
    v = VaultSharedVariables(cntname)
    If isNull(v) or isEmpty(v) or v="" Then
    'case when first document of current project was created
    n = 1
    Else
    'increment counter in case when project was just handle
    n = CInt(v)+1
    End If

    'store counter in VaultSharedVaribles
    VaultSharedVariables(cntname) = n

    Output = drwsize & "-" & projnum & "-" & drwtyp & "-" & n


Reply
  • Former Member
    Former Member
    Hello!

    Thank you for helping me with by redirecting me to a similar post. I'm stuck with one more thing, so I'm resorting to your help. I have attached a simple structure to illustrate the hierarchy.

    When creating a new "Drawing" class, I would like the "Drawing Name" to automatically be calculated using VB based on the selection of the "Project" (ID 1016), "Drawing Type" (ID1020), "Drawing Size" (1021) and give an autonumber at the end in case different file with same selection exists.

    I am stuck with looking up the "Project Number" (ID 1017) based on the selection of "Project" (ID 1016).
    So far, I have the following code. I've looked through the forum with no answer. Could you please guide me? I appreciate your help

    Option Explicit

    'Extract current value of the Project property
    Dim cntname
    cntname = PropertyValues.SearchForProperty( 1016 ).TypedValue.DisplayValue

    'MISSING CODE: Want to lookup up automatically assigned "Project Number" (ID 1017), based on "Prject" (ID 1016)
    Dim projnum
    projnum =


    Dim drwtyp, drwsize
    drwtyp = PropertyValues.SearchForProperty( 1020 ).TypedValue.DisplayValue
    drwsize = PropertyValues.SearchForProperty( 1021 ).TypedValue.DisplayValue

    'custom numbering using VaultSharedVariables to store value for each Project
    Dim n, v
    v = VaultSharedVariables(cntname)
    If isNull(v) or isEmpty(v) or v="" Then
    'case when first document of current project was created
    n = 1
    Else
    'increment counter in case when project was just handle
    n = CInt(v)+1
    End If

    'store counter in VaultSharedVaribles
    VaultSharedVariables(cntname) = n

    Output = drwsize & "-" & projnum & "-" & drwtyp & "-" & n


Children
No Data