ImageVerifierCode 换一换
格式:DOCX , 页数:73 ,大小:1.46MB ,
资源ID:12623997      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/12623997.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(Inventor二次开发入门.docx)为本站会员(b****2)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

Inventor二次开发入门.docx

1、Inventor二次开发入门Inventor二次开发入门课程1:开始接触InventorAPI,用VB.NET写一个最简单的插件,实现选择集的隐藏在本课中,你将开始写一个使用Autodesk Inventor API基于VB.NET隐藏所选组件的应用程序。演示视频(英文)演示代码lesson1_vb-net.zip (zip - 49Kb)lesson1_c-sharp.zip (zip - 73Kb)根据步骤来创建你的第一个插件1. Launch the Visual Basic Express development environment: Open Visual Basic 2010

2、Express using the Windows Start menu, selecting All Programs, then Microsoft Visual Studio 2010 Express, and then Microsoft Visual Basic 2010 Express. Note: You can also use Visual Basic 2008 Express with this guide. Projects for both 2010 and 2008 are provided.2. Open a class library project: Insid

3、e Visual Basic Express, on the File menu, click Open Project. Navigate to the subfolder of the supporting material you downloaded at the top of this guide called lesson1_VisualExpress2010 and open the VB.NET project contained within it by selecting the project file MyFirstInventorPlugin_Lesson1.vbpr

4、oj.3. Open the code: In the open project you will see a form with one button (if you dont see the Form, click on Form1.vb in the Solution Explorer frame in the upper right hand side). Right click on Form1 in the Solution Explorer and select View Code or just double click on the Form. 4. Add the code

5、: In the code window, type the code below into the Sub Button1_Click. (This is what runs when the button is clicked.) You may need to scroll down towards the bottom of the code to find the place to add the below code, looking for the words Add code for Lesson 1 here. To get the full experience of de

6、veloping with Visual Basic Express including the use of features such as IntelliSense we recommend you type the code from this guide rather than copying and pasting it. That said, if constrained for time you can also copy and paste into the Visual Basic Express code window, although this will reduce

7、 the experience you gain from working with the code directly.If _invApp.Documents.Count = 0 ThenMsgBox(Need to open an Assembly document) ReturnEnd IfIf _invApp.ActiveDocument.DocumentType _DocumentTypeEnum.kAssemblyDocumentObject Then MsgBox(Need to have an Assembly document active) ReturnEnd IfDim

8、 asmDoc As AssemblyDocumentasmDoc = _invApp.ActiveDocumentIf asmDoc.SelectSet.Count = 0 Then MsgBox(Need to select a Part or Sub Assembly) ReturnEnd IfDim selSet As SelectSetselSet = asmDoc.SelectSetTry Dim compOcc As ComponentOccurrence Dim obj As Object For Each obj In selSet compOcc = obj Debug.P

9、rint(compOcc.Name) compOcc.Visible = False NextCatch ex As Exception MsgBox(Is the selected item a Component?) MsgBox(ex.ToString() ReturnEnd Try5. Save the file: On the File menu, click Save All. 6. Build the project: The code you have written is in human readable form. To make the code readable by

10、 a computer, you will need to translate it or “build” it. Inside Visual Basic Express, in theDebugmenu, clickBuild Solutionto compile and build your plug-in.The “Build Success” message shows in status bar of the Visual Basic Express window if the code is successfully built. Thats it! You have just w

11、ritten your first plug-in for Autodesk Inventor. Lets run the plug-in to see what it does.Running the Plug-in1. Start Autodesk Inventor. (Note: When the plug-in is run it will start a new session of Inventor if one is not already open.) 2. Create or open an existing Inventor assembly:Either unzip th

12、e file Clutch_Bell_Simplified.zip, and open the Clutch_Bell_Simplified.iam assembly or within Inventor make sure you have an assembly of your choosing active. There are several types of document that can be created or worked with inside Inventor. The most commonly used document types are Part (.ipt)

13、, Assembly (.iam) and Drawing (.idw). Open a new assembly and place some parts using the standard Inventor user-interface.3. Run your plug-in with Inventor and allow the plug-in to communicate with Inventor: To make Visual Basic Express execute the code you have entered, select Start Debugging on th

14、e Debug menu (you can use the F5 key or click on the green arrow which looks like a “play” button on the Debugging toolbar). This will cause your form to be displayed. You may need to minimize VB Express to see both the form and Inventor.4. Work with the plug-in: Select one or more (by using the Ctr

15、l key) components in the assembly that is active inside Inventor and then click Button1 on the form to execute your code and hide the selected components. 5. To re-display the invisible components use the Inventor Assembly browser (you can identify them via their component icons, which should now be

16、 grayed out). In the browser, right-click on the invisible components and pick Visibility, making them visible once again.Congratulations! You have just written your first plug-in for Autodesk Inventor. You will be reviewing the code in detail in Lesson 3. Before you move on to the next lessons, let

17、 us go back to some of the things we skipped over earlier, starting with basic concepts about programming, and the benefits it can bring to your day-to-day work.Additional TopicsIntroduction to ProgrammingThe VB.NET code you have just executed that hides the selected components is only 30 lines long

18、 and more than half of the code that you entered into the project is doing error checking. The code that actually does the work can be narrowed down to these few lines of code:Dim asmDoc As AssemblyDocumentasmDoc = _invApp.ActiveDocumentDim selSet As SelectSetselSet = asmDoc.SelectSetDim compOcc As

19、ComponentOccurrenceDim obj As ObjectFor Each obj In selSet compOcc = obj compOcc.Visible = FalseNextAs you can see, a small amount of code can go a long way to simplify working with Inventor. Software programming allows you to capture the logic of a particular manual procedure once and then reap the

20、 benefits over and over again, every time you want to perform this functionality.What is Programming?A simple answer to this question is: Computer programming is the process of creating a sequence of instructions to tell the computer to do something. You can look at your program as a sequence of ins

21、tructions. During the course of the upcoming lessons, you will look at the various lines and blocks of code in the context of being instructions for a computer.If you were to explain what computers are to a young child, you might say: a computer is a tool that follows instructions you provide. Progr

22、amming is one way of giving instructions to the computer. Internally, a computer sees these instructions encoded as a series of numbers (also called machine code). The human-readable instructions you saw at the beginning of this lesson are called source code and the computer converts these instructi

23、ons into machine code which it can then read and execute. A sequence of such instructions (or code), written to perform a specific task, is called a program and a collection of such programs and related data is called software. Autodesk Inventor is one such software product.Source code can be writte

24、n in different languages, just as humans use different languages to communicate between ourselves. The language you will be using in this guide is called Visual Basic.NET (VB.NET).What is an API?API is the acronym for Application Programming Interface: the way a software programmer can communicate w

25、ith a software product. For instance, the Inventor API is the way programmers can work with Inventor, and establishes what functionality a software programmer can use within Inventor. Such as the Inventor API allows you to write instructions for Inventor to execute one after the other.Putting this s

26、lightly differently: commercial software companies, such as Autodesk, often distribute a set of libraries that you can use in your own program to interact with a particular software product, such as Autodesk Inventor, and extend its functionality. This set of libraries is known as the software produ

27、cts API. The type of program you write to interact with a software product and extend its functionality will depend upon how the API has been designed and what has been exposed (through APIs) for you to work with.What is a Plug-in?A software plug-in is a type of program module (or file) that adds fu

28、nctionality to a software product, usually in the form of a command automating a task or some customization of the products behavior. When you talk about a plug-in for Inventor and you will also hear the term AddIn or Application used for this product we mean a module containing code that makes use

29、of the Inventor API. The code can connect to Inventor to automate tasks, or be loaded by Inventor and used to adjust its behavior of Inventor under certain conditions, such as when a particular command is executed by the user of the plug-in. For terminology purposes, an Inventor AddIn would also be

30、considered a plug-in. An AddIn is a special kind of plug-in that automatically loads when Inventor is started, has high performance and appears to the user to be part of Inventor.课程2:帮助了解VisualStudio编程环境以及基本需要熟悉的方面In the previous lesson, you saw how you can increase productivity in Autodesk Inventor

31、 by implementing a plug-in built from a small amount of VB.NET code.You will probably have heard the terms COM and .NET from Lesson 1 with reference to programming with Inventor. Both COM and .NET are technologies that enable communication between software: if you are interested in learning more, yo

32、u will find information in the Additional Topics section here.You will now look more closely at what happened when you executed the code in the previous lesson.代码示例lesson2_vb-net.zip (zip - 19Kb)lesson2_c-sharp.zip (zip - 23Kb)What does it mean to “build” code?The code that you typed in to Visual Basic Express in Lesson 1 was a set of human-readable instructions (source code) that needed to be

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1