autocad civil 3d and stop drawing 1 opening each time

The author is actually a auto learning algorithm engineer. The most painful affair in the piece of work is to label data. And I have encountered more than just label categories, labels, etc. I need to mark the partition polygons of the restaurant and living room in the flooring program. This requires me to read the floor plan data (that is, the coordinate points) and and then draw the picture. After the assay, the partition frame is actually used to observe the partitioning coordinates. The task of this projection is still very large, and the difficulty is not low. It is more difficult to label data. I need to write a script, otherwise I know where to mark the coordinates. I don't recall much of the diverse drawing tools. I simply want to develop a division tool. The core is to use the pyautocad library to describe the existing coordinate points, add together the rectangular box on the CAD software, and then use the programme to set the partition coordinates. Read out and automatically write to the floor plan format file. So all I need to do is look at the uncomplicated information note piece of work of the house picture frame.

The core of the projection is still using pyautocad for api operations. At that place are very few documents on the official website about this library, and the explanations are not consummate. I will summarize the diverse ordinarily used operations here, which is the operation I used. (To put information technology bluntly, this library is to input data into the CAD application through the interface for operation, so in the procedure of drawing, the CAD process must not be closed, the essence is even so CAD cartoon, and the drawing performance can not be likewise fast, the CAD application can't react too much. May report an error, this event remains to be resolved)

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

You lot can see the source code from it, find the bones usage, and find the official documentation. (Information technology is recommended to read it well. In this example, there are fewer solutions. You can't just look effectually and accept a high take a chance of getting a bug.)

pyautocad

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

                      from            pyautocad            import            Autocad            # Automatically connect to cad, as long every bit cad is open, a <pyautocad.api.Autocad> object is created. This object connects to the nigh recently opened cad file.                        # If cad is not open however, a new dwg file will be created and the cad software volition be automatically opened.            acad            =            Autocad(create_if_not_exists=            Truthful            )            # acad.prompt() is used to impress text in the cad console                        acad.prompt(            "Hi, Autocad from Python"            )            # acad.doctor.Name stores the name of the graphic that cad has recently opened.            print            acad.dr..Name                  

In fact, you tin employ the interface given in the certificate to draw, each interface is non difficult to understand, simply there are no detailed examples of interface parameters is a headache. The interface I accept used is beneath, I endeavor to write the parameters clearly:

                      #Importing the APoint class is very necessary. Drawing is washed past points, and all points in the CAD must exist wrapped with the APoint form. APoint (10,30),            # 10 represents the ten coordinate of the bespeak, and 30 represents the y coordinate of the point.            from            pyautocad            import            APoint            import            math            # draw a line, p1 is the starting time betoken of the line, p2 is the 2d betoken            acad.model.AddLine(p1,p2)            # Add text, the starting time parameter is the added text string, the second p is the point wrapped past the APoint course, which means that the text is displayed under which coordinates, 15 is the text font size            text            =            acad.model.AddText(            "{0}"            .            format            (text)            ,            p,            15            )            #Text moves from point p1 to point p2            text.motility(p1,            p2)            # , the get-go parameter p is the signal of the APoint class package, which is the center position, and the 2nd parameter ten is the radius.            acad.model.AddCircle(p,            10            )            # Draw an arc, the first 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 fourth betoken is the ending arc.            acad.model.AddArc(p,            radius,            math.radians(            90            )            ,            math.radians(            270            )            )            # Save the cad map to the specified location, the first parameter must be the absolute path saved! ! , 64 is a format saved, the author tried it from one to 100,            # There are some files that can be generated, all of which are file type formats that can be opened by CAD. In fact, just follow the author to write 64!            acad.doctor.SaveAs(            "{0}"            .            format            (save_path)            ,            64            )                  

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

                      from            pyautocad            import            Autocad,            APoint   acad            =            Autocad(create_if_not_exists=            True            )            acad.prompt(            "Hello, Autocad from Python\northward"            )            print            (acad.doc.Proper noun)            p1            =            APoint(            0            ,            0            )            p2            =            APoint(            50            ,            25            )            for            i            in            range            (            five            )            :            text            =            acad.model.AddText(            'Howdy %southward!'            %            i,            p1,            two.5            )            acad.model.AddLine(p1,            p2)            acad.model.AddCircle(p1,            x            )            p1.y            +=            ten            dp            =            APoint(            10            ,            0            )            # ! ! ! ! ! ! ! Traverse cad graphic objects and access/modify object properties            for            text            in            acad.iter_objects(            'Text'            )            :            print            (            'text: %s at: %due 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 project. ! ! !

                      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, -lx.84885181138725, -564.9692056597924, 308.45202158973643,  -327.4641724567995, 461.94033545845366, -593.0470534647193, 546.8614421365228,   -616.4452718779175, 803.9696476627087) '''            # The starting time and second elements form the first coordinate, the iii and 4 elements form the second coordinate, and so on, and each two elements grade a coordinate.                  

Error reference:


Other details can go to the official website to study carefully, and a CAD drawing of the floor plan ends this technical sharing web log!

clarkebralks.blogspot.com

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

0 Response to "autocad civil 3d and stop drawing 1 opening each time"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel