A protection method for Revit family files
By loading and processing nested families in Revit family files, executing encryption logic to obfuscate and diffuse parameters, hiding graphics elements, and storing data on an intranet server, the encryption and easy failure of Revit family file protection in the existing technology are solved. The problem of high time cost is achieved to achieve effective protection of nested families and data security.
Patent Information
- Application Number
- CN202411096770.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-12
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2044-08-12
AI Technical Summary
Existing Revit family file protection methods have problems such as easy encryption failure, high time cost, and lack of protection for nested families. The existing solution cannot effectively protect parameters in the project environment, and the protection of nested families is insufficient.
Load the family file through the LoadFamily() method to determine whether there is a nested family. If it exists, execute the nested family processing process, including traversing family instances, modifying custom parameters, executing encryption logic, obfuscation of original parameters, diffusion parameters, and obfuscation formulas. Hide the graphics elements, set the encryption flag, and store the mapping data in the intranet server.
It effectively protects Revit family files, reduces time costs, ensures the protection of nested families, improves parameter security, and makes it difficult for illegal users to use parametric families normally.
Smart Images

Figure CN118643520B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of Revit family files, and in particular to a protection method for Revit family files. Background Art
[0002] Revit is a widely used 3D modeling software with good scalability and rich interfaces. The models built using this software are mainly composed of system families and loadable families. System families need to rely on the project environment, while loadable families can exist as independent files and can be applied to different projects, giving full play to the advantages of Revit parametric modeling.
[0003] In order to build a loadable family with complex shapes and its parameterization, modelers need to spend a lot of time and energy. In the process of project file transmission, these unprotected families will also be spread, resulting in damage to the intellectual labor results (families) of the original creators.
[0004] Therefore, it is necessary to take certain protection measures for family files. Thanks to the rich interfaces of Revit software, the use of secondary development to protect family files has attracted more and more attention from relevant researchers.
[0005] The core of Revit family parametricization is parameters. A parameter consists of multiple properties such as name, parameter type, grouping, etc. Parameter types include shared parameters and family parameters. The core idea of the existing technical solution is to modify the parameter type of parameters related to parametric characteristics, and use the invisible and non-editable characteristics of shared parameters to protect parameters. Specifically, by adding shared parameters to replace the original parameters (family parameters), the shared parameters associated with the parametric characteristics are invisible, while the original parameters not associated with the parametric characteristics are visible. As a result, the visible original parameters lose their parametric characteristics.
[0006] At the same time, there are two main technical solutions for applying the above-mentioned protected family files. One is to generate a new name for the original parameter through the base64 algorithm as the parameter name of the shared parameter to achieve the mapping relationship between the original parameter and the new parameter. The other is to store the mapping information between parameters in the DataStorage of the family file.
[0007] However, in the existing solution, the parameter invisible feature is achieved by adding shared parameters, which is only valid in the project environment, but not in the family environment. In the family environment, all parameters can be viewed through the native family type window of the Revit software, including the shared parameters that are invisible in the project environment. At this time, the parameter type of the shared parameter can be changed back to the family parameter to achieve the visibility and editability of the parameter. In addition, if the parameter name is mapped through the base64 algorithm, then the base64 algorithm calculation can be performed again according to the original parameter name to find this correspondence, thereby restoring the original characteristics of the family parameter. Even if the parameter name of the shared parameter uses other encryption algorithms, the corresponding original parameter name is not protected. It is equivalent to the reference answer to the question being published, so it is still easy to identify and restore. Another existing solution is to store the mapping relationship between parameters in DataStorage. There is a chance that the original parameter name can also be protected, thereby effectively avoiding the above problems.
[0008] However, the solution of storing the mapping relationship in DataStorage will cause the problem of time cost. Because in the design process of the project, the parametric family will be repeatedly modified many times. And each time the family parameters are modified, it is necessary to go through the steps of opening the family environment, modifying the family parameters, and loading the project environment. In the above steps, the operation of opening the family environment and loading the project environment, even if it is completed automatically by the program, the time cost is unacceptable. Especially when there are multiple family instances in the project environment, the program will take minutes to run, and the time cost is dozens or hundreds of times that of the native method.
[0009] At the same time, the existing solution does not take into account the protection of nested families, making the elements and parameters of nested families completely transparent to illegal users, and it is difficult to protect nested families. Moreover, it is not feasible to forcibly apply the existing solution directly to nested families, because it may cause errors such as unsatisfied constraints. Therefore, the lack of protection for nested families also limits the application of the existing solution.
[0010] In summary, existing solutions have problems such as easy encryption failure, high time cost, and lack of protection for nested families. Summary of the invention
[0011] In view of this, the present invention provides a protection method for Revit family files.
[0012] The present invention discloses a protection method for Revit family files, which comprises:
[0013] In the Revit project environment, the family file is loaded into the project environment through the LoadFamily() method, and then the family type of the family file is obtained. The LookupParameter() method is used to determine whether the family type has an encryption identification parameter. If it has an encryption identification parameter, it means that the family file has been encrypted, and the user is prompted that it has been encrypted; if it does not have an encryption identification parameter, it means that it is not encrypted, and the EditFamily() method is used to open the current family document document1; use the filter to obtain the family instance in the family document document1, that is, the instance of the nested family; determine whether the number of family instances is greater than 0; if so, it indicates that there is a nested family, and the nested family processing flow is executed; if not, the custom parameters are obtained and the encryption logic is executed.
[0014] Furthermore, the nested family processing flow includes:
[0015] Traverse the family instances in the family document document1; open the family document document2 corresponding to the family instance; determine whether the number of family instances in the family document document2 is greater than 0; if so, recursively call the nested family processing logic; if not, use the FamilyManager property of the family document document1 to obtain the instance of FamilyManager, obtain the parameters of the family document document2 through the attribute Parameters of the instance, and then filter out the custom parameters from the parameters through the enumeration type of BuiltInParameter;
[0016] Modify the value of the custom parameter in the family document document2 to the value of its corresponding family instance in the family document document1; execute the encryption logic; use the LoadFamily() method to reload the family document document2 into the family document document1, and use the Dispose() method to release the resources of the family document document2; return to the family document document1.
[0017] Furthermore, the encryption logic includes:
[0018] Confuse original parameters; diffuse parameters; confuse formulas; confuse parameter order so that valid parameters are randomly distributed among a large number of invalid parameters; hide elements in the family; set encryption identifiers; store data.
[0019] Furthermore, the obfuscated original parameters include:
[0020] According to the number of custom parameters, use GUID to generate the same number of random strings; match the parameter names of the custom parameters with the random strings one by one to form <old name, new name> dictionary data; use the new name, that is, the random string, to rename the corresponding old name, that is, the original parameter name, to achieve the parameter name obfuscation effect.
[0021] Furthermore, the diffusion parameters include:
[0022] For each custom parameter, use GUID to generate multiple random strings, use the random strings as parameter names, and generate parameters of the same type, namely, diffusion parameters;
[0023] The Formula property is used to determine whether a custom parameter contains a formula. If so, the formula of the custom parameter is copied to the parameter generated by diffusion and the next diffusion operation is performed. If not, the value of the custom parameter is obtained. Based on the value of the custom parameter, a random approximate value of the same type and precision is generated and the approximate value is copied to the parameter generated by diffusion.
[0024] Furthermore, the formula is composed of an operator and a parameter name. When the parameter represented by the parameter name is modified, the parameter name in the formula will be modified synchronously.
[0025] Furthermore, the obfuscation formula includes:
[0026] Obtain the formula-type parameter generated by diffusion; obtain the formula in the formula-type parameter generated by diffusion; obtain the parameter represented by the parameter name in the formula; generate a random natural number that is not greater than the number of parameters in the formula; according to the number of random natural numbers, randomly replace the original parameter name in the formula with the parameter name of the same type of parameter; according to the parameter type of the parameter represented by the parameter name in the original formula, determine whether the parameter value is reasonable.
[0027] Furthermore, the determination of whether the parameter value is reasonable includes:
[0028] If the parameter value has the same precision and the same positive and negative sign as the original parameter, it is reasonable and the next step is started; otherwise, a random natural number is regenerated and the parameter name is replaced again according to the number of random natural numbers.
[0029] Furthermore, the setting of the encryption flag includes:
[0030] Create a non-editable encrypted identification parameter to prevent user errors; use GUID to generate a random string; and use the random string as the value of the identification parameter.
[0031] Furthermore, the stored data includes:
[0032] The <old name, new name> dictionary data is stored in the intranet server; and the parameter value of the encryption identifier is stored in the intranet server.
[0033] Due to the adoption of the above technical solution, the present invention has the following advantages:
[0034] 1. The present invention modifies the original name of the parameter into a meaningless random string and adds a new parameter with a similar parameter value and a parameter name as a meaningless random string, making it difficult for illegal users to use the parameterized family normally. For example, one valid parameter is hidden among 1,000 invalid parameters. Thus, the purpose of protecting the family file is achieved. And the time cost problem of the existing solution is taken into consideration.
[0035] 2. The present invention proposes to store the mapping data in an intranet server, so that when using it, there is no need to go through the steps of opening the family environment and loading the project, avoiding frequent opening and loading operations when modifying the family file, reducing time costs, and being more easily accepted by users.
[0036] 3. The present invention fully considers the situation where there are nested families in complex family files and can protect the nested families. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of the present invention. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.
[0038] Figure 1 A flowchart of a method for protecting a Revit family file according to an embodiment of the present invention;
[0039] Figure 2 A schematic diagram of a nested family processing flow in an embodiment of the present invention;
[0040] Figure 3 This is a schematic diagram of encryption logic according to an embodiment of the present invention;
[0041] Figure 4 This is a schematic diagram of the process of obfuscating original parameters according to an embodiment of the present invention;
[0042] Figure 5 A schematic diagram of a diffusion parameter flow chart of an embodiment of the present invention;
[0043] Figure 6 A schematic diagram of a confusion formula flow chart of an embodiment of the present invention;
[0044] Figure 7 A schematic diagram of a process for setting an encryption identifier according to an embodiment of the present invention;
[0045] Figure 8 The figure is a schematic diagram of the data storage process according to an embodiment of the present invention. DETAILED DESCRIPTION
[0046] The present invention is further described in conjunction with the accompanying drawings and embodiments, and the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field should fall within the scope of protection of the embodiments of the present invention.
[0047] See also Figure 1 The present invention provides an embodiment of a protection method for a Revit family file, which comprises:
[0048] In the Revit project environment, the family file is loaded into the project environment through the LoadFamily() method, and then the family type of the family file is obtained. The LookupParameter() method is used to determine whether the family type has an encryption identification parameter. If it has an encryption identification parameter, it means that the family file has been encrypted, and the user is prompted that it has been encrypted; if it does not have an encryption identification parameter, it means that it is not encrypted, and the EditFamily() method is used to open the current family document document1; use the filter to obtain the family instance in the family document document1, that is, the instance of the nested family; determine whether the number of family instances is greater than 0; if so, it indicates that there is a nested family, and the nested family processing flow is executed; if not, the custom parameters are obtained and the encryption logic is executed. LoadFamily(), LookupParameter(), and EditFamily() are all methods provided by RevitAPI, which is the interface provided by Revit software for Revit secondary development.
[0049] In one embodiment, see Figure 2 , nested family processing flow, including:
[0050] Traverse the family instances in the family document document1; open the family document document2 corresponding to the family instance; determine whether the number of family instances in the family document document2 is greater than 0; if so, recursively call the nested family processing logic; if not, use the FamilyManager (a management class used to manage all family type-related editing behaviors) property of the family document document1 to obtain the instance of FamilyManager, obtain the parameters of the family document document2 through the attribute Parameters of the instance, and then filter out the custom parameters from these parameters through the enumeration type of BuiltInParameter (a list of enumeration types that lists all built-in parameter IDs supported by Revit); among them, the family document document1 is the parent family document of the family document document2, and the family document document2 is the child family document of the family document document1;
[0051] Modify the value of the custom parameter in the family document document2 to the value of its corresponding family instance in the family document document1; execute the encryption logic; use the LoadFamily() method to reload the family document document2 into the family document document1, and use the Dispose() method to release the resources of the family document document2; return the family document document1. Dispose() is a method provided by RevitAPI.
[0052] In one embodiment, see Figure 3 , encryption logic, including:
[0053] Confuse original parameters; diffuse parameters; confuse formulas; confuse parameter order so that valid parameters are randomly distributed among a large number of invalid parameters; hide elements in the family; set encryption identifiers; store data.
[0054] In one embodiment, see Figure 4 , obfuscating the original parameters, including:
[0055] According to the number of custom parameters, use GUID (globally unique identifier) to generate the same number of random strings; match the parameter names of the custom parameters with the random strings one by one to form <old name, new name> dictionary data; use the new name, that is, the random string, to rename the corresponding old name, that is, the original parameter name, to achieve the parameter name obfuscation effect.
[0056] In one embodiment, see Figure 5 , diffusion parameters, including:
[0057] For each custom parameter, use GUID to generate multiple random strings, use the random strings as parameter names, and generate parameters of the same type, namely, diffusion parameters;
[0058] The Formula (the formula property of the parameter) property is used to determine whether the custom parameter contains a formula; if so, the formula of the custom parameter is copied to the parameter generated by diffusion and the next diffusion operation is performed; if not, the value of the custom parameter is obtained; based on the value of the custom parameter, a random approximate value of the same type and precision is generated, and the approximate value is copied to the parameter generated by diffusion.
[0059] In one embodiment, a formula is composed of an operator and a parameter name. When the parameter represented by the parameter name is modified, the parameter name in the formula will be modified synchronously.
[0060] In one embodiment, see Figure 6 , obfuscation formulas, including:
[0061] Obtain the formula-type parameter generated by diffusion; obtain the formula in the formula-type parameter generated by diffusion; obtain the parameter represented by the parameter name in the formula; generate a random natural number that is not greater than the number of parameters in the formula; according to the number of random natural numbers, randomly replace the original parameter name in the formula with the parameter name of the same type of parameter; according to the parameter type of the parameter represented by the parameter name in the original formula, determine whether the parameter value is reasonable.
[0062] In one embodiment, judging whether the parameter value is reasonable includes:
[0063] If the parameter value has the same precision and the same positive and negative sign as the original parameter, it is reasonable and the next step is started; otherwise, a random natural number is regenerated and the parameter name is replaced again according to the number of random natural numbers.
[0064] In one embodiment, see Figure 7 , set the encryption flag, including:
[0065] Create a non-editable encrypted identification parameter to prevent user errors; use GUID to generate a random string; and use the random string as the value of the identification parameter.
[0066] In one embodiment, see Figure 8 , store data, including:
[0067] The <old name, new name> dictionary data is stored in the intranet server; and the parameter value of the encryption identifier is stored in the intranet server.
[0068] The present invention conceals valid parameters in a large number of invalid parameters by means of obfuscation and diffusion, thereby protecting the parameters and increasing the difficulty of being cracked.
[0069] The present invention stores the encrypted data in the enterprise intranet server, which can prevent the encrypted data from being leaked along with the family files, thereby effectively improving data security.
[0070] The present invention penetrates into the family file, protects the nested families constituting the family, and processes the values of the nested families before encryption according to the characteristics of the nested families.
[0071] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the relevant field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents. Any modification or equivalent replacement that does not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A protection method for Revit family files, It is characterized in that include: In the Revit project environment, use the LoadFamily() method to load the family file into the project environment, then obtain the family type of the family file, and use the LookupParameter() method to determine whether the family type has an encryption identification parameter. If it has an encryption identification parameter, it means that the family file has been encrypted, and the user is prompted that it has been encrypted; if it does not have an encryption identification parameter, it means that it has not been encrypted, and use the EditFamily() method to open the current family document document1; Use the filter to obtain the family instance in the family document document1, that is, the instance of the nested family; Determine whether the number of family instances is greater than 0; if so, it indicates that there is a nested family, and then execute the nested family processing flow; If not, obtain custom parameters and execute encryption logic; The nested family processing flow includes: Traverse the family instances in the family document document1; Open the family document document2 corresponding to the family instance; determine whether the number of family instances in the family document document2 is greater than 0; if so, recursively call the nested family processing logic; if not, use the FamilyManager property of the family document document1 to obtain the instance of FamilyManager, obtain the parameters of the family document document2 through the attribute Parameters of the instance, and then filter out the custom parameters from the parameters through the enumeration type of BuiltInParameter; Modify the value of the custom parameter in the family document document2 to the value of its corresponding family instance in the family document document1; execute the encryption logic; use the LoadFamily() method to reload the family document document2 into the family document document1, and use the Dispose() method to release the resources of the family document document2; return to the family document document1.
2. The protection method for Revit family files according to claim 1, It is characterized in that The encryption logic includes: Confuse original parameters; diffuse parameters; confuse formulas; confuse parameter order so that valid parameters are randomly distributed among a large number of invalid parameters; hide elements in the family; set encryption identifiers; store data.
3. The protection method for Revit family files according to claim 2, It is characterized in that The obfuscated original parameters include: According to the number of custom parameters, use GUID to generate the same number of random strings; match the parameter names of the custom parameters with the random strings one by one to form <old name, new name> dictionary data; use the new name, that is, the random string, to rename the corresponding old name, that is, the original parameter name, to achieve the parameter name obfuscation effect.
4. The protection method for Revit family files according to claim 2, It is characterized in that The diffusion parameters include: For each custom parameter, use GUID to generate multiple random strings, use the random strings as parameter names, and generate parameters of the same type, namely, diffusion parameters; The Formula property is used to determine whether a custom parameter contains a formula. If so, the formula of the custom parameter is copied to the parameter generated by diffusion and the next diffusion operation is performed. If not, the value of the custom parameter is obtained. Based on the value of the custom parameter, a random approximate value of the same type and precision is generated and the approximate value is copied to the parameter generated by diffusion.
5. The protection method for Revit family files according to claim 4, It is characterized in that The formula is composed of operators and parameter names. When the parameter represented by the parameter name is modified, the parameter name in the formula will be modified synchronously.
6. The protection method for Revit family files according to claim 2, It is characterized in that The obfuscation formula includes: Obtain the formula-type parameter generated by diffusion; obtain the formula in the formula-type parameter generated by diffusion; obtain the parameter represented by the parameter name in the formula; generate a random natural number that is not greater than the number of parameters in the formula; according to the number of random natural numbers, randomly replace the original parameter name in the formula with the parameter name of the same type of parameter; according to the parameter type of the parameter represented by the parameter name in the original formula, determine whether the parameter value is reasonable.
7. The protection method for Revit family files according to claim 6, It is characterized in that The determining whether the parameter value is reasonable includes: If the parameter value has the same precision and the same positive and negative sign as the original parameter, it is reasonable and the next step is started; otherwise, a random natural number is regenerated and the parameter name is replaced again according to the number of random natural numbers.
8. The protection method for Revit family files according to claim 2, It is characterized in that The step of setting the encryption flag includes: Create a non-editable encrypted identification parameter to prevent user errors; use GUID to generate a random string; and use the random string as the value of the identification parameter.
9. The protection method for Revit family files according to claim 2, It is characterized in that The stored data includes: The <old name, new name> dictionary data is stored in the intranet server; and the parameter value of the encryption identifier is stored in the intranet server.
Citation Information
Patent Citations
Processing method for Revit family file
CN113946849A
Encryption method for Revit family file
CN113946866A
File encryption method and device, electronic equipment and computer readable medium
CN114329535A
Revit-based bus coupler electric appliance cabinet modeling method and system
CN115510539A
Cement plant equipment family library creation method based on BIM
CN117251948A
