.NET Framework Class Library
DataEntrHelper Methods

<< Click to Display Table of Contents >>

Navigation:  Programming Mechworks PDM > .NET API > MwPDMApi Namespace > DataEntrHelper Class >

.NET Framework Class Library
DataEntrHelper Methods

The DataEntrHelper type exposes the following members.

Methods

 

Name

Description

Public method

CancelCustomScript

Creates a cancellation file ("DataEntr_Custom.CANCEL") in the system temporary directory to signal that the Save As process should be cancelled. Typically called from custom DataEntr_PreEvent or DataEntr_PostEvent methods.

Public method

ClearTempData

Clears temporary data.

Public method

DefaultOutputValues

Outputs default values to the MWPDM API after script execution. This method performs several actions to prepare and transmit script-generated data:

Validates that both the folder and file name are set; shows an error message if missing.

Writes the file name and folder path using DBWLib.DBWOutput, ensuring the path ends with a backslash.

Outputs part/assembly ID and description, if available.

If the part/assembly was copied, outputs the source UID and corresponding ID.

Outputs category values for all categorizable fields.

Clears unused category fields beyond the maximum allowed, unless called from the Assembly Duplication Wizard ("ADW").

Outputs the current project name, if specified.

Outputs configuration property name when the context is ADD_CONFIGURATION or RENAME_CONFIGURATION.

Public method

Equals

(Inherited from Object.)

Protected method

Finalize

(Overrides Object.Finalize().)

Public method

GetCategoriesfromOldPrtAsm

Retrieves category data from an existing Part or Assembly identified by its UID. Populates the SelectedCategoriesArray with ObjCategory instances found in the linked fields and prepares the ValueFieldsLinkedToCategories for document output.

Public method

GetComputedDocExtension

Returns the current document's file extension, including the leading dot (e.g., ".sldprt").

Public method

GetComputedDocType

Returns the current document type code (e.g., "A" for Assembly, "P" for Part, "D" for Drawing). The value identifies the type of CAD document being processed.

Public method

GetDefaultDescription

Constructs a default description string by concatenating selected category names, excluding the first one in the list.

This logic applies only when the method is not called from the Assembly Duplication Wizard (ADW), and when SelectedCategoriesArray contains more than one item. The resulting description is built by joining the remaining category names using the CM_Separator string.

Public method

GetDefaultDescription_Drawing

Retrieves the default description for a drawing based on the current context.

The description is typically derived from the associated Part or Assembly if available. Specifically:

In contexts SAVE_AS, GET_FILENAME_BEFORE_SAVEAS, or SAVE_AS_LINKED_DRAWING: Retrieves the UID of the linked model and uses its description.

In context RENAME_DRAWING: No description is returned or modified.

In all other cases: Prompts the user to enter a name manually and returns an empty string.

If called from the Assembly Duplication Wizard (ADW), no description is returned.

Public method

GetDefaultFileName

Generates the default file name (including extension but excluding the directory path) based on the provided number and current context.

The method considers various configuration flags and context:

Standard context: If category management is enabled (CM_USE_SUBCODES) and configured to prepend the first category, the category name is prefixed to the file name using CM_Separator. Otherwise, only the number and extension are used.

ADW (Assembly Duplication Wizard): Attempts to replace the original component ID in the file name with the new number. Falls back to appending the new number and extension if no match is found.

Configuration management: If active configurations are used, the method may override the file name with an existing one or retain the current configuration-specific name depending on whether the context is ADD_CONFIGURATION or SAVE_AS.

Public method

GetDefaultFileName_Drawing

Generates the default file name for a drawing based on the provided new number, current context, and optional conditions.

Behavior by context:

ADW (Assembly Duplication Wizard): Constructs the file name using the new number and extension. Optionally, it may derive the name from the main component's file name, including a drawing index if ADWGetFileNameWithoutExt is enabled (currently commented).

SAVE_AS, GET_FILENAME_BEFORE_SAVEAS, SAVE_AS_LINKED_DRAWING: Returns the new number with the standard extension.

RENAME_DRAWING: Returns the new number with the extension. Optionally, the old component name in the current drawing file name may be replaced with the new component name if OnDrawingRenameUseComponentFileName is enabled (currently commented).

No linked document: Prompts the user to manually enter a name and outputs a blank ID.

Public method

GetDefaultFolder


Public method

GetDefaultFolder_Drawing

Determines and returns the default folder path for the drawing based on the execution context.

The returned path always includes a trailing backslash (\). Folder resolution depends on the following contexts:

ADW (Assembly Duplication Wizard): Uses the folder of the new component file.

SAVE_AS / GET_FILENAME_BEFORE_SAVEAS / SAVE_AS_LINKED_DRAWING: Attempts to retrieve the model's folder via UID lookup. If unavailable, falls back to the original script folder.

RENAME_DRAWING: Retrieves the folder from the original part/assembly UID.

Fallback: If no valid document is found, prompts the user to enter a name manually and returns an empty string.

Public method

GetDefaultNumber

Retrieves the full part or assembly number for a new model, based on the execution context and category settings.

If not called from the Assembly Duplication Wizard (ADW), this method launches the Category Wizard and uses the selected categories to compute a default ID via GetDefaultID.

If called from the duplication wizard:

If CheckIfInFiltering is enabled, writes dummy values for the ID and file name and exits.

Otherwise, retrieves the default ID based on the original file and selected category options.

Public method

GetDefaultNumber_Drawing

Generates the default number (ID) for a new or renamed drawing based on the current context and related component data.

The returned number is determined by the execution context, such as:

ADW (Assembly Duplication Wizard): Uses NewComponentID, optionally appending a counter.

SAVE_AS, SAVE_AS_LINKED_DRAWING, GET_FILENAME_BEFORE_SAVEAS: Retrieves the associated component UID, checks existing drawings, and computes the next available drawing ID.

RENAME_DRAWING: Determines the new drawing name by analyzing the original and current IDs and parent relationships.

If no valid drawing context is detected or an error occurs, an empty string is returned.

Public method

GetDefaultProject

Retrieves the default project name for the drawing based on script context.

If the Category Wizard was shown, this returns the project selected by the user (choosed_project). Otherwise, it defaults to the project passed into the script via DBWInput("@CURRENT_PROJECT").

Public method

GetDrawingRev

Retrieves the revision value of the model (Part or Assembly) linked to the current drawing.

Return Value

The revision string of the linked model, or an empty string if not available.

Public method

GetFirstRevision

Retrieves the first available revision value, based on the revisions configurations.

Return Value

The first revision string if found; otherwise, an empty string.

Public method

GetHashCode

(Inherited from Object.)

Public method

GetThisDrawingComponentUid

Retrieves the UID of the Part or Assembly linked to the current drawing, based on the active save context. This method checks if the drawing is being processed in a Save As–related context (e.g., SAVE_AS, GET_FILENAME_BEFORE_SAVEAS, or SAVE_AS_LINKED_DRAWING). It then verifies the saved configuration and attempts to resolve the UID of the associated component.

Public method

GetType

(Inherited from Object.)

Public method

InputAllCategoryValues

Reads category-related values from a temporary file and populates internal data structures such as SelectedCategoriesArray and ValueFieldsLinkedToCategories.

The input file (referenced by tempCategoriesFile) is parsed line-by-line for key-value pairs defining category metadata such as project name, category titles, codes, and descriptions..

The method also sets internal counters like CategoryMakerTreeDepth and _MaxCategorizable, and ensures that the internal category value fields arrays are properly aligned with the number of selected categories.

Return Value

True if valid category data was loaded and processed; False otherwise.

Public method

InputPostEventValues

Parses post-event output values and updates global variables accordingly. This method reads key-value pairs from the temporary DBWorks script output file and assigns values to fields such as NewNumber, NewFileName, NewFolderPath, NewDescription, NewProject, and NewRevision, based on recognized keys in the file. Lines starting with a semicolon (;) are treated as comments and ignored.

Public method

IsValidFileName

Determines whether the specified file name is valid by checking for invalid characters. Returns True if the file name does not contain any of the following characters: \ / : * ? " < > |; otherwise, returns False.

Public method

IsValidFolderName

Validates a folder name to ensure it does not contain invalid characters and that any colon (:) appears only at the second position.

The folder name is considered invalid if it contains any of the following characters: * ? " < > |, or if a colon (:) appears anywhere other than the second character (e.g., C:\ is valid).

Public method

LoadAllInput

Initializes and loads all required input for script execution. This includes: - Localizing table and field names. - Loading general script input values. - Setting global variables and paths. - Reading Category Wizard field links and parameters. - Determining the document extension and type based on postFlag. Returns True if all operations succeed; otherwise, returns False.

Public method

LoadPostEventValues

Loads values from the temporary output file created by the custom post-event script. This method is intended to be called from a custom `DataEntr_PostEvent.LST` or `DataEntr_PostEvent` method after the custom logic has executed. It reads the "DataEntr_PostEvent.IN" file from the system temp path, parses key-value pairs, and sets corresponding properties such as NewNumber, NewFileName, NewFolderPath, etc.

Protected method

MemberwiseClone

(Inherited from Object.)

Public method

RunChecks

Performs validation checks before executing file operations such as Save As or Rename.

Checks performed:

Save As context: If context = "GET_FILENAME_BEFORE_SAVEAS" and a valid part/assembly UID is provided, checks for existing associated drawings. If any are found, displays a warning that CAD Save As will not include drawings.

Rename context: If context = "RENAME", ensures a valid UID is present and that the file is not a drawing. - If UID is missing, shows an error message.
- If file is a drawing, displays a message prohibiting renaming from a drawing.
- If both checks pass, retrieves the active configuration name.

Return Value

True if all checks pass; otherwise, False.

Public method

ToString

(Inherited from Object.)

See Also

DataEntrHelper Class

MwPDMApi Namespace