A method and device for dynamically drawing temporary graphics based on Revit

By capturing mouse and keyboard events, converting screen coordinates into view coordinates, and using Revit graphic rendering pipeline to display temporary elements, the problem that Revit software cannot perform drag and drop preview in real time is solved, improving the ease of user operations and the convenience of modeling and annotation.

CN119478139BActive Publication Date: 2025-08-01AUTOMOTIVE ENGINEERING CORPORATION +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202510052191.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-14
Publication Date
2025-08-01
Estimated Expiration
2045-01-14

AI Technical Summary

Technical Problem

The Revit software lacks a customized secondary development interface and cannot implement dynamic drag and drop preview functions, which limits the ease of user interaction and the convenience of modeling and annotation.

Method used

By capturing mouse and keyboard events, converting screen coordinates into view coordinates, using the Revit graphic rendering pipeline to display temporary primitives, and updating them in real time in the view interface, combining the DirectContext3D API to generate customized temporary preview graphics.

Benefits of technology

The dynamic drag and drop preview function of Revit software is implemented, which improves the ease of user operations and the convenience of modeling and annotation, and avoids response delays caused by frequent transaction submission and view refresh.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119478139B_ABST
    Figure CN119478139B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and device for dynamically drawing temporary graphics based on Revit. The invention includes: step S101, capturing mouse events and keyboard events, where the mouse events include the buttons and movement of the mouse, and the keyboard events include keyboard input; step S102, obtaining the screen coordinates of the mouse according to the mouse event and converting them into view coordinates; step S103, constructing a temporary primitive according to the view coordinates and pushing the temporary primitive to the Revit graphics rendering pipeline to display the temporary primitive; step S104, when the mouse cursor moves, repeating steps S102 - S103 until the program exits or automatically exits when the condition for ending the drawing is met, stopping the capture of mouse events and keyboard events, clearing the temporary graphics, and stopping the drawing of the temporary graphics; step S105, creating components according to the screen coordinates and view coordinates. Through the present invention, the problem that the Revit software in the related art cannot perform real-time drag and preview is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of graphic drawing, and more particularly, to a method and device for dynamically drawing temporary graphics based on Revit. Background Art

[0002] As a BIM software widely used in the engineering construction industry, Autodesk Revit provides many tools for engineering design modeling and also provides a large number of secondary development interfaces for developers to customize functions. However, compared with the breadth and depth of localized secondary development of AutoCAD, there are still some gaps in Revit. For example, in AutoCAD, the Draw Jig dynamic drag-and-drop development interface is often used to allow developers to implement custom dynamic interaction previews, but Revit does not provide a similar development interface. This will limit many user interaction operation functions and usability.

[0003] In the secondary development of AutoCAD, the Jig technology is often used to achieve dynamic interaction in drawing operations. This technology will dynamically display the entities to be placed and also have a real-time dragging effect, what you see is what you get, which is convenient for users to instantaneously preview the effect. For example, when arranging fire sprinklers in a floor plan, before batch placing the sprinkler heads, after clicking the first point, the user can move the mouse in the drawing area. At this time, multiple columns of temporary sprinkler pipeline primitives will be generated in real time dynamically, and the protection radius and sprinkler spacing markings can also be displayed, and the layout positioning of the sprinkler heads will change in real time as the mouse position changes; when the user presses the second point, the program will automatically exit the drag-and-drop preview mode and complete the actual graphic drawing according to the positioning results of the sprinkler pipelines during the preview.

[0004] In the interface of Revit software, there are native dynamic real-time preview functions for drawing walls, pipelines, and placing family components, etc., but no custom secondary development interfaces are opened. For example, if a user wants to implement the above-mentioned batch layout of fire sprinklers, they cannot call the corresponding functions to achieve real-time preview.

[0005] In view of the above problems in the related art, no effective solution has been proposed yet. Summary of the Invention

[0006] The main objective of this application is to provide a method and device for dynamically drawing temporary graphics based on Revit, so as to at least solve the problem that Revit software cannot perform real-time drag-and-drop preview in the related art.

[0007] To achieve the above object, according to one aspect of the present application, a method for dynamically drawing temporary graphics based on Revit is provided. The method includes: Step S101, capturing mouse events and keyboard events, where the mouse events include the buttons and movements of the mouse, and the keyboard events include keyboard inputs; Step S102, obtaining the screen coordinates of the mouse according to the mouse events and converting them into view coordinates; Step S103, constructing temporary primitives according to the view coordinates and pushing the temporary primitives to the Revit graphics rendering pipeline to display the temporary primitives; Step S104, when the mouse cursor moves, repeating Steps S102 - S103 until the program exits or automatically exits when the condition for ending the drawing is met, stopping capturing mouse events and keyboard events, clearing the temporary graphics, and stopping the drawing of the temporary graphics; Step S105, creating components according to the screen coordinates and view coordinates.

[0008] Optionally, the external application responds to mouse events and keyboard events in real time by embedding a mouse - keyboard global HOOK under the Windows message handling mechanism, and pushes the coordinate information of the mouse cursor to the external application in real time.

[0009] Optionally, obtain the screen coordinates of the mouse cursor; obtain the screen range of the interface drawing area and calculate the coordinate points of the four corners of the interface drawing area; calculate the horizontal scaling ratio and vertical scaling ratio between the screen and the view, and the calculation formula is; , , where is the horizontal scaling ratio, is the vertical scaling ratio, is the screen coordinate, is the abscissa of the upper - left corner of the interface drawing area, is the coordinate of the upper - right corner of the interface drawing area, is the ordinate of the lower - right corner of the interface drawing area; obtain the view range of the interface drawing area to get the minimum coordinate point and the maximum coordinate point; obtain the projection plane of the view; obtain the projection points of the view coordinates and calculate the projection coordinate points of the four corners of the interface drawing area; convert the screen coordinates into view coordinates according to the projection coordinates, and the calculation formula is , where is the view coordinate, is the lower - left projection coordinate point, is the upper - left projection coordinate point, is the lower - right projection coordinate point.

[0010] Optionally, if it is a 3D view, determine that the projection plane is the plane passing through the midpoint of the minimum coordinate point and the maximum coordinate point, the projection point is the midpoint of the minimum coordinate point and the maximum coordinate point, and the normal vector of the projection plane is the direction of the current view towards the observer; if it is other views, determine that the projection plane is the sketch plane of the view, the projection point is the origin of the sketch plane, and the normal vector of the projection plane is the direction of the current view towards the observer.

[0011] Optionally, project the minimum coordinate point onto the projection plane to obtain the lower-left projection coordinate point; project the maximum coordinate point onto the projection plane to obtain the upper-right projection coordinate point; project the lower-left projection coordinate point into the projection plane with the upward side of the current view as the normal direction and passing through the upper-right projection coordinate point to obtain the upper-left projection coordinate point; project the upper-right projection coordinate point into the projection plane with the upward side of the current view as the normal direction and passing through the lower-left projection coordinate point to obtain the lower-right projection coordinate point.

[0012] Optionally, when the difference between the abscissa and the ordinate between the initialized screen coordinates and the real-time screen coordinates is not greater than two pixels, render the temporary graphics; when the difference between the abscissa and the ordinate between the initialized screen coordinates and the real-time screen coordinates is greater than two pixels, update the initialized screen coordinates to the real-time screen coordinates.

[0013] According to another aspect of the present application, there is provided an apparatus for dynamically drawing temporary graphics based on Revit. The apparatus includes: a capture unit for performing step S101 to capture mouse events and keyboard events, where the mouse events include the keys and movements of the mouse, and the keyboard events include keyboard inputs; a conversion unit for performing step S102 to obtain the screen coordinates of the mouse according to the mouse events and convert them into view coordinates; a rendering unit for performing step S103 to construct temporary primitives according to the view coordinates, push the temporary primitives to the Revit graphics rendering pipeline, and display the temporary primitives; an end unit for performing step S104, when the mouse cursor moves, repeat steps S102 - S103 until the program exits or automatically exits when the condition for ending the drawing is met, stop capturing mouse events and keyboard events, clear the temporary graphics, and stop drawing the temporary graphics; a creation unit for performing step S105 to create components according to the screen coordinates and the view coordinates.

[0014] To achieve the above object, according to another aspect of the present application, there is provided a computer-readable storage medium, which includes a stored program, where the program executes a method for dynamically drawing temporary graphics based on Revit as described in any one of the above.

[0015] According to another aspect of the present application, an electronic device is provided, including: one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs include a method for dynamically drawing temporary graphics based on Revit for performing any one of the above.

[0016] Through the present application, the following steps are adopted: Step S101, capturing mouse events and keyboard events, where the mouse events include mouse button presses and movements, and the keyboard events include keyboard inputs; Step S102, obtaining the screen coordinates of the mouse according to the mouse event and converting them into view coordinates; Step S103, constructing a temporary primitive according to the view coordinates and pushing the temporary primitive to the Revit graphics rendering pipeline to display the temporary primitive; Step S104, when the mouse cursor moves, repeating Steps S102 - S103 until the program exits or automatically exits when the condition for ending the drawing is met, stopping capturing mouse events and keyboard events, clearing the temporary graphics, and stopping the drawing of the temporary graphics; Step S105, creating components according to the screen coordinates and view coordinates, solving the problem in the related art that the Revit software cannot perform real-time drag and preview, and thus achieving the effects of improving the usability of user operations and the convenience of modeling and annotation operations. Brief Description of the Drawings

[0017] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the drawings required for use in the description of the specific embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.

[0018] Figure 1 is a flowchart of a method for dynamically drawing temporary graphics based on Revit according to an embodiment of the present application;

[0019] Figure 2 is a schematic diagram of the communication between an external application and Revit through a callback function; [[ID=!8]]

[0020] Figure 3 is a flowchart of optimizing graphic submission and view refresh response;

[0021] Figure 4 is a structural block diagram of a device for dynamically drawing temporary graphics based on Revit according to an embodiment of the present application. Detailed Embodiments

[0022] It should be noted that, without conflict, the embodiments in the present application and the features in the embodiments may be combined with each other. The following will describe the present application in detail with reference to the drawings and in combination with the embodiments.

[0023] In order to enable those skilled in the art to better understand the solution of the present application, the following will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without making creative efforts shall fall within the protection scope of the present application.

[0024] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and do not have to be used to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances for the embodiments of the present application described herein. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device comprising a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.

[0025] As introduced in the background art, the prior art provides a native dynamic real-time preview function for drawing walls, pipelines, and placing family components, etc., but does not open a custom secondary development interface. To solve the problem that the Revit software cannot perform real-time drag preview, the embodiments of the present application provide a method and device for dynamically drawing temporary graphics based on Revit.

[0026] The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention.

[0027] In this embodiment, a method for dynamically drawing temporary graphics based on Revit running on a mobile terminal, a computer terminal or a similar computing device is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.

[0028] Figure 1 is a flowchart of a method for dynamically drawing temporary graphics based on Revit according to an embodiment of the present application. As Figure 1 shown, the method includes the following steps:

[0029] Step S101, capture mouse events and keyboard events, where the mouse events include the buttons and movements of the mouse, and the keyboard events include keyboard inputs;

[0030] Specifically, use the Windows API to obtain mouse events and keyboard events in the way of HOOK, and monitor the user's keyboard inputs and the buttons and movements of the mouse.

[0031] Step S102, obtain the screen coordinates of the mouse according to the mouse event, and convert them into view coordinates, denoted as q;

[0032] Specifically, obtain the screen coordinate position of the mouse in the mouse action event processing function, and convert it into the coordinates of the view through a function;

[0033] Step S103, construct a temporary primitive according to the view coordinates, and push the temporary primitive to the Revit graphics rendering pipeline to display the temporary primitive;

[0034] Specifically, obtain the coordinates p[i] of the position where the user clicks in the view (whether it is needed can be determined according to the actual application situation), use the p set and q as the input positioning parameters to construct a temporary primitive, and push the primitive to the Revit graphics rendering pipeline in the specified format and submit it to Revit for display;

[0035] Step S104, when the mouse cursor moves, repeat steps S102 - S103 until the program exits or automatically exits when the condition for ending the drawing is met, stop capturing mouse events and keyboard events, clear the temporary graphics, and stop drawing the temporary graphics;

[0036] Step S105, create components according to the screen coordinates and view coordinates;

[0037] Specifically, create real components according to the p set and q as the input positioning parameters.

[0038] In order to simulate the drag - and - drop preview effect, the following several methods are adopted in the prior art to achieve it:

[0039] 1. Implement it by calling the built - in commands of Revit. The built - in commands of Revit can be called through UIApplication.PostCommand() to simulate dynamic drag - and - drop. For example, the DetailLine command PostableCommand.DetailLine; or use the UIDocument.PromptForFamilyInstancePlacement() method to call to place line - based family components. The disadvantages of these two methods are that only drag - and - drop in the shape of a two - point straight line can be performed or the default appearance of the family instance can be displayed, and the appearance of the preview graphics cannot be deeply customized.

[0040] 2. It is achieved by refreshing the short - term repeated submission of transactions. Drag - temporary graphics are generated according to the real - time positioning of the mouse, and these temporary graphics are continuously deleted and rebuilt in a loop as the mouse positioning changes. The disadvantage of this method is that transactions need to be submitted frequently, the IDs of components will increase sharply in a short time, and frequent access to the project model database and view refreshing will be carried out. In a relatively large project model, the response to user operations is slow.

[0041] 3. It is achieved by laying a transparent form in the drawing area. When starting to draw, a transparent form is first popped up in the drawing area, and then GDI lines are drawn on this form according to the mouse positioning. When the mouse zooms, the line size in the form also needs to be adjusted proportionally. When the user's operation is completed, the transparent form is closed. The disadvantage of this method is that the appearance and response speed of the form line drawing do not match the appearance and response speed of the view change in the drawing area. Especially in a relatively large model, the out - of - sync phenomenon is more obvious.

[0042] The solution of the present invention: The present invention proposes to use the API provided by Revit for displaying external graphics to generate temporary preview graphics. Its basic principle is that in an external application, defined basic primitives (such as points, lines, and triangles) are used as inputs and pushed into the internal graphics rendering pipeline of Revit through the DirectContext3D API for drawing, so as to be displayed in the view interface. It is necessary to implement a DirectContext3DServer server object, respond to callbacks from Revit and execute DirectContext3D API calls to draw temporary graphics. The main callback function used is RenderScene(), and its interaction process with Revit is as Figure 2 shown.

[0043] The advantages of this method are that it allows developers to customize the appearance of preview graphics, can control the refresh frequency of graphics, does not need to frequently submit transactions to add and delete components, and at the same time, since the temporary graphics will uniformly enter the internal graphics rendering pipeline of Revit, it can also maintain dynamic synchronous response with the Revit view drawing and display.

[0044] To more conveniently demonstrate the whole process, the article will take the function of drawing a straight line with two points as an example to elaborate on how to add dynamic preview graphics:

[0045] First, in the external application of Revit, prompt the user to click on the starting point and record the view coordinates of this point. Then create an instance lineJig of the LineJig class and pass the starting point clicked by the user as an input parameter to the DrawingServer property of this instance. Start drawing a temporary graphic through the lineJig.DrawJig() method, display it in the view interface, and notify the user to click on the next point. After the user clicks on the second point in the view, exit the drawing of the temporary graphic through the lineJig.StopJig() method. The code for this process is as follows.

[0046] XYZ p1 = commandData.Application.ActiveUIDocument.Selection.PickPoint(); / / Obtain the view coordinates of the first click by the user;

[0047] XYZ p2 = null;

[0048] LineJig lineJig = null;

[0049] try

[0050] {

[0051] lineJig = new LineJig(commandData.Application) { DrawingServer = { BasePoint = p1}};

[0052] lineJig.DrawJig(); / / Display the temporary graphic

[0053] p2 = uiDocument.Selection.PickPoint("Pick the next point"); / / Obtain the view coordinates of the second click by the user;

[0054] }

[0055] catch (Exception ex)

[0056] {}

[0057] finally

[0058] {

[0059] if (lineJig != null)

[0060] {

[0061] lineJig.StopJig(); / / End the drawing of the temporary graphic

[0062] }

[0063] }

[0064] Among them, the DrawingServer class inherits from the IDirectContext3DServer interface and is set as a property of the LineJig class, capable of receiving the coordinates of the first click input by the user. In the custom DrawJig() method of the LineJig class, a temporary graphic is created using the starting point graphic coordinates and the current real-time position graphic coordinates of the mouse, and is submitted to Revit for display through the RenderScene() method of DrawingServer. As the mouse moves, the old temporary graphic is cleared and the new temporary graphic is rendered in a loop until the user clicks the second point coordinates or presses the ESC key to exit the program, ending the drawing of the temporary graphic.

[0065] The DrawJig() method for drawing the temporary graphic is as follows:

[0066] public override void DrawJig()

[0067] {

[0068] this.DrawingServer.CurveList.Clear(); / / It is necessary to clear the original temporary graphic before each submission;

[0069] if (this.DrawingServer == null ||

[0070] this.DrawingServer.BasePoint == null ||

[0071] this.DrawingServer.NextPoint == null ||

[0072] this.DrawingServer.BasePoint.DistanceTo(this.DrawingServer.NextPoint) <= 0.001)

[0073] {

[0074] return;

[0075] }

[0076] this.DrawingServer.CurveList.Add(Line.CreateBound(this.DrawingServer.BasePoint,this.DrawingServer.NextPoint)); / / CurveList is the Curve collection of the temporary graphics to be submitted, BasePoint is the first coordinate point clicked by the user, and NextPoint is the view coordinate of the mouse cursor obtained and converted in real time;

[0077] }

[0078] In an optional embodiment, the external application responds to mouse events and keyboard events in real time by embedding a global HOOK for mouse and keyboard under the Windows message handling mechanism, and pushes the coordinate information of the mouse cursor to the external application in real time.

[0079] Specifically, to respond to Windows mouse and keyboard events, it is necessary to embed a global HOOK for mouse and keyboard under the Windows message handling mechanism in the external application to respond to mouse and keyboard events in real time (such as the OnMouseActivity event of the mouse and the KeyPress event of the keyboard), and push the coordinate information of the mouse cursor to the external application in real time in the implementation method of subscribing to these events, so as to realize the drawing and display of temporary graphics.

[0080] The global HOOK can monitor the event messages of all threads in the system. Whether it is mouse movement, click or keyboard key press, it can be captured in time. Through the global HOOK, the external application can obtain the accurate coordinate information of the mouse cursor, which is very effective for applications that need to accurately obtain the mouse position. The captured event data and coordinate information can be pushed to the external application in real time for further processing or analysis.

[0081] In an optional embodiment, obtain the screen coordinates of the mouse cursor; obtain the screen range of the interface drawing area, and calculate the coordinate points of the four corners of the interface drawing area; calculate the horizontal scaling ratio and vertical scaling ratio between the screen and the view, and the calculation formula is; , , where is the horizontal scaling ratio, is the vertical scaling ratio, is the screen coordinate, is the abscissa of the upper left corner of the interface drawing area, is the coordinate of the upper right corner of the interface drawing area, is the vertical coordinate at the lower right corner of the interface drawing area; obtain the view range of the interface drawing area to get the minimum coordinate point and the maximum coordinate point; obtain the projection plane of the view; obtain the projection points of the view coordinates and calculate the projection coordinate points of the four corners of the interface drawing area; convert the screen coordinates to view coordinates according to the projection coordinates, and the calculation formula is , where is the view coordinate,[[]] is the lower left projection coordinate point,[[]] is the upper left projection coordinate point,[[]] is the lower right projection coordinate point.[[]]

[0082] Specifically, the implementation method of converting screen coordinates to view coordinates is as follows:

[0083] XYZ GetMousePoint()

[0084] {

[0085] / / Obtain the interface view of the current document

[0086] var uiView = GetActiveUiView(this.HostApplication.ActiveUIDocument);

[0087] Autodesk.Revit.DB.View currentView = this.HostApplication.ActiveUIDocument.ActiveGraphicalView;

[0088] / / Screen coordinates

[0089] var rect = uiView.GetWindowRectangle();

[0090] var dx = (double)(Cursor.Position.X - rect.Left) / (rect.Right -rect.Left);

[0091] var dy = (double)(Cursor.Position.Y - rect.Bottom) / (rect.Top -rect.Bottom);

[0092] / / View coordinates

[0093] var corners = uiView.GetZoomCorners();

[0094] XYZ projectionPoint = this.DrawingServer.BasePoint;

[0095] if (currentView is View3D) / / For 3D views

[0096] {

[0097] projectionPoint = (corners[0] + corners[1]) / 2;

[0098] }

[0099] else if (currentView is ViewSection || currentView is ViewPlanplanView) / / For plan and sectional views

[0100] {

[0101] projectionPoint = currentView.SketchPlane.GetPlane().Origin;

[0102] }

[0103] / / Coordinates of the lower left point

[0104] var p1 = GetProjectPointOnSurface(corners[0], currentView.ViewDirection, projectionPoint);

[0105] / / Coordinates of the upper right point

[0106] var p3 = GetProjectPointOnSurface(corners[1], currentView.ViewDirection, projectionPoint);

[0107] XYZ midPoint = (corners[0] + corners[1]) / 2;

[0108] var plane = Plane.CreateByNormalAndOrigin(currentView.RightDirection, midPoint);

[0109] var mirrorMat = Transform.CreateReflection(plane);

[0110] / / Coordinates of the lower right point

[0111] var p4 = mirrorMat.OfPoint(p1);

[0112] / / Coordinates of the upper left point

[0113] var p2 = mirrorMat.OfPoint(p3);

[0114] / / Move the coordinate point

[0115] var pc = p1 + (p4 - p1) * dx + (p2 - p1) * dy;

[0116] return pc;

[0117] }

[0118] / / / <summary>

[0119] / / / Obtain the currently active interface view

[0120] / / / < / summary>

[0121] / / / <param name="uidoc"> Interface document

[0122] / / / <returns>< / returns>

[0123] UIView GetActiveUiView(UIDocument uidoc)

[0124] {

[0125] var doc = uidoc.Document;

[0126] var view = doc.ActiveView;

[0127] var uiviews = uidoc.GetOpenUIViews();

[0128] UIView uiview = null;

[0129] foreach (var uv in uiviews)

[0130] {

[0131] if (uv.ViewId.Equals(view.Id))

[0132] {

[0133] uiview = uv;

[0134] break;

[0135] }

[0136] }

[0137] return uiview;

[0138] }

[0139] / / / <summary>

[0140] / / / Project a point outside the plane onto the plane to obtain the projection point

[0141] / / / < / summary>

[0142] / / / <param name="normalOfSurface"> Normal vector of the plane

[0143] / / / <param name="pointInSurface"> A point on the plane

[0144] / / / <param name="pointOutOfSurface"> A point outside the plane that needs to be projected

[0145] / / / <returns>< / returns>

[0146] XYZ GetProjectPointOnSurface(XYZ pointOutOfSurface, XYZ normalOfSurface, XYZ pointInSurface)

[0147] {

[0148] XYZ directionOfTwoPoint = (pointInSurface - pointOutOfSurface).Normalize();

[0149] double cosθ = directionOfTwoPoint.DotProduct(normalOfSurface);

[0150] double distanceOfTwoPoint = pointInSurface.DistanceTo(pointOutOfSurface);

[0151] double distanceOfPerpendicular = distanceOfTwoPoint * cosθ; / / Length of the perpendicular foot

[0152] XYZ projectPoint = GetNextPoint(pointOutOfSurface, normalOfSurface, distanceOfPerpendicular);

[0153] return projectPoint;

[0154] }

[0155] / / / <summary>

[0156] / / / Determine the position of a point based on a given point, distance, and direction

[0157] / / / < / summary>

[0158] / / / <param name="datumPoint"> Initial point

[0159] / / / <param name="direction"> Direction

[0160] / / / <param name="distance"> Distance

[0161] / / / <returns>< / returns>

[0162] XYZ GetNextPoint(XYZ datumPoint, XYZ direction, double distance)

[0163] {

[0164] XYZ xDirection = new XYZ(1, 0, 0); [[ID=in]]

[0165] XYZ yDirection = new XYZ(0, 1, 0);

[0166] XYZ zDirection = new XYZ(0, 0, 1);

[0167] direction = direction.Normalize();

[0168] double xIncrement = distance * (xDirection.DotProduct(direction));

[0169] double yIncrement = distance * (yDirection.DotProduct(direction));

[0170] It should be noted that there seems to be an incorrect "in" in the translation for line . It should be " ". This might be a typo in the original text or during the translation process. Please double-check for accuracy.double zIncrement = distance * (zDirection.DotProduct(direction));

[0171] XYZ newPoint = new XYZ(datumPoint.X + xIncrement, datumPoint.Y +yIncrement, datumPoint.Z + zIncrement);

[0172] return newPoint;

[0173] }

[0174] [DllImport("user32.dll")]

[0175] static extern IntPtr GetActiveWindow();

[0176] In an alternative embodiment, if it is a three-dimensional view, the projection plane is determined as the plane where the midpoint of the minimum coordinate point and the maximum coordinate point is located, the projection point is the midpoint of the minimum coordinate point and the maximum coordinate point, and the normal vector of the projection plane is the direction of the current view towards the observer; if it is other views, the projection plane is determined as the sketch plane of the view, the projection point is the origin of the sketch plane, and the normal vector of the projection plane is the direction of the current view towards the observer.

[0177] Specifically, obtain the projection plane, convert the three-dimensional solid figure into a two-dimensional plane figure and project it onto the display, and prepare for obtaining the projection coordinate points in the subsequent process through the projection plane.

[0178] In an alternative embodiment, project the minimum coordinate point onto the projection plane to obtain the lower left projection coordinate point; project the maximum coordinate point onto the projection plane to obtain the upper right projection coordinate point; project the lower left projection coordinate point into the projection plane with the upward side of the current view as the normal direction and passing through the upper right projection coordinate point to obtain the upper left projection coordinate point; project the upper right projection coordinate point into the projection plane with the upward side of the current view as the normal direction and passing through the lower left projection coordinate point to obtain the lower right projection coordinate point.

[0179] In an alternative embodiment, when the differences in the abscissa and ordinate between the initialized screen coordinates and the real-time screen coordinates are not greater than two pixels, render the temporary graphics; when the differences in the abscissa and ordinate between the initialized screen coordinates and the real-time screen coordinates are greater than two pixels, update the initialized screen coordinates to the real-time screen coordinates.

[0180] Specifically, optimize the lag problem when the large model refreshes the view. Due to the high frequency of the OnMouse Activity event of the mouse, each time the event occurs, it will trigger a graphic redraw of the Revit rendering pipeline and refresh the current view. Therefore, when there are many existing real models in the view, it will cause a response delay in view refreshing and a lag phenomenon. To solve this problem, the article records the screen coordinates of the mouse's current action in the event subscription method, and then compares the distance with the coordinates after the mouse moves next time. Only when the distance between these two coordinates is close (both the horizontal and vertical coordinates are within 2 pixels), will it submit the temporary graphics to be rendered through the DrawJig() method. Otherwise, it will only record the latest screen coordinates of the mouse for the next comparison. This avoids the problem of frequently submitting rendering graphics and refreshing the view due to responding to all mouse actions. After the temporary graphics are submitted, the current view needs to be refreshed (ActiveUIDocument.RefreshActiveView()) to view the actual results.

[0181] The purpose of recording the new coordinates is to make a distance judgment when the user's cursor position changes again next time. Only when the distance between the user's mouse cursor positions before and after is not too far, will the view be refreshed. Because the user will always stop the mouse cursor at an appropriate position and fine-tune the coordinate points. As long as the movement slows down, there will be two adjacent mouse coordinate points that are close, which will trigger the view refresh. So there is no need to worry about the user constantly flicking the mouse over a long distance. Because constantly flicking the mouse over a long distance is not a normal and reasonable operation, and this is also what we need to avoid frequent view refreshing during long-distance user operations, resulting in response lags.

[0182] Refer to Figure 3 , Figure 3 Figure

[0183] The following code snippet demonstrates the process of judging whether to refresh based on mouse coordinates in the method for responding to mouse activity events.

[0184] / / This field is used to record the screen coordinates of the mouse

[0185] System.Drawing.Point currentPickedPoint = System.Drawing.Point.Empty;

[0186] / / Subscription method for mouse activity events

[0187] public virtual void OnMouseActivity(object sender, MouseEventArgs e)

[0188] {

[0189] var topWindow = GetActiveWindow();

[0190] if (this.revitWindow != topWindow)

[0191] {

[0192] return;

[0193] }

[0194] try

[0195] {

[0196] var currPoint = GetMousePoint();

[0197] if (this.DrawingServer != null)0]

[0198] {

[0199] if (e.Clicks > 0 && e.Button == MouseButtons.Left)

[0200] {

[0201] this.DrawingServer.BasePoint = null;

[0202] this.DrawingServer.NextPoint = null;

[0203] }

[0204] else

[0205] {

[0206] if (IsVeryClose(e.Location, currentPickedPoint))

[0207] {

[0208] this.DrawingServer.NextPoint = currPoint;

[0209] this.DrawJig();

[0210] HostApplication.ActiveUIDocument.RefreshActiveView();

[0211] }

[0212] else

[0213] {

[0214] currentPickedPoint = e.Location;

[0215] }

[0216] }

[0217] }

[0218] }

[0219] catch (Exception ex)

[0220] {

[0221] throw ex;

[0222] }

[0223] }

[0224] bool IsVeryClose(System.Drawing.Point p1, System.Drawing.Point p2)

[0225] {

[0226] if (Math.Abs(p1.X - p2.X) < 2 && Math.Abs(p1.Y - p2.Y) < 2) / / Return true only when the two coordinate positions are very close

[0227] {

[0228] return true;

[0229] }

[0230] return false;

[0231] }

[0232] The embodiment of the present application also provides a device for dynamically drawing temporary graphics based on Revit. It should be noted that the device for dynamically drawing temporary graphics based on Revit in the embodiment of the present application can be used to execute the method for dynamically drawing temporary graphics based on Revit provided by the embodiment of the present application. The device for implementing the above embodiment and the preferred implementation manner has been described and will not be repeated here. As used below, the term "module" can be a combination of software and / or hardware that can achieve a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware is also possible and contemplated.

[0233] The following introduces a device for dynamically drawing temporary graphics based on Revit provided by the embodiment of the present application.

[0234] Figure 4 is a structural block diagram of a device for dynamically drawing temporary graphics based on Revit according to an embodiment of the present application. As Figure 4 shown, the device includes:

[0235] A capture unit 401, configured to execute step S101 to capture mouse events and keyboard events, where the mouse events include the buttons and movements of the mouse, and the keyboard events include keyboard inputs;

[0236] A conversion unit 402, configured to execute step S102 to obtain the screen coordinates of the mouse according to the mouse event and convert them into view coordinates;

[0237] A rendering unit 403, configured to execute step S103 to construct a temporary primitive according to the view coordinates, push the temporary primitive to the Revit graphics rendering pipeline, and display the temporary primitive;

[0238] An end unit 404, configured to execute step S104. When the mouse cursor moves, repeat steps S102 - S103 until the program exits or automatically exits when the condition for ending the drawing is met, stop capturing mouse events and keyboard events, clear the temporary graphics, and stop drawing the temporary graphics;

[0239] A creation unit 405, configured to execute step S105 to create components according to the screen coordinates and view coordinates.

[0240] In an optional embodiment, the capture unit 401 includes: a response subunit, configured to enable an external application to respond to mouse events and keyboard events in real time through a mouse - keyboard global HOOK embedded in the Windows message processing mechanism, and push the coordinate information of the mouse cursor to the external application in real time.

[0241] In an alternative embodiment, the conversion unit 402 includes: a first acquisition subunit configured to acquire the screen coordinates of the mouse cursor; a first calculation subunit configured to acquire the screen range of the interface drawing area and calculate the coordinate points of the four corners of the interface drawing area; a second calculation subunit configured to calculate the horizontal scaling ratio and the vertical scaling ratio between the screen and the view, and the calculation formula is; , , where is the horizontal scaling ratio, is the vertical scaling ratio, is the screen coordinate, is the abscissa of the upper left corner of the interface drawing area, is the coordinate of the upper right corner of the interface drawing area, is the ordinate of the lower right corner of the interface drawing area; a second acquisition subunit configured to acquire the view range of the interface drawing area to obtain the minimum coordinate point and the maximum coordinate point; a third acquisition subunit configured to acquire the projection plane of the view; a third calculation subunit configured to acquire the projection point of the view coordinate and calculate the projection coordinate points of the four corners of the interface drawing area; a fourth calculation subunit configured to convert the screen coordinate into a view coordinate according to the projection coordinate, and the calculation formula is , where is the view coordinate, is the lower left projection coordinate point, is the upper left projection coordinate point, is the lower right projection coordinate point.

[0242] In an alternative embodiment, the third acquisition subunit includes: a first determination module configured to, if it is a three-dimensional view, determine that the projection plane is the plane where the midpoint of the minimum coordinate point and the maximum coordinate point is located as the projection plane, the projection point is the midpoint of the minimum coordinate point and the maximum coordinate point, and the normal vector of the projection plane is the direction of the current view towards the observer; a second determination module configured to, if it is other views, determine that the projection plane is the sketch plane of the view, the projection point is the origin of the sketch plane, and the normal vector of the projection plane is the direction of the current view towards the observer.

[0243] In an alternative embodiment, the third calculation subunit includes: a first projection module configured to project the minimum coordinate point onto the projection plane to obtain the lower left projection coordinate point; a second projection module configured to project the maximum coordinate point onto the projection plane to obtain the upper right projection coordinate point; a third projection module configured to project the lower left projection coordinate point into the projection plane with the upward side of the current view as the normal direction and passing through the upper right projection coordinate point to obtain the upper left projection coordinate point; a fourth projection module configured to project the upper right projection coordinate point into the projection plane with the upward side of the current view as the normal direction and passing through the lower left projection coordinate point to obtain the lower right projection coordinate point.

[0244] In an alternative embodiment, the rendering unit 303 includes: a first rendering subunit, configured to render a temporary graphic when the difference between the abscissa and the ordinate between the initialized screen coordinates and the real-time screen coordinates is no greater than two pixels; and a second rendering subunit, configured to update the initialized screen coordinates to the real-time screen coordinates when the difference between the abscissa and the ordinate between the initialized screen coordinates and the real-time screen coordinates is greater than two pixels.

[0245] The apparatus for dynamically drawing a temporary graphic based on Revit includes a processor and a memory. The above-mentioned capture unit 401 and the like are all stored in the memory as program units, and the corresponding functions are implemented by the processor executing the above program units stored in the memory. The above modules are all located in the same processor; or, the above modules are respectively located in different processors in any combination form.

[0246] The processor contains a kernel, and the kernel retrieves the corresponding program units from the memory. One or more kernels can be set, and by adjusting the kernel parameters, the technical problem that the Revit software cannot perform real-time drag preview can be solved.

[0247] The memory may include non-permanent memory in a computer-readable medium, in the form of random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. The memory includes at least one storage chip.

[0248] An embodiment of the present invention provides a computer-readable storage medium, which includes a stored program. When the program runs, it controls the device where the computer-readable storage medium is located to execute the method for dynamically drawing a temporary graphic based on Revit.

[0249] Specifically, a method for dynamically drawing a temporary graphic based on Revit includes:

[0250] Step S101, capturing a mouse event and a keyboard event, where the mouse event includes the buttons and movement of the mouse, and the keyboard event includes keyboard input; Step S102, obtaining the screen coordinates of the mouse according to the mouse event and converting them into view coordinates; Step S103, constructing a temporary primitive according to the view coordinates, pushing the temporary primitive to the Revit graphic rendering pipeline, and displaying the temporary primitive; Step S104, when the mouse cursor moves, repeating Steps S102 - S103 until the program exits or automatically exits when the condition for ending the drawing is met, stopping capturing the mouse event and the keyboard event, clearing the temporary graphic, and stopping the drawing of the temporary graphic; Step S105, creating a component according to the screen coordinates and the view coordinates.

[0251] Optionally, the external application uses a global HOOK for the mouse and keyboard embedded in the Windows message handling mechanism to respond to mouse events and keyboard events in real time, and pushes the coordinate information of the mouse cursor to the external application in real time.

[0252] Optionally, obtain the screen coordinates of the mouse cursor; obtain the screen range of the interface drawing area and calculate the coordinate points of the four corners of the interface drawing area; calculate the horizontal and vertical scaling ratios between the screen and the view, and the calculation formula is; , , where is the horizontal scaling ratio, is the vertical scaling ratio, is the screen coordinate, is the abscissa of the upper left corner of the interface drawing area, is the coordinate of the upper right corner of the interface drawing area, is the ordinate of the lower right corner of the interface drawing area; obtain the view range of the interface drawing area to get the minimum coordinate point and the maximum coordinate point; obtain the projection plane of the view; obtain the projection point of the view coordinates and calculate the projection coordinate points of the four corners of the interface drawing area; convert the screen coordinates to view coordinates according to the projection coordinates, and the calculation formula is , where is the view coordinate, is the lower left projection coordinate point, is the upper left projection coordinate point, is the lower right projection coordinate point.

[0253] Optionally, if it is a 3D view, determine that the projection plane is the plane where the midpoint of the minimum coordinate point and the maximum coordinate point is located, the projection point is the midpoint of the minimum coordinate point and the maximum coordinate point, and the normal vector of the projection plane is the direction of the current view towards the observer; if it is other views, determine that the projection plane is the sketch plane of the view, the projection point is the origin of the sketch plane, and the normal vector of the projection plane is the direction of the current view towards the observer.

[0254] Optionally, project the minimum coordinate point onto the projection plane to obtain the lower left projection coordinate point; project the maximum coordinate point onto the projection plane to obtain the upper right projection coordinate point; project the lower left projection coordinate point into the projection plane with the upward side of the current view as the normal direction and passing through the upper right projection coordinate point to obtain the upper left projection coordinate point; project the upper right projection coordinate point into the projection plane with the upward side of the current view as the normal direction and passing through the lower left projection coordinate point to obtain the lower right projection coordinate point.

[0255] Optionally, when the difference between the abscissa and the ordinate between the initialized screen coordinates and the real-time screen coordinates is not greater than two pixels, render the temporary graphics; when the difference between the abscissa and the ordinate between the initialized screen coordinates and the real-time screen coordinates is greater than two pixels, update the initialized screen coordinates to the real-time screen coordinates.

[0256] An embodiment of the present invention provides a processor for running a program, wherein when the program runs, it executes the method for dynamically drawing temporary graphics based on Revit.

[0257] Specifically, a method for dynamically drawing temporary graphics based on Revit includes:

[0258] Step S101, capture the mouse event and the keyboard event, where the mouse event includes the mouse button and movement, and the keyboard event includes the keyboard input; Step S102, obtain the screen coordinates of the mouse according to the mouse event and convert them into view coordinates; Step S103, construct a temporary primitive according to the view coordinates and push the temporary primitive to the Revit graphics rendering pipeline to display the temporary primitive; Step S104, when the mouse cursor moves, repeat steps S102 - S103 until the program exits or automatically exits when the condition for ending the drawing is met, stop capturing the mouse event and the keyboard event, clear the temporary graphics, and stop drawing the temporary graphics; Step S105, create a component according to the screen coordinates and the view coordinates.

[0259] Optionally, the external application responds to the mouse event and the keyboard event in real time by embedding the mouse and keyboard global HOOK under the Windows message processing mechanism, and pushes the coordinate information of the mouse cursor to the external application in real time.

[0260] Optionally, obtain the screen coordinates of the mouse cursor; obtain the screen range of the interface drawing area and calculate the coordinate points of the four corners of the interface drawing area; calculate the horizontal scaling ratio and the vertical scaling ratio between the screen and the view, and the calculation formula is; , , where, is the horizontal scaling ratio, is the vertical scaling ratio, is the screen coordinate, is the abscissa of the upper left corner of the interface drawing area, is the coordinate of the upper right corner of the interface drawing area, is the ordinate of the lower right corner of the interface drawing area; obtain the view range of the interface drawing area to obtain the minimum coordinate point and the maximum coordinate point; obtain the projection plane of the view; obtain the projection points of the view coordinates and calculate the projection coordinate points of the four corners of the interface drawing area; convert the screen coordinates into view coordinates according to the projection coordinates, and the calculation formula is , where, is the view coordinate, is the lower left projection coordinate point, is the upper left projection coordinate point, is the lower right projection coordinate point.

[0261] Optionally, if it is a 3D view, determine that the projection plane is the plane where the midpoint of the minimum coordinate point and the maximum coordinate point is located, the projection point is the midpoint of the minimum coordinate point and the maximum coordinate point, and the normal vector of the projection plane is the direction of the current view towards the observer; if it is other views, determine that the projection plane is the sketch plane of the view, the projection point is the origin of the sketch plane, and the normal vector of the projection plane is the direction of the current view towards the observer.

[0262] Optionally, project the minimum coordinate point onto the projection plane to obtain the lower left projection coordinate point; project the maximum coordinate point onto the projection plane to obtain the upper right projection coordinate point; project the lower left projection coordinate point into the projection plane with the upward side of the current view as the normal direction and passing through the upper right projection coordinate point to obtain the upper left projection coordinate point; project the upper right projection coordinate point into the projection plane with the upward side of the current view as the normal direction and passing through the lower left projection coordinate point to obtain the lower right projection coordinate point.

[0263] Optionally, when the difference between the abscissa and the ordinate between the initialized screen coordinates and the real-time screen coordinates is not greater than two pixels, render the temporary graphics; when the difference between the abscissa and the ordinate between the initialized screen coordinates and the real-time screen coordinates is greater than two pixels, update the initialized screen coordinates to the real-time screen coordinates.

[0264] An embodiment of the present invention provides a device, which includes a processor, a memory, and a program stored on the memory and executable on the processor. When the processor executes the program, it implements at least the following steps: Step S101, capture mouse events and keyboard events, where the mouse events include the keys and movements of the mouse, and the keyboard events include keyboard inputs; Step S102, obtain the screen coordinates of the mouse according to the mouse events and convert them into view coordinates; Step S103, construct temporary primitives according to the view coordinates, push the temporary primitives to the Revit graphics rendering pipeline, and display the temporary primitives; Step S104, when the mouse cursor moves, repeat Steps S102 - S103 until the program exits or automatically exits when the condition for ending the drawing is met, stop capturing mouse events and keyboard events, clear the temporary graphics, and stop drawing the temporary graphics; Step S105, create components according to the screen coordinates and view coordinates. The device herein can be a server, a PC, a PAD, a mobile phone, etc.

[0265] Optionally, the external application responds to mouse events and keyboard events in real time by embedding a global HOOK for the mouse and keyboard under the Windows message processing mechanism, and pushes the coordinate information of the mouse cursor to the external application in real time.

[0266] Optionally, obtain the screen coordinates of the mouse cursor; obtain the screen range of the interface drawing area, and calculate the coordinate points of the four corners of the interface drawing area; calculate the horizontal scaling ratio and the vertical scaling ratio between the screen and the view, and the calculation formula is; , , where, is the horizontal scaling ratio, is the vertical scaling ratio, is the screen coordinate, is the abscissa of the upper left corner of the interface drawing area, is the coordinate of the upper right corner of the interface drawing area, is the ordinate of the lower right corner of the interface drawing area; obtain the view range of the interface drawing area to get the minimum coordinate point and the maximum coordinate point; obtain the projection plane of the view; obtain the projection point of the view coordinate, and calculate the projection coordinate points of the four corners of the interface drawing area; convert the screen coordinate to the view coordinate according to the projection coordinate, and the calculation formula is , where, is the view coordinate, is the lower left projection coordinate point, is the upper left projection coordinate point, is the lower right projection coordinate point.

[0267] Optionally, if it is a three-dimensional view, determine that the projection plane is the plane where the midpoint of the minimum coordinate point and the maximum coordinate point is located as the projection plane, the projection point is the midpoint of the minimum coordinate point and the maximum coordinate point, and the normal vector of the projection plane is the direction of the current view towards the observer; if it is other views, determine that the projection plane is the sketch plane of the view, the projection point is the origin of the sketch plane, and the normal vector of the projection plane is the direction of the current view towards the observer.

[0268] Optionally, project the minimum coordinate point onto the projection plane to obtain the lower left projection coordinate point; project the maximum coordinate point onto the projection plane to obtain the upper right projection coordinate point; project the lower left projection coordinate point into the projection plane with the upward side of the current view as the normal direction and passing through the upper right projection coordinate point to obtain the upper left projection coordinate point; project the upper right projection coordinate point into the projection plane with the upward side of the current view as the normal direction and passing through the lower left projection coordinate point to obtain the lower right projection coordinate point.

[0269] Optionally, when the differences in the abscissa and ordinate between the initialized screen coordinates and the real-time screen coordinates are not greater than two pixels, render the temporary graphics; when the differences in the abscissa and ordinate between the initialized screen coordinates and the real-time screen coordinates are greater than two pixels, update the initialized screen coordinates to the real-time screen coordinates.

[0270] The present application also provides a computer program product, which, when executed on a data processing device, is adapted to execute a program initialized with at least the following method steps: Step S101, capture mouse events and keyboard events, where the mouse events include the buttons and movements of the mouse, and the keyboard events include keyboard inputs; Step S102, obtain the screen coordinates of the mouse according to the mouse events and convert them into view coordinates; Step S103, construct temporary primitives according to the view coordinates, push the temporary primitives to the Revit graphics rendering pipeline, and display the temporary primitives; Step S104, when the mouse cursor moves, repeat Steps S102 - S103 until the program exits or automatically exits when the condition for ending the drawing is met, stop capturing mouse events and keyboard events, clear the temporary graphics, and stop drawing the temporary graphics; Step S105, create components according to the screen coordinates and view coordinates.

[0271] Optionally, the external application responds to mouse events and keyboard events in real time by embedding a mouse and keyboard global HOOK under the Windows message processing mechanism, and pushes the coordinate information of the mouse cursor to the external application in real time.

[0272] Optionally, obtain the screen coordinates of the mouse cursor; obtain the screen range of the interface drawing area and calculate the coordinate points of the four corners of the interface drawing area; calculate the horizontal scaling ratio and vertical scaling ratio between the screen and the view, and the calculation formula is; , ,where is the horizontal scaling ratio, is the vertical scaling ratio, is the screen coordinate, is the abscissa of the upper left corner of the interface drawing area, is the coordinate of the upper right corner of the interface drawing area, is the ordinate of the lower right corner of the interface drawing area; obtain the view range of the interface drawing area to obtain the minimum coordinate point and the maximum coordinate point; obtain the projection plane of the view; obtain the projection points of the view coordinates and calculate the projection coordinate points of the four corners of the interface drawing area; convert the screen coordinates into view coordinates according to the projection coordinates, and the calculation formula is ,where is the view coordinate, is the lower left projection coordinate point, is the upper left projection coordinate point, is the lower right projection coordinate point.

[0273] Optionally, if it is a three-dimensional view, determine that the projection plane is the plane passing through the midpoint of the minimum coordinate point and the maximum coordinate point, the projection point is the midpoint of the minimum coordinate point and the maximum coordinate point, and the normal vector of the projection plane is the direction of the current view towards the observer; if it is other views, determine that the projection plane is the sketch plane of the view, the projection point is the origin of the sketch plane, and the normal vector of the projection plane is the direction of the current view towards the observer.

[0274] Optionally, project the minimum coordinate point onto the projection plane to obtain the lower-left projection coordinate point; project the maximum coordinate point onto the projection plane to obtain the upper-right projection coordinate point; project the lower-left projection coordinate point into the projection plane with the upward side of the current view as the normal direction and passing through the upper-right projection coordinate point to obtain the upper-left projection coordinate point; project the upper-right projection coordinate point into the projection plane with the upward side of the current view as the normal direction and passing through the lower-left projection coordinate point to obtain the lower-right projection coordinate point.

[0275] Optionally, when the difference between the abscissa and the ordinate between the initialized screen coordinates and the real-time screen coordinates is not greater than two pixels, render the temporary graphics; when the difference between the abscissa and the ordinate between the initialized screen coordinates and the real-time screen coordinates is greater than two pixels, update the initialized screen coordinates to the real-time screen coordinates.

[0276] Obviously, those skilled in the art should understand that the above-mentioned modules or steps of the present invention can be implemented by a general-purpose computing device. They can be concentrated on a single computing device or distributed on a network composed of multiple computing devices. They can be implemented by program codes executable by the computing device. Thus, they can be stored in a storage device and executed by the computing device. And in some cases, the steps shown or described can be executed in a different order than here, or they can be separately fabricated into individual integrated circuit modules, or multiple modules or steps among them can be fabricated into a single integrated circuit module to implement. In this way, the present invention is not limited to any specific combination of hardware and software.

[0277] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0278] This application is described with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to embodiments of the present application. It should be understood that each flow and / or block in the flowchart and / or block diagram, and the combination of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing device generate a means for implementing the functions specified in one process Figure 1 one process or multiple processes and / or blocks Figure 1 or a means for implementing the functions specified in multiple blocks.

[0279] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory generate a manufactured article including an instruction means, and the instruction means implements the functions specified in one process Figure 1 one process or multiple processes and / or blocks Figure 1 or a means for implementing the functions specified in multiple blocks.

[0280] These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one process Figure 1 one process or multiple processes and / or blocks Figure 1 or a means for implementing the functions specified in multiple blocks.

[0281] In a typical configuration, a computing device includes one or more processors (CPUs), an input / output interface, a network interface, and a memory.

[0282] The memory may include non-permanent memory in the form of computer-readable media, random access memory (RAM), and / or non-volatile memory such as read-only memory (ROM) or flash memory (flash RAM). The memory is an example of computer-readable media.

[0283] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can be implemented using any method or technology to store information. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change RAM (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media such as modulated data signals and carrier waves.

[0284] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.

[0285] The above description is merely a preferred embodiment of the present application and is not intended to limit the present application. Various modifications and variations are possible for those skilled in the art. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present application shall be included within the scope of protection of the present application.

Claims

1. A method for dynamically drawing temporary graphics based on Revit, characterized in that, Including: Step S101, capturing mouse events and keyboard events, where the mouse events include the buttons and movements of the mouse, and the keyboard events include keyboard inputs; Step S101, capturing mouse events and keyboard events, including: the external application responds to the mouse events and the keyboard events in real time through a mouse and keyboard global HOOK embedded under the Windows message processing mechanism, and pushes the coordinate information of the mouse cursor to the external application in real time; Step S102, obtaining the screen coordinates of the mouse according to the mouse event and converting them into view coordinates; Step S103, constructing a temporary primitive according to the view coordinates, pushing the temporary primitive to the Revit graphics rendering pipeline, and displaying the temporary primitive; Step S104, when the mouse cursor moves, repeat steps S102 - S103 until the program exits or automatically exits when the condition for ending the drawing is met, stop capturing mouse events and keyboard events, clear the temporary graphics, and stop drawing the temporary graphics; Step S105, creating components according to the screen coordinates and the view coordinates.

2. The method according to claim 1, wherein Step S102, obtaining the screen coordinates of the mouse according to the mouse event and converting them into view coordinates, including: Obtaining the screen coordinates of the mouse cursor; Obtaining the screen range of the interface drawing area and calculating the coordinate points of the four corners of the interface drawing area; Calculate the horizontal scaling ratio and the vertical scaling ratio between the calculation screen and the view. The calculation formula is: dx = (x Qc - x Q2 ) / (x Q3 - x Q2 ), dy = (y Qc - y Q4 ) / (y Q3 - y Q4 ). Among them, dx is the horizontal scaling ratio, dy is the vertical scaling ratio, (x Qc , y Qc ) is the screen coordinate, x Q2 is the abscissa of the upper left corner of the interface drawing area, (x Q3 , y Q3 ) is the coordinate of the upper right corner of the interface drawing area, and y Q4 is the ordinate of the lower right corner of the interface drawing area; Obtaining the view range of the interface drawing area to obtain the minimum coordinate point and the maximum coordinate point; Obtaining the projection plane of the view; Obtaining the projection points of the view coordinates and calculating the projection coordinate points of the four corners of the interface drawing area; Converting the screen coordinates into view coordinates according to the projection coordinates, and the calculation formula is Pc = P1+(P4 - P1)*dx+(P2 - P1)*dy, where Pc is the view coordinate, P1 is the lower left projection coordinate point, P2 is the upper left projection coordinate point, and P4 is the lower right projection coordinate point.

3. The method according to claim 2, characterized in that, Obtaining the projection plane of the view, including: If it is a 3D view, determining that the projection plane is the plane where the midpoint of the minimum coordinate point and the maximum coordinate point is located as the projection plane, the projection point is the midpoint of the minimum coordinate point and the maximum coordinate point, and the normal vector of the projection plane is the direction of the current view towards the observer; If it is other views, determining that the projection plane is the sketch plane of the view, the projection point is the origin of the sketch plane, and the normal vector of the projection plane is the direction of the current view towards the observer.

4. The method according to claim 2, wherein Obtaining the projection points of the view coordinates and calculating the projection coordinate points of the four corners of the interface drawing area, including: Projecting the minimum coordinate point onto the projection plane to obtain the lower left projection coordinate point; Projecting the maximum coordinate point onto the projection plane to obtain the upper right projection coordinate point; Projecting the lower left projection coordinate point into the projection plane with the upward side of the current view as the normal direction and passing through the upper right projection coordinate point to obtain the upper left projection coordinate point; Projecting the upper right projection coordinate point into the projection plane with the upward side of the current view as the normal direction and passing through the lower left projection coordinate point to obtain the lower right projection coordinate point.

5. The method according to claim 1, wherein Before constructing a temporary primitive according to the view coordinates, pushing the temporary primitive to the Revit graphics rendering pipeline, and displaying the temporary primitive, including: When the differences in the abscissa and ordinate between the initialized screen coordinates and the real-time screen coordinates are no greater than two pixels, render the temporary graphics; When the differences in the abscissa and ordinate between the initialized screen coordinates and the real-time screen coordinates are greater than two pixels, update the initialized screen coordinates to the real-time screen coordinates.

6. A device for dynamically drawing temporary graphics based on Revit, characterized in that, Including: A capture unit, configured to execute step S101 to capture mouse events and keyboard events, where the mouse events include the buttons and movements of the mouse, and the keyboard events include keyboard inputs; The capture unit 401 includes: a response subunit, configured to enable an external application to respond to the mouse events and the keyboard events in real time through a mouse and keyboard global HOOK embedded in the Windows message processing mechanism, and push the coordinate information of the mouse cursor to the external application in real time; A conversion unit, configured to execute step S102 to obtain the screen coordinates of the mouse according to the mouse events and convert them into view coordinates; A rendering unit, configured to execute step S103 to construct temporary primitives according to the view coordinates, push the temporary primitives to the Revit graphics rendering pipeline, and display the temporary primitives; An end unit, configured to execute step S104. When the mouse cursor moves, repeat steps S102 - S103 until the program exits or automatically exits when the condition for ending the drawing is met, stop capturing mouse events and keyboard events, clear the temporary graphics, and stop drawing the temporary graphics; A creation unit, configured to execute step S105 to create components according to the screen coordinates and the view coordinates.

7. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, where when the program runs, it controls the device where the computer-readable storage medium is located to execute a method for dynamically drawing temporary graphics based on Revit according to any one of claims 1 to 5.

8. An electronic device, characterized in that, Including: One or more processors, a memory, and one or more programs, where the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs include a method for dynamically drawing temporary graphics based on Revit according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Flow chart drawing method, device and equipment based on HTML5 (Hypertext Markup Language 5) and storage medium

    CN115904152A