enter name of drawing to open civil 3d

The writer is actually a machine learning algorithm engineer. The most painful thing in the work is to label information. And I have encountered more than just label categories, labels, etc. I need to mark the partitioning polygons of the restaurant and living room in the floor plan. This requires me to read the flooring plan data (that is, the coordinate points) and so draw the picture. Later the assay, the partitioning frame is actually used to find the division coordinates. The job of this project is however very big, and the difficulty is non depression. It is more difficult to label data. I need to write a script, otherwise I know where to mark the coordinates. I don't think much of the various drawing tools. I just want to develop a division tool. The core is to use the pyautocad library to describe the existing coordinate points, add the rectangular box on the CAD software, then apply the program to set the partition coordinates. Read out and automatically write to the flooring plan format file. So all I need to practise is look at the simple data annotation piece of work of the firm picture frame.

The cadre of the project is even so using pyautocad for api operations. There are very few documents on the official website about this library, and the explanations are not complete. I volition summarize the various commonly used operations hither, which is the operation I used. (To put it frankly, this library is to input information into the CAD application through the interface for performance, then in the process of cartoon, the CAD procedure must not be closed, the essence is still CAD drawing, and the drawing operation can not be too fast, the CAD application can't react too much. May report an error, this consequence remains to be resolved)

Github accost of pyautocad:https://github.com/reclosedev/pyautocad

Yous can run across the source code from it, notice the basic usage, and find the official documentation. (Information technology is recommended to read information technology well. In this case, at that place are fewer solutions. Yous tin can't simply await around and have a high risk of getting a problems.)

pyautocad

The pyautocad package can be operated with any version of cad, in fact the interface is the same. The code outset connects to cad in the documentation:

                      from            pyautocad            import            Autocad            # Automatically connect to cad, as long as cad is open up, a <pyautocad.api.Autocad> object is created. This object connects to the most recently opened cad file.                        # If cad is non open yet, a new dwg file will be created and the cad software will be automatically opened.            acad            =            Autocad(create_if_not_exists=            True            )            # acad.prompt() is used to print text in the cad console                        acad.prompt(            "Hello, Autocad from Python"            )            # acad.doc.Name stores the name of the graphic that cad has recently opened.            print            acad.physician.Name                  

In fact, you tin use the interface given in the document to describe, each interface is non hard to understand, merely there are no detailed examples of interface parameters is a headache. The interface I have used is beneath, I effort to write the parameters clearly:

                      #Importing the APoint class is very necessary. Drawing is done past points, and all points in the CAD must be wrapped with the APoint class. APoint (10,xxx),            # 10 represents the x coordinate of the point, and thirty represents the y coordinate of the signal.            from            pyautocad            import            APoint            import            math            # draw a line, p1 is the commencement betoken of the line, p2 is the second point            acad.model.AddLine(p1,p2)            # Add text, the offset parameter is the added text string, the second p is the point wrapped past the APoint class, which ways that the text is displayed under which coordinates, xv is the text font size            text            =            acad.model.AddText(            "{0}"            .            format            (text)            ,            p,            15            )            #Text moves from bespeak p1 to bespeak p2            text.move(p1,            p2)            # , the first parameter p is the point of the APoint course package, which is the centre position, and the second parameter 10 is the radius.            acad.model.AddCircle(p,            ten            )            # Draw an arc, the beginning parameter is at which point to draw the arc, the second parameter is the radius, the third is the starting arc (radian system, not the angle system), and the 4th point is the catastrophe arc.            acad.model.AddArc(p,            radius,            math.radians(            ninety            )            ,            math.radians(            270            )            )            # Save the cad map to the specified location, the commencement parameter must be the absolute path saved! ! , 64 is a format saved, the author tried it from 1 to 100,            # At that place are some files that tin can exist generated, all of which are file type formats that can exist opened by CAD. In fact, but follow the author to write 64!            acad.doc.SaveAs(            "{0}"            .            format            (save_path)            ,            64            )                  

Then you can combine Python drawing, for an case (very official):

                      from            pyautocad            import            Autocad,            APoint   acad            =            Autocad(create_if_not_exists=            Truthful            )            acad.prompt(            "Hello, Autocad from Python\north"            )            impress            (acad.doc.Name)            p1            =            APoint(            0            ,            0            )            p2            =            APoint(            50            ,            25            )            for            i            in            range            (            5            )            :            text            =            acad.model.AddText(            'How-do-you-do %s!'            %            i,            p1,            2.five            )            acad.model.AddLine(p1,            p2)            acad.model.AddCircle(p1,            10            )            p1.y            +=            10            dp            =            APoint(            10            ,            0            )            # ! ! ! ! ! ! ! Traverse cad graphic objects and access/modify object properties            for            text            in            acad.iter_objects(            'Text'            )            :            print            (            'text: %s at: %south'            %            (text.TextString,            text.InsertionPoint)            )            text.InsertionPoint            =            APoint(text.InsertionPoint)            +            dp            for            obj            in            acad.iter_objects(            [            'Circle'            ,            'Line'            ]            )            :            print            (obj.ObjectName)                  

The result is:

This method extracts the vertices of PolyLine and helps me with my projection. ! ! !

                      for            item            in            acad.iter_objects(            "PolyLine"            )            :            print            (particular.Coordinates)            ''' (-462.01707322354014, 719.8251441314151, 207.17175903027055, 1056.4031530064085,  389.6778054895749, 574.9096117303479, -143.80140284041954, 434.6687742615859,  -326.30744929972207, -sixty.84885181138725, -564.9692056597924, 308.45202158973643,  -327.4641724567995, 461.94033545845366, -593.0470534647193, 546.8614421365228,   -616.4452718779175, 803.9696476627087) '''            # The first and second elements course the kickoff coordinate, the 3 and 4 elements form the second coordinate, and and then on, and each ii elements class a coordinate.                  

Error reference:


Other details tin can become to the official website to study carefully, and a CAD cartoon of the floor plan ends this technical sharing blog!

smithgref1950.blogspot.com

Source: https://programmersought.com/article/257655920/

0 Response to "enter name of drawing to open civil 3d"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel