Boutique CAD Batch processing tool--batchproc

Source: Internet
Author: User
Tags function prototype

Batchproc is a batch plug-in that is based on AutoCAD two-time development. Loading a program into CAD allows you to bulk manipulate multiple documents with custom Lisp code.

1. Document Description

This program from the Ming through the CAD community named "Autumn Maple" users to provide, I pass the test on the use of the procedure to explain, in order to improve the efficiency of CAD graphics processing. The source program download link is as follows:

Http://bbs.mjtd.com/thread-13302-1-1.html

Note : The TD CAD Community is a relatively well-known CAD forum, which contains a large number of CAD operations skills and two development code, but registration requires an invitation code (can be exchanged for 1 yuan).

The Batchproc batch program contains two files: Batchproc.dvb is a VBA-based program, and BATCHPROC.LSP is a Lisp-based program. As shown in 1.

2. Installation and operation

(1) The program BATCHPROC.DVB and BATCHPROC.LSP copied into the CAD installation path under the Support folder, such as E:\Program Files\autocad 2007\support;

(2) Run the CAD, type "APPLOAD" on the command line, select the BATCHPROC.LSP under the support file in the previous step in the pop-up selection dialog box, click "Load", close the dialog box;

(3) If the load succeeds, the command line outputs "successfully loaded BATCHPROC.LSP" and the command bat is entered to run the program. The main interface of the program is as follows:

Note : If you need to load this tool automatically when CAD starts, you need to modify the CAD installation path E:\Program FILES\AUTOCAD 2007\support ACAD2007.LSP

    1. (arxload "vel.arx")
    2. (if (Not (= (substr (ver) 1) "Visual LISP"))
    3. (Load "acad2007doc.lsp");
    4. )
    5. ;; Silent load.
    6. (princ) can replace the actual value with the following constant anywhere in the code:

3. Tool description

The procedures for the specific operation are as follows:

(1) "Add File" or "Append directory" to select the DWG file to be processed in bulk, also can use "delete" and "clear" button to manipulate files in the purge file list;

(2) Click the "Edit" button to pop up the Edit Code window, as shown in 3-2. The user can edit, open, save the code, after editing is complete, click "Close", the program will automatically save the edits, and updates appear in the Code window (if you use the scripting language, select "Script Code");

(3) Click "Start Batch Processing", the program will open the files in the file list, and follow the code in the Code window (if the "automatic disk after processing", the operation results file will overwrite the original data)

4. Code Analysis

The test case for this program is two copies of the map, now the requirements are:

    • Change all text fonts in the Jzd and JZP layers to Arial;
    • Change the Hz style to Txt.shx, hztxt.shx (large font);
    • Change the color of all objects in the Jzd, Jzp, and JMD layers to red.

The test code for "Parcel map modification 20140820.LSP" Under the test Case folder is now described in the code that is more critical:

(1) Get a layer of text

    1. (setq SS (ssget "x" (List (cons 0 "*text") (Cons 8 "jzd")));

Ssget is used to establish a selection feature set, where "x" means select all, 0 and 8 for different groups, *text is the filter selection text, jzd the layer to be selected.

(2) Create new or change text styles

    1. (Command "_style" "ST" "simsunb.ttf" "0" "1" "" "" "")
    2. (Command "_style" "hztxt" "txt.shx,hztxt.shx" 0 0.8 0 "n" "N" " n")

The new style uses the _style command, "ST" for the style name, "Simsunb.ttf" font name, and if you want to use a large font style, the font parameter is set to such as "txt.shx,hztxt.shx", if the style name already exists, the command modifies the parameter if it does not exist, will be newly established.

(3) Change the color of a layer to a specified color

    1. (Vla-put-color layer Color_no)

Call the function in the system to modify the layer color, its function prototype is as shown above, it is in Express tools, note to ensure that the installer installs this component. Where the color parameter uses the enumeration value:

constant

value

description

vbblack

0x0

black

vbred

0xff

red

vbgreen

0xff00

green

vbyellow

0xffff

yellow

vbblue

0xff0000

blue

Vbmagenta

0xff00ff

Magenta

Vbcyan

0xffff00

cyan

Vbwhite

0xFFFFFF

White

(4) Change the color of the layer object with the layer

    1. (Command "_.chprop" "_all" "" "_color" "_bylayer" "")

Modifying the color of a layer does not change the color of an existing object, and you need to set the color of the Layer object to follow the layer.

5. Frequently Asked Questions

(1) Open file is prompt to select font

Figure 51 Font not found

This field is missing from the CAD font, either by using another font, or by downloading the missing font and placing it under the Fonts folder under the CAD installation path, such as E:\Program Files\autocad 2007\fonts

(2) When you add a drawing, you cannot load it into the list

The purpose of this program is to do batch processing, at least two graphics files must be selected at the same time to properly load into the file list, if you select only one file, it will not be added correctly.

(3) Run the Times error, errors when saving the document

Generally, in batch processing, you need to tick "automatic disk after processing", but if the graphic is open before processing, the error will be saved, so the graphics will not open during batch processing.

(4) How do I verify that the operation failed?

The most important way to verify the operation is to compare the errors in the test case, and if the code is executed, the CAD Help window pops up and it is recommended that you test the Lisp code before batch processing.

(5) Command line error: no definition vlax-get-acad-object

In the Test Lisp code, the Vlax-get-acad-object object is used, and it is in property Express tools, so when installing the software, you choose to install Express tools

(6) Individual Test Lisp pass, batch failed

As long as the individual test Lisp code can achieve the purpose, batch processing generally can achieve the purpose. Note that if you define a parameterless function in Lisp code, you simply copy the contents of the function into the Batchproc code window without the entire function, and if you define a function with parameters in Lisp code, you need to copy the entire function and copy the command that is called back.

(7) Exception occurred: 0xC0000005 (Access violation)

The call to the bat command appears " exception : 0xC0000005 ( access violation )", which is typically the case when the command is called, and only the CAD is re-installed.

(8) Error "info or ' info transparent call * * * is vertical?"

Call the System Print command (-plot) to print the parcel map in bulk, test the pass on the test machine, but escalate the error on the client: "Use command: info or ' info transparent call * * * is vertical?" <N>, you can only print the first file.

In CAD, when there are many commands that can be used transparently, the transparent command is a function that allows the user to enter these commands on the command line when using another command. So transparent commands are often used to change the shape's settings or display. When the system completes the transparent command, it resumes execution of the original command.

The test machine can be described as a client environment problem, I try to turn off the Cass environment, you can achieve batch printing.

Boutique CAD Batch processing tool--batchproc

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.