Choice of language

Source: Internet
Author: User

Because of some features, a user of VBA finally chose net, and for some reason, a user of part net finally chose C + +. Finally, this part of the amateur users embarked on the professional development of the road two, and away from the original professional.

From a CAD group called "arx-Hwa"

As a novice, as an amateur, basic general, limited energy, in fact, the choice of language is a problem that cannot be ignored.

A 04-year old post: How do I choose AutoCAD development tools?

AutoCAD provides three main development tools, namely, ActiveX development using the C + + OBJECTARX,VB/VBA, and autolisp/visuallisp development tools. Every developer has a hobby, but aside from all the preferences, people often want to know which one is the best, and what kind of tools should I choose? The answer to these people is: "It depends on what work you are going to accomplish." "Every development tool has a different kind of thing, and in some cases there are incomparable advantages." When deciding what development tools to use, you can ask yourself four questions: which language makes me feel most comfortable? How much time do I have? Who are my target users and how much experience do they have with AutoCAD? How far do I need to control AutoCAD and how many possible window types are needed to get the job done as soon as possible? When I describe the different features of different development tools, you may understand why these four issues are important. When it comes to these kinds of development tools, I just look at them as functions used in AutoCAD, not as standalone applications.


Objectarx:

In three development tools, this tool has the most in-depth control over AutoCAD and can provide the most types of forms. Using Arx, you can register your own commands with AutoCAD without needing to know more about AutoCAD when the user runs your program. The cost of this convenience is that it takes more time to develop a ARX program than VBA and Lisp programs, so it's a bit wasteful to compile simple drawing tools. To master the premise of Arx is that you are very familiar with C and C + +, from a personal point of view, I like this tool most, but that is because I do 99% of the program is in C and C + + language, the choice of Arx means I do not have to learn a new language. To me, "which language makes me feel most comfortable?" "Is enough. Arx has access to many of the AutoCAD underlying tools (which may not be accessible by VBA and Lisp), which is the main reason why most developers choose Arx, and they need to do some work that they cannot do with the other two development tools. In addition, this is the only development tool that ensures that your code is safe (not read or copied illegally). If you need to develop custom entities, use spatial filtering, extend the functionality of an application that uses other development tools, are developing third-party tools for sales, or use a whole bunch of things that VBA and Lisp can't access (or something that's hard to achieve), Then Objectarx is the best choice for you.


Vba:

If you are developing AutoCAD applications for the first time, then this is the best tool for you! This kind of tool is very friendly to beginners, Visual Basic code reading is very easy, many beginners only read the name of the function can understand a problem. Regardless of creating or executing Lisp commands to augment your means of access, this development tool does not have as much access to AutoCAD as Arx and Lisp (Translator Note: This is also the original, after all, VBA and the other two development tools are much younger than that!) If you are very proficient in VBA, you can carefully study and classify the AutoCAD command line (this may not be fluent, the original is: You can subclass the AutoCAD command lines), so you can achieve all the functions Lisp can do! For VBA, the biggest regret is that you cannot register a command with AutoCAD, you must first load its corresponding DVB file with various methods added to the application, and then execute it through the tools/Macros/Macros menu item, or execute it in both menu items and custom toolbar buttons, if your user's basic knowledge is limited , this is a very small problem for you (translator Note: There is an appropriate solution). I have studied many contracts, and many mappers prefer to execute commands directly at the command line, which is not good news for VBA (development tools) Sales (Translator Note: There is a proper way to do this), and if the user group does not tangle on this issue, then VBA is usually a good commodity, Especially when they see how quickly you can use it to create applications. In conjunction with Lisp, VBA is first and foremost a tool for developing a program used within a company, or used when you have contractor and need to write custom tools in the field. In all development tools, this is one of the fastest-developing tools, especially when developing programs that require a graphical interface (dialog box). With this tool, you can also get the best technical support from Autodesk!


Lisp:

When I talk about Lisp, I usually refer to autolisp and visuallisp rather than the General Lisp language of ANSI. First of all, a brief description of the features of Autolisp,autolisp and the flexibility of COBOL language, the main reason many developers choose Lisp is that it fits their "what language makes me feel good?" "The answer to the question is that for many people, this is the first language they have developed for AutoCAD and is quickly developed using that language. Another reason to use this development tool is that the environment you work in May already have many Lisp programs (indeed, AutoLisp has the longest history of use). Learning Lisp is harder than VBA, but simpler than C and C + +. Until AutoCAD 2000,vba is not very well implemented within AutoCAD, and leaves many issues that developers want to solve. Lisp is the initial development tool for quickly writing applications, and the bulk of the Lisp program inventory is that it is not worthwhile or easy to rewrite these things with VBA in a short period of time around the world. If this is the case, then Lisp is the development tool for you, perhaps God pity you, hehe, a joke. People who have used Lisp for years have been greatly reduced, and if you are a beginner of AutoCAD two times, and your program may want to exchange data with other Windows programs, you'd better go and see VBA. In general, if you are creating a program to Exchange data with a program written in Arx, it is easier for a ARX programmer to prestage an interface to a LISP programmer than for a VBA reserved interface, but a good programmer should be able to do both, so the exact language reserved interface actually depends on the writing of C + + aspect of the things of the people.


-------------------------------------
Here's a simple checklist to decide which development tool is most appropriate for your project:

Objectarx:

You have to feel that C and C + + are the most handy (translator note: Handy is a language for no reason like);

You need a lot of control over AutoCAD and many types of forms;

You need to customize the object;

You need access to something that you can't access with VBA and Lisp;

Your program needs to be more efficient (VBA and Lisp cannot be reached);

Your working environment requires programs developed in C or C + +;

You need to use some library functions outside of AutoCAD, which can only be called in C and C + +.


Vba:

You feel the most handy to use VBA programming;

You need to use a dialog box;

You need to exchange data with Windows or an Office application (such as Excel);

You beginner AutoCAD two times development, or beginner programming;

You need to complete the development of a program as soon as possible, and the efficiency of the program is not so important;

You know you need to get a lot of help from Autodesk during the development process.


Lisp:

The end of the world, there is no other tool optional (translator Note: You think VBA and ARX are not suitable for you);

You feel very handy with Lisp programming;

The program you want to develop runs on a previous version of AutoCAD 2000;

Your job involves something special, which can be achieved directly with Lisp, but it takes a lot of effort to achieve it with VBA;

You need it in your working environment;

Your working environment needs to use the existing Lisp function library;

You like to enjoy the pain (translator Note: There may be some personal emotional color of the author);

No dialog boxes or graphical user interfaces are required in your program except for command line and graphical objects;

Parens make You Happy (translator Note: Do not understand the meaning of this sentence, estimated that parens is familiar with the Lisp development of the name of the person), oh, look here, the man in the white coat came to see you.


-------------------------------------

Now I'm going to give you something that everyone here wants: the free Code (the translator's note: The author is still joking)! Of course, it's not until this is the reason you read this article, isn't it? So, since you've been through a lot of trouble reading the text above, I think I should give you some free code so maybe you'll come here next time. In the sample code for each development tool, I've given a way to edit the first editable property in a block reference, and you won't see the statement using the command line in the code, because I don't like to use those things. If you use "command" (Translator Note: the command function in Lisp, the SendCommand method in VBA, the Acedcommand function in Arx), you are not programming, at most, you are writing a script (translator Note: The script here refers to the language that interprets the execution , in a sense, it is a different thing to use "command" to actually ask the command line to interpret and execute the statement you provide.


Objectarx's code:------------------------
void Chngatt ()
{
Ads_name Entres;
Ads_point Ptres;
Acdbobjectid _id, _attid;
Acdbobjectiterator *pittr = NULL;
if (Acedentsel ("Select a Block Reference", Entres, ptres)! = rtnorm)
{
Selection failed
Return
}
Acdbgetobjectid (_id, entres);
Acdbobjectpointer PRef (_id,acdb::kforread);
if (Pref.openstatus ()!=acad::eok)
{
Open failed
Return
}
Pittr = Pref->attributeiterator ();
while (!pittr->done ())
{
_attid = Pittr->objectid ();
Acdbobjectpointer PAtt (_attid,acdb::kforwrite);
if (Patt.openstatus () ==acad::eok)
{
Patt->settextstring ("We changed this");
Break
}
Pittr->step ();
}
Delete pittr;
}
vba:--------------------------------------
Option Explicit
Sub Chngatt ()
Dim Objent as Acadobject
Dim ObjRef as Acadblockreference
Dim Varatts as Variant
Dim Objatt as Acadattributereference
Dim Emptypt as Variant
ThisDrawing.Utility.GetEntity objent, Emptypt, "Select Block:"
If objent.objectname = "Acdbblockreference" Then
Set ObjRef = objent
If Objref.hasattributes Then
Varatts = Objref.getattributes
Set Objatt = Varatts (0)
objatt.textstring = "We changed this"
End If
End If
End Sub
lisp:---------------------------------------
(Defun C:chngatt ()
(setq mainent (Entsel))
(Setq entlist (entget (Car mainent)))
(Setq Entatt (Entget (Entnext (CDR (assoc-1 entlist))))
(Setq entnewattval
(Subst (cons 1 "We changed this") (Assoc 1 entatt) Entatt)
)
(Entmod entnewattval)
(ENTUPD (car mainent))
(Princ)
)
< end of the full >

Choice of language

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.