Tutorials to .com

Tutorials to .com » Mechine » Autocad » Secondary development of the basic steps Solidworks

Secondary development of the basic steps Solidworks

Print View , by: iSee ,Total views: 17 ,Word Count: 1204 ,Date: Mon, 17 Aug 2009 Time: 4:06 AM

SW integration because the vb editor (more like VB6.0), the editor can be carried out with the secondary development of macro production. The use of macros to lay a good foundation for the establishment of a framework to streamline the development process. Macro recording with this method can also be fast to be SW of the operation command, which searches the whole than English to facilitate the API documentation. Objective: To use a simple example, to the novice on the secondary development of the most basic steps, so that no secondary development of the friends used to quickly get started. In this paper, the basic technology needs VB6, VB6 can read code, write the basic procedures will do.

Secondary development of the basic steps Solidworks

Picture not clear? Click here to view the image (larger).

The first step: recording macros

Running SW, the two methods in Figure start recording macro

Secondary development of the basic steps Solidworks

Picture not clear? Click here to view the image (larger).

Create a new cylinder, and then stop recording and save the file

Secondary development of the basic steps Solidworks

Picture not clear? Click here to view the image (larger).

Step two: create procedure

Use edit macros in VB editor Acer has just produced a document. interface is the same with VB6. Procedure did not last long, through the reading process, we found just two things - the creation of documents and code modeling to prepare for his own benefit.

Secondary development of the basic steps Solidworks

Picture not clear? Click here to view the image (larger).

Insert UserForm

Secondary development of the basic steps Solidworks

Great trust in the control toolbox drag a button control to the form, figure. The form and buttons, respectively, into the Caption property: "SW development based on the Second" and "array painting", so that the text window and the button we need to become the same again. Of course, you can also be written in other languages.

Secondary development of the basic steps Solidworks

The third step: organize code

First of all, save to prevent the debugging process brought about by the loss of Death.

The upper left corner and then double-base "project" window "module", we just established that macro, to display the code. In the "Sub main ()" to add the following line "Sub main ()", so that after the first run of the window you just created. Then select the "Sub main ()" to the last "end" of all are between the macro code, and shear. This macro code on the remaining three the following. (Dividing line of the statement above code will not move)

Secondary development of the basic steps Solidworks

Picture not clear? Click here to view the image (larger).

Double-click the project window "UserForm1", shows the creation of the window, and then double-click the button, VB will automatically create the button click event code:

Private Sub CommandButton1_Click ()

End Sub

We all just macro code to paste over. The meaning of the word through the order that we can judge, the former is used to create seven new components, we observed the first six, found that the creation of methods and SW linked to the installation location, so we use the following three common methods to create components to replace those code (forget the heroes who taught of the Ben Ben, sorry).

Set swApp = Application.SldWorks

Set Part = swApp.NewPart

Set Part = swApp.ActiveDoc

Continue down the reading, the purpose is to find the cylinder to create an order code. Order to determine the basis of the English meaning of the word, and then modeling the time we have done two things: the creation of the draft and tensile. In the following two command code: Part.CreateCircle and Part.FeatureManager.FeatureExtrusion, and then open the Help menu in the SW to help the theme API.

Secondary development of the basic steps Solidworks

Picture not clear? Click here to view the image (larger).

Search the usage of these two orders, so that we function in the macro editor taking the help of which we need to use the command code.

Secondary development of the basic steps Solidworks

Picture not clear? Click here to view the image (larger).

The fourth step: the preparation of procedures

The following things to do is programming, and Ben Ben procedures which make use of the cylinder, we find the model order to create a cylindrical array, the height of columns in accordance with the sinusoidal changes in the location of columns in a circle on. The idea is to use programming loop for computing the variable, and then the variable value will be paid to modeling parameters, to allow the establishment of the location of the cylinder model (round draft position) and height (the length of the tensile characteristics and direction of) change . Do not forget to save, and then run this macro. Code and the implementation of the results of macro code is as follows:

Secondary development of the basic steps Solidworks

Picture not clear? Click here to view the image (larger).


AutoCAD Tutorial Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.