Method and device for dynamically drawing temporary graph based on Revit

By capturing and handling mouse and keyboard events, building and pushing temporary elements to the Revit rendering pipeline, the problem that Revit software cannot preview in real time is solved, and the ease of use of user operations is improved.

CN119478139AActive Publication Date: 2025-02-18AUTOMOTIVE ENGINEERING CORPORATION +1
View PDF 7 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

The Revit software cannot perform real-time drag and drop preview, which limits user interaction functions and ease of use.

Method used

通过捕获鼠标事件和键盘事件,获取屏幕坐标并转换为视图坐标,构建临时图元并推送到Revit图形渲染管道,实现动态绘制临时图形。

Benefits of technology

It solves the problem that Revit software cannot drag and drop preview in real time, improving the ease of user operations and the convenience of modeling and annotation operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119478139A_ABST
    Figure CN119478139A_ABST
Patent Text Reader

Abstract

The invention discloses a method and a device for dynamically drawing a temporary graph based on Revit. The method comprises the steps that S101, a mouse event and a keyboard event are captured, the mouse event comprises keys and movement of a mouse, and the keyboard event comprises keyboard input; s102, acquiring a screen coordinate of a mouse according to the mouse event, and converting the screen coordinate into a view coordinate; step S103, constructing a temporary primitive according to the view coordinate, pushing the temporary primitive to a Revit graphic rendering pipeline, and displaying the temporary primitive; step S104, when the mouse cursor moves, repeating the steps S102 to S103 until the program is quitted or a drawing ending condition is met, automatically quitting, stopping capturing the mouse event and the keyboard event, emptying the temporary graph, and stopping drawing the temporary graph; and S105, creating a component according to the screen coordinate and the view coordinate. According to the method and the device, the problem that the Revit software cannot be dragged and previewed in real time in related technologies is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of graphics drawing technology, and in particular to a method and device for dynamically drawing temporary graphics based on Revit. Background Art

[0002] As BIM software widely used in the engineering and construction industry, Autodesk Revit provides numerous tools for engineering design and modeling, as well as numerous custom development interfaces for developers to customize functionality. However, compared to the breadth and depth of AutoCAD's localized custom development, Revit still lags behind. For example, the Draw Jig dynamic drag-and-drop interface, commonly used in AutoCAD, allows developers to implement customized dynamic interactive previews, but Revit lacks a similar interface. This limits user interaction functionality and ease of use.

[0003] In AutoCAD's secondary development, Jig technology is often used to achieve dynamic interaction in drawing operations. This technology dynamically displays the entities to be placed and provides a real-time dragging effect. What you see is what you get, allowing users to preview the effects instantly. For example, when arranging fire sprinklers on a plan, the user can click the first point before placing sprinkler heads in batches, and then move the mouse in the drawing area. At this time, multiple columns of temporary sprinkler line elements will be dynamically generated in real time. The protection radius and sprinkler spacing annotations can also be displayed, and the sprinkler head layout positioning will be changed in real time as the mouse position changes. When the user presses the second point, the program will automatically exit the drag preview mode and complete the actual drawing based on the sprinkler line positioning results during the preview.

[0004] The Revit software interface provides native dynamic real-time preview functions for drawing walls, pipelines, and placing family components, but does not open a custom secondary development interface. For example, if users want to implement the above-mentioned batch layout of fire sprinklers, they cannot call the corresponding function to achieve real-time preview.

[0005] Currently, no effective solution has been proposed to the above-mentioned problems existing in the related technologies. Summary of the Invention

[0006] The main purpose 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 in the related art that Revit software cannot perform drag and drop preview in real time.

[0007] To achieve the above-mentioned purpose, according to one aspect of the present application, a method for dynamically drawing temporary graphics based on Revit is provided. The method comprises: step S101, capturing mouse events and keyboard events, wherein mouse events include mouse buttons and movements, and keyboard events include keyboard input; step S102, obtaining the screen coordinates of the mouse based on the mouse events and converting them into view coordinates; step S103, constructing temporary elements based on the view coordinates, and pushing the temporary elements to the Revit graphics rendering pipeline to display the temporary elements; step S104, when the mouse cursor moves, repeating steps S102-S103 until the program is exited or the drawing end condition is met, automatically exiting, stopping capturing mouse events and keyboard events, clearing the temporary graphics, and stopping drawing the temporary graphics; step S105, creating components based on the screen coordinates and view coordinates.

[0008] Optionally, the external application responds to mouse events and keyboard events 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.

[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: , ,in, is the horizontal scaling ratio, For vertical scaling, are screen coordinates, It is the horizontal coordinate 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 of the lower right corner of the interface drawing area; obtain the view range of the interface drawing area, obtain the minimum coordinate point and the maximum coordinate point; obtain the projection surface 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 coordinates to view coordinates based on the projection coordinates, the calculation formula is ,in, 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 three-dimensional view, the projection surface is determined to be the plane where the midpoint of the minimum coordinate point and the maximum coordinate point is located as the projection surface, the projection point is the midpoint of the minimum coordinate point and the maximum coordinate point, and the normal vector of the projection surface is the direction of the current view toward the observer; if it is other views, the projection surface is determined to be the sketch plane of the view, the projection point is the origin of the sketch plane, and the normal vector of the projection surface is the direction of the current view toward the observer.

[0011] Optionally, the minimum coordinate point is projected onto the projection plane to obtain the lower left projection coordinate point; the maximum coordinate point is projected onto the projection plane to obtain the upper right projection coordinate point; the lower left projection coordinate point is projected onto 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; the upper right projection coordinate point is projected onto 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 horizontal coordinate and the vertical coordinate between the initialization screen coordinates and the real-time screen coordinates is no more than two pixels, a temporary graphic is rendered; when the difference between the horizontal coordinate and the vertical coordinate between the initialization screen coordinates and the real-time screen coordinates is greater than two pixels, the initialization screen coordinates are updated to the real-time screen coordinates.

[0013] According to another aspect of the present application, a device for dynamically drawing temporary graphics based on Revit is provided. The device includes: a capture unit for executing step S101 to capture mouse events and keyboard events, wherein mouse events include mouse buttons and movements, and keyboard events include keyboard input; a conversion unit for executing step S102 to obtain the screen coordinates of the mouse based on the mouse events and convert them into view coordinates; a rendering unit for executing step S103 to construct temporary elements based on the view coordinates and push the temporary elements to the Revit graphics rendering pipeline to display the temporary elements; an ending unit for executing step S104 to repeat steps S102-S103 when the mouse cursor moves until the program exits or the drawing end condition is met, and then the program stops capturing mouse events and keyboard events, clears the temporary graphics, and stops drawing the temporary graphics; and a creation unit for executing step S105 to create components based on the screen coordinates and view coordinates.

[0014] In order to achieve the above-mentioned purpose, according to another aspect of the present application, a computer-readable storage medium is provided, which includes a stored program, wherein the program executes any one of the above-mentioned methods for dynamically drawing temporary graphics based on Revit.

[0015] According to another aspect of the present application, an electronic device is provided, comprising: 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 executing any one of the items of dynamically drawing temporary graphics based on Revit.

[0016] Through the present application, the following steps are adopted: Step S101, capturing mouse events and keyboard events, wherein mouse events include mouse buttons and movements, and keyboard events include keyboard input; Step S102, obtaining the screen coordinates of the mouse based on the mouse events, and converting them into view coordinates; Step S103, constructing temporary elements based on the view coordinates, and pushing the temporary elements to the Revit graphics rendering pipeline to display the temporary elements; Step S104, when the mouse cursor moves, repeating steps S102-S103 until the program is exited or the conditions for ending drawing are met and the program is automatically exited, stopping capturing mouse events and keyboard events, clearing the temporary graphics, and stopping drawing the temporary graphics; Step S105, creating components based on screen coordinates and view coordinates, solving the problem in the related art that Revit software cannot perform drag and drop preview in real time, thereby achieving the effect of improving the ease of user operation 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 briefly introduces the drawings required for use in the specific embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

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

[0019] Figure 2 It is a schematic diagram of the communication between the external application and Revit through the callback function;

[0020] Figure 3 It is a flowchart for optimizing graphics submission and view refresh response;

[0021] Figure 4 This 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 DESCRIPTION

[0022] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments in this application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0023] In order to enable those skilled in the art to better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this 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 are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application described here. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0025] As introduced in the background technology, the existing technology provides native dynamic real-time preview functions for drawing walls, pipelines, and placing family components, but does not open a customized secondary development interface. In order to solve the problem that Revit software cannot perform real-time drag and drop preview, the embodiments of the present application provide a method and device for dynamically drawing temporary graphics based on Revit.

[0026] The technical solutions in the embodiments of the present invention will be described clearly and completely below 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 is provided, which runs on a mobile terminal, a computer terminal or a similar computing device. 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 a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

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

[0029] Step S101, capturing mouse events and keyboard events, wherein mouse events include mouse buttons and movements, and keyboard events include keyboard inputs;

[0030] Specifically, the Windows API is used to obtain mouse events and keyboard events through HOOK, and monitor user keyboard input and mouse button and movement actions.

[0031] Step S102, obtaining the screen coordinates of the mouse according to the mouse event, and converting them into view coordinates, represented by q;

[0032] Specifically, the screen coordinate position of the mouse is obtained in the mouse action event processing function and converted into the coordinates of the view through the function;

[0033] Step S103: construct a temporary element based on the view coordinates, and push the temporary element to the Revit graphics rendering pipeline to display the temporary element;

[0034] Specifically, the coordinates p[i] of the location where the user clicks in the view are obtained (this may be necessary depending on the actual application), and the p set and q are used as input positioning parameters to construct a temporary element. The element is then pushed to the Revit graphics rendering pipeline in the specified format and submitted to Revit for display.

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

[0036] Step S105, creating a component according to the screen coordinates and the view coordinates;

[0037] Specifically, a real component is created based on the p set and q as the positioning parameters of the input.

[0038] In order to simulate the drag preview effect, the existing technology uses the following methods to achieve it:

[0039] 1. Implement this by calling Revit's built-in commands. You can simulate dynamic dragging by calling Revit's built-in commands, such as the detail line command PostableCommand.DetailLine, via UIApplication.PostCommand(); or use the UIDocument.PromptForFamilyInstancePlacement() method to place line-based family components. The disadvantage of both methods is that they only allow for double-point straight line dragging or display the default family instance appearance, preventing in-depth customization of the preview appearance.

[0040] 2. Implement this through repeated short transaction commits and refreshes. Temporary drag-and-drop graphics are generated based on the real-time mouse positioning, and these temporary graphics are continuously deleted and recreated as the mouse positioning changes. The disadvantage of this approach is that it requires frequent transaction commits, resulting in a rapid increase in component IDs within a short period of time. Furthermore, the project model database requires frequent access and view refreshes, resulting in slower response to user operations in larger project models.

[0041] 3. Implement this by placing a transparent form in the drawing area. When you start drawing, a transparent form pops up in the drawing area. GDI lines are then drawn on this form based on the mouse position. As the mouse zooms in and out, the line size in the form also adjusts proportionally. When the user completes the operation, the transparent form closes. The disadvantage of this method is that the appearance and responsiveness of the line drawing on the form do not match the appearance and responsiveness of changes in the drawing area view. This asynchrony is particularly noticeable in larger models.

[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. The basic principle is to use the defined basic graphics elements (such as points, lines and triangles) as input in the external application, push them to the graphics rendering pipeline inside Revit through DirectContext3DAPI for drawing, and then display them in the view interface. It needs to implement a DirectContext3DServer server object, respond to the callback from Revit and execute the DirectContext3DAPI call to draw temporary graphics. The callback function used is mainly RenderScene(), and the process of its interaction with Revit is as follows Figure 2 shown.

[0043] The advantage of this method is that it allows developers to customize the appearance of preview graphics, control the refresh frequency of graphics, and avoid frequently submitting transactions to add or delete components. At the same time, because temporary graphics will be uniformly entered into the graphics rendering pipeline within Revit, they can also maintain dynamic synchronous response with the drawing and display of Revit views.

[0044] To make it easier to demonstrate the entire process, this article will use the function of drawing a straight line with two points as an example to explain how to add a dynamic preview graphic:

[0045] First, in the external Revit application, prompt the user to click a starting point and record the view coordinates of that point. Then, create an instance of the LineJig class named lineJig and pass the user's starting point as an input parameter to its DrawingServer property. Use the lineJig.DrawJig() method to begin drawing a temporary shape, display it in the view interface, and notify the user to click the next point. After the user clicks the second point in the view, use the lineJig.StopJig() method to exit the temporary shape drawing process. The code for this process is as follows.

[0046] XYZp1=commandData.Application.ActiveUIDocument.Selection.PickPoint(); / / Get the view coordinates where the user first clicks;

[0047] XYZ p2 = null;

[0048] LineJig lineJig = null;

[0049] try

[0050] {

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

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

[0053] p2 = uiDocument.Selection.PickPoint("Pick the next point"); / / Get the view coordinates where the user clicks for the second time;

[0054] }

[0055] catch (Exception ex)

[0056] {}

[0057] finally

[0058] {

[0059] if (lineJig != null)

[0060] {

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

[0062] }

[0063] }

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

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

[0066] public override void DrawJig()

[0067] {

[0068] this.DrawingServer.CurveList.Clear(); / / The original temporary graphics must be cleared 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. NextPoint is the view coordinate point 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 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.

[0079] Specifically, to respond to Windows mouse and keyboard events, it is necessary to embed a global mouse and keyboard hook under the Windows message processing mechanism in the external application to respond to mouse and keyboard events in real time (such as the mouse's OnMouseActivity event and the keyboard's KeyPress event). In the implementation method of subscribing to these events, the mouse cursor coordinate information is pushed to the external application in real time, thereby achieving temporary graphics drawing and display.

[0080] Global hooks monitor event messages from all threads in the system, capturing mouse movements, clicks, and keyboard keystrokes in real time. Through global hooks, external applications can obtain the precise coordinates of the mouse cursor, which is very effective for applications that require precise mouse position. The captured event data and coordinate information can be pushed to external applications in real time for further processing or analysis.

[0081] In an optional embodiment, the screen coordinates of the mouse cursor are obtained; the screen range of the interface drawing area is obtained, and the coordinate points of the four corners of the interface drawing area are calculated; the horizontal scaling ratio and the vertical scaling ratio between the screen and the view are calculated using the following formulas: , ,in, is the horizontal scaling ratio, For vertical scaling, are screen coordinates, It is the horizontal coordinate 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 of the lower right corner of the interface drawing area; obtain the view range of the interface drawing area, obtain the minimum coordinate point and the maximum coordinate point; obtain the projection surface 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 coordinates to view coordinates based on the projection coordinates, the calculation formula is ,in, 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 method of converting screen coordinates to view coordinates is as follows:

[0083] XYZ GetMousePoint()

[0084] {

[0085] / / Get 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 view

[0096] {

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

[0098] }

[0099] else if (currentView is ViewSection|| currentView is ViewPlanplanView) / / For plan and section 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] / / bottom right point coordinates

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

[0112] / / Upper left point coordinates

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

[0114] / / Move coordinate point

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

[0116] return pc;

[0117] }

[0118] / / / <summary>

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

[0120] / / / < / summary>

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

[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 get the projected point

[0141] / / / < / summary>

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

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

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

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

[0146] XYZ GetProjectPointOnSurface(XYZ pointOutOfSurface, XYZnormalOfSurface, 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);

[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] 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 optional embodiment, if it is a three-dimensional view, the projection surface is determined to be the plane where the midpoint of the minimum coordinate point and the maximum coordinate point is located as the projection surface, the projection point is the midpoint of the minimum coordinate point and the maximum coordinate point, and the normal vector of the projection surface is the direction of the current view toward the observer; if it is other views, the projection surface is determined to be the sketch plane of the view, the projection point is the origin of the sketch plane, and the normal vector of the projection surface is the direction of the current view toward the observer.

[0177] Specifically, a projection surface is obtained, and the three-dimensional stereogram is converted into a two-dimensional plane image and projected onto a display, so as to prepare for the subsequent acquisition of projection coordinate points through the projection surface.

[0178] In an optional embodiment, the minimum coordinate point is projected onto the projection plane to obtain the lower left projection coordinate point; the maximum coordinate point is projected onto the projection plane to obtain the upper right projection coordinate point; the lower left projection coordinate point is projected onto 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; the upper right projection coordinate point is projected onto 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 optional embodiment, when the difference between the horizontal coordinate and the vertical coordinate between the initialization screen coordinates and the real-time screen coordinates is no more than two pixels, a temporary graphic is rendered; when the difference between the horizontal coordinate and the vertical coordinate between the initialization screen coordinates and the real-time screen coordinates is greater than two pixels, the initialization screen coordinates are updated to the real-time screen coordinates.

[0180] Specifically, the issue of lag when refreshing views of large models is addressed. Due to the high frequency of the mouse OnMouseActivity event, each event triggers a graphics redraw and refresh of the current view in the Revit rendering pipeline. Therefore, when a large number of real-world models are already in the view, this can cause delays in view refresh response and lead to lag. To address this issue, the article records the screen coordinates of the current mouse movement in the event subscription method and then compares them with the coordinates of the next mouse movement. Only when the two coordinates are close (within 2 pixels of each other in both horizontal and vertical coordinates) is the temporary drawing submitted for rendering using the DrawJig() method. Otherwise, only the most recent mouse screen coordinates are recorded for the next comparison. This avoids the frequent submission of rendered graphics and view refreshes caused by responding to all mouse movements. After the temporary drawing is submitted, the current view must be refreshed (ActiveUIDocument.RefreshActiveView()) to view the actual results.

[0181] The new coordinates are recorded to determine the distance the next time the user's cursor position changes. The view will only be refreshed when the user's mouse cursor moves back and forth within a short distance. Because the user will always stop the mouse cursor at a suitable location and fine-tune the position of the coordinate point, as long as the movement slows down, the two adjacent mouse coordinate points will be close in position, which will trigger a refresh of the view. So there is no need to worry about the user constantly swinging the mouse for a long distance. Because constantly swinging the mouse for a long distance is not a normal and reasonable operation, we must avoid frequent view refreshes when the user is operating at a long distance, which will cause response lag.

[0182] Reference Figure 3 , Figure 3 Flowchart for optimizing graph submission and view refresh responses.

[0183] The following code snippet demonstrates how to determine whether a refresh is needed based on the mouse coordinates in a method that responds to a mouse activity event.

[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)

[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 in the embodiment of the present application. The device is used to implement the above-mentioned embodiments and preferred implementation methods, and the details that have been explained will not be repeated here. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, implementation in hardware, or a combination of software and hardware, is also possible and conceivable.

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

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

[0235] The capture unit 401 is configured to execute step S101 to capture mouse events and keyboard events, wherein the mouse events include mouse buttons and movements, and the keyboard events include keyboard inputs;

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

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

[0238] End unit 404 is used to execute step S104. When the mouse cursor moves, steps S102-S103 are repeated until the program exits or the drawing end condition is met, the program automatically exits, stops capturing mouse events and keyboard events, clears the temporary graphics, and stops drawing the temporary graphics.

[0239] The creation unit 405 is configured to execute step S105 and create a component according to the screen coordinates and the view coordinates.

[0240] In an optional embodiment, the capture unit 401 includes: a response sub-unit, which is used for external applications to respond to mouse events and keyboard events in real time through the 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.

[0241] In an optional 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 coordinates of the four corners of the interface drawing area; and a second calculation subunit, configured to calculate the horizontal scaling ratio and the vertical scaling ratio between the screen and the view, using the following calculation formula: , ,in, is the horizontal scaling ratio, For vertical scaling, are screen coordinates, It is the horizontal coordinate 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 of the lower right corner of the interface drawing area; the second acquisition subunit is used to obtain the view range of the interface drawing area and obtain the minimum coordinate point and the maximum coordinate point; the third acquisition subunit is used to obtain the projection surface of the view; the third calculation subunit is used to obtain the projection point of the view coordinate and calculate the projection coordinate points of the four corners of the interface drawing area; the fourth calculation subunit is used to convert the screen coordinate into the view coordinate according to the projection coordinate. The calculation formula is ,in, 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 optional embodiment, the third acquisition sub-unit includes: a first determination module, which is used to determine that if it is a three-dimensional view, the plane where the midpoint of the minimum coordinate point and the maximum coordinate point is 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 toward the observer; a second determination module, which is used to determine that if it is other views, 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 toward the observer.

[0243] In an optional embodiment, the third calculation subunit includes: a first projection module, used to project the minimum coordinate point onto the projection plane to obtain a lower left projection coordinate point; a second projection module, used to project the maximum coordinate point onto the projection plane to obtain an upper right projection coordinate point; a third projection module, used to project the lower left projection coordinate point onto a 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 an upper left projection coordinate point; a fourth projection module, used to project the upper right projection coordinate point onto a 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 a lower right projection coordinate point.

[0244] In an optional embodiment, the rendering unit 303 includes: a first rendering subunit, used to render a temporary graphic when the difference between the horizontal coordinate and the vertical coordinate between the initialization screen coordinates and the real-time screen coordinates is not greater than two pixels; a second rendering subunit, used to update the initialization screen coordinates to the real-time screen coordinates when the difference between the horizontal coordinate and the vertical coordinate between the initialization screen coordinates and the real-time screen coordinates is greater than two pixels.

[0245] The apparatus for dynamically rendering temporary graphics based on Revit includes a processor and a memory. The capture unit 401 and other components are stored in the memory as program units, and the processor executes the program units stored in the memory to implement corresponding functions. The modules are all located in the same processor; alternatively, the modules can be located in different processors in any combination.

[0246] The processor contains a core, which retrieves the corresponding program unit from memory. You can configure one or more cores, and by adjusting the core parameters, you can resolve technical issues that prevent Revit from performing real-time drag and drop previews.

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

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

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

[0250] Step S101, capture mouse events and keyboard events, where mouse events include mouse buttons and movements, and keyboard events include keyboard input; Step S102, obtain the screen coordinates of the mouse based on the mouse events and convert them into view coordinates; Step S103, construct temporary elements based on the view coordinates, and push the temporary elements to the Revit graphics rendering pipeline to display the temporary elements; Step S104, when the mouse cursor moves, repeat steps S102-S103 until the program is exited or the drawing end condition is met, and the program automatically exits, stops capturing mouse events and keyboard events, clears the temporary graphics, and stops drawing the temporary graphics; Step S105, creates components based on the screen coordinates and view coordinates.

[0251] Optionally, the external application responds to mouse events and keyboard events 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.

[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 scaling ratio and vertical scaling ratio between the screen and the view, and the calculation formula is: , ,in, is the horizontal scaling ratio, For vertical scaling, are screen coordinates, It is the horizontal coordinate 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 of the lower right corner of the interface drawing area; obtain the view range of the interface drawing area, obtain the minimum coordinate point and the maximum coordinate point; obtain the projection surface 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 coordinates to view coordinates based on the projection coordinates, the calculation formula is ,in, 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 three-dimensional view, the projection surface is determined to be the plane where the midpoint of the minimum coordinate point and the maximum coordinate point is located as the projection surface, the projection point is the midpoint of the minimum coordinate point and the maximum coordinate point, and the normal vector of the projection surface is the direction of the current view toward the observer; if it is other views, the projection surface is determined to be the sketch plane of the view, the projection point is the origin of the sketch plane, and the normal vector of the projection surface is the direction of the current view toward the observer.

[0254] Optionally, the minimum coordinate point is projected onto the projection plane to obtain the lower left projection coordinate point; the maximum coordinate point is projected onto the projection plane to obtain the upper right projection coordinate point; the lower left projection coordinate point is projected onto 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; the upper right projection coordinate point is projected onto 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 horizontal coordinate and the vertical coordinate between the initialization screen coordinates and the real-time screen coordinates is no more than two pixels, a temporary graphic is rendered; when the difference between the horizontal coordinate and the vertical coordinate between the initialization screen coordinates and the real-time screen coordinates is greater than two pixels, the initialization screen coordinates are updated to the real-time screen coordinates.

[0256] An embodiment of the present invention provides a processor, which is used to run a program, wherein the program executes the method of dynamically drawing temporary graphics based on Revit when running.

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

[0258] Step S101, capture mouse events and keyboard events, where mouse events include mouse buttons and movements, and keyboard events include keyboard input; Step S102, obtain the screen coordinates of the mouse based on the mouse events and convert them into view coordinates; Step S103, construct temporary elements based on the view coordinates, and push the temporary elements to the Revit graphics rendering pipeline to display the temporary elements; Step S104, when the mouse cursor moves, repeat steps S102-S103 until the program is exited or the drawing end condition is met, and the program automatically exits, stops capturing mouse events and keyboard events, clears the temporary graphics, and stops drawing the temporary graphics; Step S105, creates components based on the screen coordinates and view coordinates.

[0259] Optionally, the external application responds to mouse events and keyboard events 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 vertical scaling ratio between the screen and the view, and the calculation formula is: , ,in, is the horizontal scaling ratio, For vertical scaling, are screen coordinates, It is the horizontal coordinate 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 of the lower right corner of the interface drawing area; obtain the view range of the interface drawing area, obtain the minimum coordinate point and the maximum coordinate point; obtain the projection surface 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 coordinates to view coordinates based on the projection coordinates, the calculation formula is ,in, 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 three-dimensional view, the projection surface is determined to be the plane where the midpoint of the minimum coordinate point and the maximum coordinate point is located as the projection surface, the projection point is the midpoint of the minimum coordinate point and the maximum coordinate point, and the normal vector of the projection surface is the direction of the current view toward the observer; if it is other views, the projection surface is determined to be the sketch plane of the view, the projection point is the origin of the sketch plane, and the normal vector of the projection surface is the direction of the current view toward the observer.

[0262] Optionally, the minimum coordinate point is projected onto the projection plane to obtain the lower left projection coordinate point; the maximum coordinate point is projected onto the projection plane to obtain the upper right projection coordinate point; the lower left projection coordinate point is projected onto 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; the upper right projection coordinate point is projected onto 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 horizontal coordinate and the vertical coordinate between the initialization screen coordinates and the real-time screen coordinates is no more than two pixels, a temporary graphic is rendered; when the difference between the horizontal coordinate and the vertical coordinate between the initialization screen coordinates and the real-time screen coordinates is greater than two pixels, the initialization screen coordinates are updated to the real-time screen coordinates.

[0264] An embodiment of the present invention provides a device comprising a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, at least the following steps are implemented: Step S101, capturing mouse events and keyboard events, wherein mouse events include mouse button presses and movements, and keyboard events include keyboard input; Step S102, obtaining the mouse screen coordinates based on the mouse events and converting them into view coordinates; Step S103, constructing temporary elements based on the view coordinates and pushing the temporary elements to the Revit graphics rendering pipeline to display the temporary elements; Step S104, when the mouse cursor moves, repeating Steps S102-S103 until the program is exited or a drawing termination condition is met, then automatically exiting, stopping capturing mouse and keyboard events, clearing the temporary graphics, and ceasing drawing of the temporary graphics; Step S105, creating components based on the screen coordinates and view coordinates. The device herein may be a server, a PC, a PAD, a mobile phone, or the like.

[0265] Optionally, the external application responds to mouse events and keyboard events 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.

[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 vertical scaling ratio between the screen and the view, and the calculation formula is: , ,in, is the horizontal scaling ratio, For vertical scaling, are screen coordinates, It is the horizontal coordinate 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 of the lower right corner of the interface drawing area; obtain the view range of the interface drawing area, obtain the minimum coordinate point and the maximum coordinate point; obtain the projection surface 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 coordinates to view coordinates based on the projection coordinates, the calculation formula is ,in, 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, the projection surface is determined to be the plane where the midpoint of the minimum coordinate point and the maximum coordinate point is located as the projection surface, the projection point is the midpoint of the minimum coordinate point and the maximum coordinate point, and the normal vector of the projection surface is the direction of the current view toward the observer; if it is other views, the projection surface is determined to be the sketch plane of the view, the projection point is the origin of the sketch plane, and the normal vector of the projection surface is the direction of the current view toward the observer.

[0268] Optionally, the minimum coordinate point is projected onto the projection plane to obtain the lower left projection coordinate point; the maximum coordinate point is projected onto the projection plane to obtain the upper right projection coordinate point; the lower left projection coordinate point is projected onto 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; the upper right projection coordinate point is projected onto 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 difference between the horizontal coordinate and the vertical coordinate between the initialization screen coordinates and the real-time screen coordinates is no more than two pixels, a temporary graphic is rendered; when the difference between the horizontal coordinate and the vertical coordinate between the initialization screen coordinates and the real-time screen coordinates is greater than two pixels, the initialization screen coordinates are updated 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 suitable for executing a program that is initialized with at least the following method steps: step S101, capturing mouse events and keyboard events, wherein mouse events include mouse buttons and movements, and keyboard events include keyboard input; step S102, obtaining the screen coordinates of the mouse based on the mouse events, and converting them into view coordinates; step S103, constructing temporary elements based on the view coordinates, and pushing the temporary elements to the Revit graphics rendering pipeline to display the temporary elements; step S104, when the mouse cursor moves, repeating steps S102-S103 until the program is exited or the condition for ending drawing is met and the program is automatically exited, stopping capturing mouse events and keyboard events, clearing the temporary graphics, and stopping drawing the temporary graphics; step S105, creating components based on the screen coordinates and view coordinates.

[0271] Optionally, the external application responds to mouse events and keyboard events 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.

[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: , ,in, is the horizontal scaling ratio, For vertical scaling, are screen coordinates, It is the horizontal coordinate 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 of the lower right corner of the interface drawing area; obtain the view range of the interface drawing area, obtain the minimum coordinate point and the maximum coordinate point; obtain the projection surface 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 coordinates to view coordinates based on the projection coordinates, the calculation formula is ,in, 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, the projection surface is determined to be the plane where the midpoint of the minimum coordinate point and the maximum coordinate point is located as the projection surface, the projection point is the midpoint of the minimum coordinate point and the maximum coordinate point, and the normal vector of the projection surface is the direction of the current view toward the observer; if it is other views, the projection surface is determined to be the sketch plane of the view, the projection point is the origin of the sketch plane, and the normal vector of the projection surface is the direction of the current view toward the observer.

[0274] Optionally, the minimum coordinate point is projected onto the projection plane to obtain the lower left projection coordinate point; the maximum coordinate point is projected onto the projection plane to obtain the upper right projection coordinate point; the lower left projection coordinate point is projected onto 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; the upper right projection coordinate point is projected onto 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 horizontal coordinate and the vertical coordinate between the initialization screen coordinates and the real-time screen coordinates is no more than two pixels, a temporary graphic is rendered; when the difference between the horizontal coordinate and the vertical coordinate between the initialization screen coordinates and the real-time screen coordinates is greater than two pixels, the initialization screen coordinates are updated to the real-time screen coordinates.

[0276] Obviously, those skilled in the art will appreciate that the various modules or steps of the present invention described above can be implemented using a general-purpose computing device, can be centralized on a single computing device, or can be distributed across a network of multiple computing devices. They can be implemented using program code executable by the computing device, and thus, can be stored in a storage device and executed by the computing device. In some cases, the steps shown or described herein can be performed in a different order than that shown, or can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.

[0277] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0278] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes 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 a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0279] These computer program instructions may 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, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0280] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

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

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

[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: include: Step S101, capturing mouse events and keyboard events, wherein the mouse events include mouse buttons 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 graphic element according to the view coordinates, and pushing the temporary graphic element to the Revit graphics rendering pipeline to display the temporary graphic element; Step S104, when the mouse cursor moves, repeat steps S102-S103 until the program is exited or the drawing end condition is met and the program is automatically exited, the capture of mouse events and keyboard events is stopped, the temporary graphics are cleared, and the drawing of the temporary graphics is stopped; Step S105 , creating a component according to the screen coordinates and the view coordinates.

2. The method according to claim 1, characterized in that Step S101, capturing mouse events and keyboard events, includes: 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.

3. The method according to claim 1, characterized in that Step S102, obtaining the screen coordinates of the mouse according to the mouse event and converting them into view coordinates, includes: Get the screen coordinates of the mouse cursor; Get the screen range of the interface drawing area and calculate the coordinates of the four corners of the interface drawing area; Calculate the horizontal and vertical scaling ratios between the screen and the view. The calculation formula is: , ,in, is the horizontal scaling ratio, is the vertical scaling ratio, are the screen coordinates, It is the horizontal coordinate of the upper left corner of the interface drawing area. is the coordinate of the upper right corner of the interface drawing area, It is the vertical coordinate of the lower right corner of the interface drawing area; Get the view range of the interface drawing area and get the minimum and maximum coordinate points; Get the projection surface of the view; Get the projection point of the view coordinates and calculate the projection coordinate points of the four corners of the interface drawing area; The screen coordinates are converted to view coordinates based on the projection coordinates. The calculation formula is: ,in, 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.

4. The method according to claim 3, characterized in that Get the projection surface of the view, including: If it is a three-dimensional view, the projection plane is determined to be 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 toward the observer; If it is any other view, the projection surface is determined to be the sketch plane of the view, the projection point is the origin of the sketch plane, and the normal vector of the projection surface is the direction of the current view toward the observer.

5. The method according to claim 3, characterized in that: Get the projection point of the view coordinates and calculate 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 a lower left projection coordinate point; Projecting the maximum coordinate point onto the projection plane to obtain an upper right projection coordinate point; Project the lower left projection coordinate point onto 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; The upper right projection coordinate point is projected onto a projection plane that takes the upward side of the current view as the normal direction and passes through the lower left projection coordinate point to obtain the lower right projection coordinate point.

6. The method according to claim 1, characterized in that Constructing a temporary element according to the view coordinates, and pushing the temporary element to the Revit graphics rendering pipeline, before displaying the temporary element, including: When the difference between the abscissa and ordinate of the initialization screen coordinates and the real-time screen coordinates is no more than two pixels, the temporary graphics are rendered; When the difference between the abscissa and the ordinate between the initialization screen coordinates and the real-time screen coordinates is greater than two pixels, the initialization screen coordinates are updated to the real-time screen coordinates.

7. A device for dynamically drawing temporary graphics based on Revit, characterized in that: include: A capture unit, used to execute step S101, capture mouse events and keyboard events, wherein the mouse events include mouse buttons and movements, and the keyboard events include keyboard inputs; A conversion unit, used to execute step S102, obtain the screen coordinates of the mouse according to the mouse event, and convert them into view coordinates; A rendering unit, configured to execute step S103, construct a temporary graphic element according to the view coordinates, and push the temporary graphic element to a Revit graphics rendering pipeline to display the temporary graphic element; An end unit, used to execute step S104, when the mouse cursor moves, repeat steps S102-S103 until the program is exited or the drawing end condition is met and the program is automatically exited, the capture of mouse events and keyboard events is stopped, the temporary graphics are cleared, and the drawing of the temporary graphics is stopped; The creating unit is used to execute step S105 to create a component according to the screen coordinates and the view coordinates.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute a method for dynamically drawing temporary graphics based on Revit as described in any one of claims 1 to 6.

9. An electronic device, characterized in that: include: One or more processors, a memory, and one or more programs, wherein 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 executing a method for dynamically drawing temporary graphics based on Revit as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • User interface generation method

    CN101944027A

  • Design scheme of user interface used for human-computer interaction under VxWorks system

    CN107391125A

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

    CN115904152A

  • BIM (Building Information Modeling) visualization method and device based on cloud rendering, equipment and medium

    CN115914526A

  • Coordinate designating method for plotting supporting tool

    JP1994230762A