• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            C++ Programmer's Cookbook

            {C++ 基礎(chǔ)} {C++ 高級(jí)} {C#界面,C++核心算法} {設(shè)計(jì)模式} {C#基礎(chǔ)}

            Autodesk CAD實(shí)體集合另存為小工具

            一,使用Autodesk CAD的二次開發(fā)技術(shù)ObjectARX(依賴與Autodesk CAD)。其中有c++和C#版,這里使用C#版。

            二,生成的dll(C#)或arx(c++),必須被拷貝到ACAD的目錄下,且在ACAD中使用命令netload或appload加載生成的dll或arx,加載后我們?cè)贏CAD中輸入我們的命令即可。(下面小程序的命令是SaveDwg

            三,小程序的功能是選取ACAD中打開的dwg圖紙上的一些內(nèi)容,然后保存為另一張dwg圖紙。

            四,c#的代碼如下,比較簡(jiǎn)單,只考慮了簡(jiǎn)單的情況。

            using System;
            using System.Collections.Generic;
            using System.Text;
            using System.Windows.Forms;
            using System.Collections;

            using Autodesk.AutoCAD.Runtime;
            using Autodesk.AutoCAD.DatabaseServices;
            using Autodesk.AutoCAD.EditorInput;
            using Autodesk.AutoCAD.ApplicationServices;

            namespace SaveDwg
            {
                
            public class Program
                
            {   
             
                    [CommandMethod(
            "SaveDwg")]   
                    
                    
            public void SaveDwg()
                    
            {
                        
            try
                        
            {

                            Database db 
            = HostApplicationServices.WorkingDatabase;

                            SelectionSet selectionset;
                            ArrayList setList 
            = new ArrayList();

                            Editor ed 
            = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
                            ed.WriteMessage(
            "welcome to use the tool, it can save as a dwg file for your selected entities.\n");
                            PromptSelectionOptions selectionOptions 
            = new PromptSelectionOptions();
                            PromptSelectionResult selectionResult;
                            selectionResult 
            = ed.GetSelection(selectionOptions);
                            
            if (selectionResult.Status != PromptStatus.OK)
                            
            {
                                ed.WriteMessage(
            "select error, please use command again.\n");
                                
            return;
                            }

                            
            else
                            
            {
                                selectionset 
            = selectionResult.Value;
                                
            foreach (ObjectId id in selectionset.GetObjectIds())
                                
            {
                                    DBObject ob 
            = id.Open(OpenMode.ForRead);
                                    Entity ent 
            = ob as Entity;
                                    
            if (ent != null)
                                    
            {
                                        Entity ent2 
            = ent.Clone() as Entity;
                                        setList.Add(ent2);
                                        ed.WriteMessage(
            "copying entity is successful.\n");
                                    }
                                    
                                    ob.Close();
                                }

                            }

                            ed.WriteMessage(
            "select and copy successfully.\n");

                            Database Db 
            = new Database(truefalse);
                            HostApplicationServices.WorkingDatabase 
            = Db;
                            Autodesk.AutoCAD.DatabaseServices.TransactionManager manager 
            = Db.TransactionManager;
                            
            using (Transaction transaction = manager.StartTransaction())
                            
            {
                                BlockTable table 
            = (BlockTable)manager.GetObject(Db.BlockTableId, OpenMode.ForWrite);
                                BlockTableRecord record 
            = (BlockTableRecord)manager.GetObject(Db.CurrentSpaceId, OpenMode.ForWrite);

                                
            foreach (Object obj in setList)
                                
            {
                                    Entity ent 
            = obj as Entity;
                                    
            if (ent != null)
                                    
            {
                                        record.AppendEntity(ent);
                                        
            //manager.AddNewlyCreatedDBObject(ent,true);
                                    }


                                }

                                record.Close();
                                table.Close();
                                transaction.Commit();
                            }


                            SaveFileDialog dialog 
            = new SaveFileDialog();
                            
            string filePath;
                            
            if (DialogResult.OK == dialog.ShowDialog())
                            
            {
                                filePath 
            = dialog.FileName;
                                Db.SaveAs(filePath, DwgVersion.Current);
                            }

                            
                        }

                        
            catch(System.Exception e)
                        
            {
                            MessageBox.Show(
            "copy fail");
                        }

                    }

                }

            }


            五,記得要reference ObjectARX程序需要的dll哦,如下圖:

            六,想要脫離AutodeskCAD處理dwg圖紙,需要使用ObjectDBX技術(shù),最新版改名為realdwg技術(shù)。

            posted on 2007-05-24 15:04 夢(mèng)在天涯 閱讀(3213) 評(píng)論(7)  編輯 收藏 引用 所屬分類: ARX/DBX

            評(píng)論

            # re: Autodesk CAD實(shí)體集合另存為小工具 2007-05-24 15:08 夢(mèng)在天涯

            命令是:SaveDwg  回復(fù)  更多評(píng)論   

            # re: Autodesk CAD實(shí)體集合另存為小工具 2007-05-25 15:24 ethan

            持續(xù)關(guān)注你的文章   回復(fù)  更多評(píng)論   

            # re: Autodesk CAD實(shí)體集合另存為小工具 2008-03-16 19:23

            夢(mèng)在天涯?你好,看了你的關(guān)于“Autodesk CAD實(shí)體集合另存為小工具”文章很興趣,因?yàn)槲易瞿>咴O(shè)計(jì),經(jīng)常需要將一個(gè)圖中的單個(gè)圖拷貝給別人線割,如果有了你的那個(gè)savedwg,工作為方便好多,但是我又不會(huì)C++,能否將編譯后的arx文件發(fā)給我,另外,如果能給個(gè)視頻教程,本人將更感激!謝謝了!我的郵箱是:guoling0412@163.com  回復(fù)  更多評(píng)論   

            # re: Autodesk CAD實(shí)體集合另存為小工具 2012-01-06 12:45 RoseMorton25

            A lot of specialists argue that <a href="http://goodfinance-blog.com/topics/personal-loans">personal loans</a> aid a lot of people to live their own way, just because they are able to feel free to buy needed stuff. Furthermore, a lot of banks offer commercial loan for different classes of people.   回復(fù)  更多評(píng)論   

            # re: Autodesk CAD實(shí)體集合另存為小工具 2012-01-13 08:13 essay paper

            You can ask if that is a fair to buy essay papers. I claim that's a natural stuff to use academic writing corporations to reach your goal.   回復(fù)  更多評(píng)論   

            # re: Autodesk CAD實(shí)體集合另存為小工具 2012-01-13 08:15 Research paper references

            Do you know people who can help with Research paper made easy accomplishing? I will surely pay cash for such a help.   回復(fù)  更多評(píng)論   

            # re: Autodesk CAD實(shí)體集合另存為小工具 2013-07-31 09:21 visit this website

            Want to buy CV? Have no idea where to buy resume paper? Select this site where you can find resume templates. Our certified resume writers will assure you that buying resume can bring job seekers career success!  回復(fù)  更多評(píng)論   

            # re: Autodesk CAD實(shí)體集合另存為小工具 2013-07-31 09:52 Web page

            Desire to learn about essay writing services? Seeking for trusty organization to get aid from? PremiumQualityEssays rewiew will give you a list of firms from which students may select the most qualified ones to order paper from.  回復(fù)  更多評(píng)論   

            公告

            EMail:itech001#126.com

            導(dǎo)航

            統(tǒng)計(jì)

            • 隨筆 - 461
            • 文章 - 4
            • 評(píng)論 - 746
            • 引用 - 0

            常用鏈接

            隨筆分類

            隨筆檔案

            收藏夾

            Blogs

            c#(csharp)

            C++(cpp)

            Enlish

            Forums(bbs)

            My self

            Often go

            Useful Webs

            Xml/Uml/html

            搜索

            •  

            積分與排名

            • 積分 - 1811122
            • 排名 - 5

            最新評(píng)論

            閱讀排行榜

            国产欧美久久久精品影院| 精品久久久久久久久免费影院| 亚洲午夜久久久久久久久电影网| 精品国产热久久久福利| 久久精品无码一区二区WWW| 精品多毛少妇人妻AV免费久久| 久久精品国产免费观看三人同眠| 久久w5ww成w人免费| 久久久久久久亚洲Av无码| 精品免费tv久久久久久久| 香港aa三级久久三级老师2021国产三级精品三级在| 亚洲人成电影网站久久| 人妻无码久久一区二区三区免费 | 久久久久女教师免费一区| 久久精品国产亚洲av麻豆蜜芽| 中文字幕精品无码久久久久久3D日动漫 | 久久婷婷综合中文字幕| 久久国产精品无码一区二区三区| 久久免费视频一区| 无码精品久久一区二区三区| 无码人妻久久久一区二区三区| 久久九九久精品国产免费直播| 国产日产久久高清欧美一区| 丁香五月综合久久激情| 久久A级毛片免费观看| 性欧美大战久久久久久久久| 日韩精品久久久久久久电影| 久久综合九色综合久99| 日本精品久久久中文字幕| 亚洲va国产va天堂va久久| 久久99精品久久久大学生| 久久夜色撩人精品国产小说| 国产精品无码久久四虎| 精品久久久久久久久午夜福利| 精品久久久久久国产| 思思久久好好热精品国产| 亚洲综合婷婷久久| 国产99久久久国产精免费| 久久中文娱乐网| 香蕉久久久久久狠狠色| 日韩欧美亚洲国产精品字幕久久久|