èæ¯
ç§ã¯åå¿è éçºè ã§ããããåŠæ ¡ãã¬ãã«ã®C ++ç¥èãCïŒã§ã®ããã°ã©ãã³ã°çµéšããããïŒ2幎ïŒãAutoCADã§ã®çµéšããŒãã§ãã
æè¿ã圌ãã¯å¢çèšç»ãäœæ/å€æŽãã察å¿ããMS Word / XMLããã¥ã¡ã³ããæºåããããã«èšèšãããLISP auto-cadããã°ã©ã ãå€æŽããããã«é Œã¿ãŸããããã°ãä¿®æ£ããæ°ããæ©èœãè¿œå ããŸãã
Lispã§ã®ããã°ã©ã ã®èªã¿ãããïŒå°ãªããšãç§ã«ãšã£ãŠã¯ïŒãæãŸããŠããã®ã§ãç§ã¯ãããããç解ããããèšèªã§æžãçŽãããšã«ããŸããã
ãªããªã ããªç§åäœã§é床ãäžããå¿ èŠã¯ãããŸããã§ãããC++ãã¹ãããããCïŒã§è§£æ±ºããŸãã
ãã®èšäºãæžããŠããã®ã¯ïŒ
1. Autocadã«ã€ããŠåŠãã ããšãæ£ã«é ã®äžã«å ¥ããŸãã
2.ç§ã®ããã«ãããããããªããã¥ã¡ã³ããèªã人ãå©ããããã
3.ãããªãã¯ééã£ãŠããŸããããããæ¹ãç°¡åã§è¯ãããªã©ã®ã³ã¡ã³ãæ å ±ãå ¥æããŠãã ããã
å§ããŸãããã ãã©ã°ã€ã³ãäœæããŸãã
ClassLibraryãã³ãã¬ãŒãã䜿çšããŠCïŒãããžã§ã¯ããäœæãã
ããã°ã©ã ãã©ã«ãã«ãã管çãããAutocad APIã©ã€ãã©ãªãžã®ãªã³ã¯ãè¿œå ããŸãã
ç§ã®å Žåãããã¯æ¬¡ã®ãšããã§ãã
CïŒ\ Program Files \ AutoCAD 2007 \ acdbmgd.dll
CïŒ\ Program Files \ AutoCAD 2007 \ acmgd.dll
äœããããã¯ã©ã¹ãäœæããŸãã
using Autodesk.AutoCAD.Runtime; using Autodesk.AutoCAD.ApplicationServices; namespace AutocadPlugin { public class test : IExtensionApplication { [CommandMethod("hello")] public void Helloworld() { var editor = Application.DocumentManager.MdiActiveDocument.Editor; editor.WriteMessage(" Autocad "); } public void Initialize() { var editor = Application.DocumentManager.MdiActiveDocument.Editor; editor.WriteMessage(" .."+Environment.NewLine); } public void Terminate() { } } }
IExtensionApplicationããã®ç¶æ¿ã¯ãªãã·ã§ã³ã§ãããAutocadã¯ã©ã€ãã©ãªå ã®ãã¹ãŠã®ãããªãã¯ã¯ã©ã¹ãèªåçã«ååŸããŸãããå ã»ã©è¿°ã¹ãããã«ãããé«éã«ãªããŸãã ããã«ãInitialize / Terminateãã©ã°ã€ã³ãå¶åŸ¡ã§ããŸãã
ã³ã³ãã€ã«ããautocadãå®è¡ããnetloadã³ãã³ãã§ãã©ã°ã€ã³ãããŒãããŸãïŒãããŒãžDLLéžæãŠã£ã³ããŠãéããŸãïŒ
ããã§ãhelloã³ãã³ããå ¥åãããšãäºæ³ãããå¿çãåŸãããŸãã
Autocadã¢ããªã±ãŒã·ã§ã³æ§é ïŒ
ç»é¢ã«è¡šç€ºããããã®ã ãšã³ãã£ãã£ããç¶æ¿ãããã°ã©ãã£ãã¯ãªããžã§ã¯ã
ç®ã«èŠããæ å ±ãªããžã§ã¯ãã«å ããŠã ã¬ã€ã€ãŒ ã ç·çš® ã 寞æ³ã¹ã¿ã€ã« ã è¡šã¹ã¿ã€ã«ãªã©ã®äžå¯èŠã®æ å ±ãªããžã§ã¯ãããããŸãã
ããã¯ãã¹ãŠã ããŒã¿ããŒã¹ããŒãã«ã¬ã³ãŒã ã TYPETableã¿ã€ããªããžããªããã³TYPETableRecordã¿ã€ãã¯ã©ã¹ã«æ ŒçŽãããŸã ã
ãªããžã§ã¯ãèå¥å
- ObjectId ãENameïŒãšã³ãã£ãã£åïŒãšãåŒã°ããŸãã ç»åãéãããšãã«äœæãããçªå·ã
䜿çšæ³-1ã€ã®ã»ãã·ã§ã³äžã®ããŒã¿ããŒã¹å ã®ãªããžã§ã¯ãã®èå¥ããªããžã§ã¯ãã¯ããã®ObjectIdã«ãã£ãŠããŒã¿ããŒã¹ããèŠæ±ãããŸã
çºèŠããšã«ç°ãªãå ŽåããããŸãããªããžã§ã¯ããžã®ãªã³ã¯ãä¿åããããã«äœ¿çšããªãããšããå§ãããŸã
- ãã³ãã« -ææžã®ç°ãªãéå£éšã®éã§å€åããªãæ°;ãã¡ã€ã«ãä¿åãããšãã«ãªããžã§ã¯ãéã®é¢ä¿ãç¶æããããã«ããã䜿çšãããšäŸ¿å©ã§ãã
è©³çŽ°ïŒ ãã³ãã«ã¯AutoCADã»ãã·ã§ã³éã§æ°žç¶çã§ãããããåŸã§å³é¢ã®æŽæ°ã«äœ¿çšããå¿ èŠã®ããå€éšãã¡ã€ã«ã«å³é¢æ å ±ããšã¯ã¹ããŒãããå¿ èŠãããå Žåããªããžã§ã¯ãã«ã¢ã¯ã»ã¹ããæè¯ã®æ¹æ³ã§ãã ããŒã¿ããŒã¹å ã®ãªããžã§ã¯ãã®ObjectIdã¯ãããŒã¿ããŒã¹ãã¡ã¢ãªã«ããŒããããŠããéã®ã¿ååšããŸãã ããŒã¿ããŒã¹ãéãããããšããªããžã§ã¯ãã«å²ãåœãŠããããªããžã§ã¯ãIDã¯ååšããªããªãã次åããŒã¿ããŒã¹ãéãããšãã«ç°ãªãå¯èœæ§ããããŸãã
ããŒã¿ããŒã¹ãæäœãã
éåžžãããŒã¿ããŒã¹ã®æäœã¯ãã©ã³ã¶ã¯ã·ã§ã³ã䜿çšããŠè¡ãããŸãã ãªããžã§ã¯ããããŒã¿ããŒã¹ããèŠæ±ãããå€æŽãããã³ããããã©ã³ã¶ã¯ã·ã§ã³ãä¿åãããŸãã
ãã©ã³ã¶ã¯ã·ã§ã³äžã3ã€ã®ForReadãForWriteãForNotifyã¢ãŒãã®ããããã§ããŒã¿ããŒã¹ãããªããžã§ã¯ããèŠæ±ãããŸãã
æåã®2ã€ã®ç®çã¯æããã§ããã3çªç®ã¯äœããã®åœ¢ã§ã€ãã³ãã®ã¡ã«ããºã ã«äœ¿çšãããŸãã
ForWriteã¢ãŒãã§ã¯ãautocadã¯ãã©ã³ã¶ã¯ã·ã§ã³å ã®å€æŽãç Žæ£ã§ããè¿œå ã®ãªããžã§ã¯ããäœæããŸãã
ãForReadããšããŠéããããªããžã§ã¯ããå€æŽããå Žåããã®UpgradeOpenïŒïŒã¡ãœãããåŒã³åºãããŸãã
æ¢ã«å€æŽã¢ãŒãã§éããŠãããªããžã§ã¯ãã§ãã®ã¡ãœãããåŒã³åºããšãã¡ãœããã¯äŸå€ãã¹ããŒããŸãã
ObjectIdã«ãã£ãŠPolylineãªããžã§ã¯ããååŸããäŸ
// UPDATE: , . , UpgradeOpen , .. public static Polyline GetPolylineByEname(ObjectId ename) { if (ename == ObjectId.Null) return null; Polyline polyline = null; var db = Application.DocumentManager.MdiActiveDocument.Database; using (var transaction = db.TransactionManager.StartTransaction()) { return transaction.GetObject(ename, OpenMode.ForRead) as Polyline; } }
ãã©ã³ã¶ã¯ã·ã§ã³ã¯ãã¹ãã§ããæäžäœã®ãã©ã³ã¶ã¯ã·ã§ã³ããã£ã³ã»ã«ããããšããã¹ãŠã®åããã£ã³ã»ã«ãããŸãã
æåã¯ãé·ãéããšã©ãŒã®å Žæãç¹å®ã§ããŸããã§ãããç»åã®å€æŽã¯ä¿åãããŸããã§ããã çµå±ã®ãšãããç§ã¯äžã®ãã©ã³ã¶ã¯ã·ã§ã³ãéããã®ãå¿ããŠããŸããã
ã€ã©ã¹ã
public void OwnerTransFunction() { var db = Application.DocumentManager.MdiActiveDocument.Database; using (var transaction = db.TransactionManager.StartTransaction()) { // ChangePolylineInChildTransation() } } public void ChangePolyline() { var db = Application.DocumentManager.MdiActiveDocument.Database; using (var transaction = db.TransactionManager.StartTransaction()) { // // transaction.Commit(); // , Commit'a } }
æŽæ°ïŒã³ã¡ã³ãã§ç€ºåãããŠããããã«ããã©ã³ã¶ã¯ã·ã§ã³ããã£ã³ã»ã«ããå¿ èŠãããå Žåãé€ããŠãåžžã«transaction.CommitïŒïŒãåŒã³åºãããšããå§ãããŸãã ãã©ã³ã¶ã¯ã·ã§ã³ãã³ããããããŠããªãå Žåãtransaction.AbortïŒïŒãèªåçã«åŒã³åºãããè¿œå ã®ã³ã¹ããçºçããŸãã
èŸæž
äžèŠãªãã¡ã€ã«ãäœæããªãããã«ãèŸæžã䜿çšããŠããŒã¿ãDWGã«ä¿åããŸãã
å³é¢ã§2çš®é¡ã®èŸæž-NamedObjectDictionaryãšExtensionDictionaryã« åºäŒããŸãã
èŸæžã®ããŒã¿ã¯ã¬ã³ãŒãïŒã¬ã³ãŒãïŒã«æ ŒçŽãããã¬ã³ãŒãã«ã¯åä»ãã®å€ãæ ŒçŽãããŸãã
ããã¹ãããŒã®ããŒã¿ãã¢ãã¬ã¹æå®ããŸãã
NamedObjectDictionary-ã°ããŒãã«ãªæç»èŸæžã ããã¥ã¡ã³ãã®äœææã«èªåçã«çæãããŸãã
䜿çšããã¡ã€ã³ãªããžã§ã¯ããžã®ãªã³ã¯ãä¿åããããã«äœ¿çšããŸããã
ExtensionDictionary-åãªããžã§ã¯ãã®èŸæžãæåã§äœæããå¿ èŠããããŸãã
entity.ExtensionDictionaryãã£ãŒã«ããObjectId.Nullãšæ¯èŒããããšã«ããããã®ååšã確èªã§ããŸãã
ExtensionDictionaryããæååå€ãæžã蟌ãã§ååŸããäŸ
public static void SetExtDictionaryValueString(ObjectId ename, string key, string value) { if (ename == ObjectId.Null) throw new ArgumentNullException("ename"); if (String.IsNullOrEmpty(key)) throw new ArgumentNullException("key"); var doc = Application.DocumentManager.MdiActiveDocument; using (var transaction = doc.Database.TransactionManager.StartTransaction()) { var entity = transaction.GetObject(ename, OpenMode.ForWrite); if (entity == null) throw new DataException(" ExtensionDictionary: entity ObjectId=" + ename + " "); // extDictionary var extensionDictionaryId = entity.ExtensionDictionary; if (extensionDictionaryId == ObjectId.Null) { entity.CreateExtensionDictionary(); extensionDictionaryId = entity.ExtensionDictionary; } var extDictionary = (DBDictionary) transaction.GetObject(extensionDictionaryId, OpenMode.ForWrite); // if (String.IsNullOrEmpty(value)) { if (extDictionary.Contains(key)) extDictionary.Remove(key); return; } var xrec = new Xrecord(); xrec.Data = new ResultBuffer(new TypedValue((int) DxfCode.ExtendedDataAsciiString, value)); extDictionary.SetAt(key, xrec); transaction.AddNewlyCreatedDBObject(xrec, true); Debug.WriteLine(entity.Handle+"['" + key + "'] = '" + value + "'"); transaction.Commit(); } } public static string GetExtDictionaryValueString(ObjectId ename, string key) { if (ename == ObjectId.Null) throw new ArgumentNullException("ename"); if (String.IsNullOrEmpty(key)) throw new ArgumentNullException("key"); var doc = Application.DocumentManager.MdiActiveDocument; using (var transaction = doc.Database.TransactionManager.StartTransaction()) { var entity = transaction.GetObject(ename, OpenMode.ForRead); if (entity == null) throw new DataException(" ExtensionDictionary: ObjectId=" + ename + " "); var extDictionaryId = entity.ExtensionDictionary; if (extDictionaryId == ObjectId.Null) throw new DataException(" ExtensionDictionary: "); var extDic = (DBDictionary)transaction.GetObject(extDictionaryId, OpenMode.ForRead); if (!extDic.Contains(key)) return null; var myDataId = extDic.GetAt(key); var readBack = (Xrecord)transaction.GetObject(myDataId, OpenMode.ForRead); return (string)readBack.Data.AsArray()[0].Value; } }
ã°ããŒãã«ãã£ã¯ã·ã§ããªã®æäœã¯ã»ãšãã©åãã§ãDBDictionaryãªããžã§ã¯ãã®ã¿ã次ã®ããã«ååŸãããŸãã
var dictionary = (DBDictionary) transaction.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForWrite);
ç§ã¯ä»ã«äœã«ééããŸãã
1.ãã©ã°ã€ã³ã®èµ·å
ãã©ã°ã€ã³ã®5ç§éã®ãã§ãã¯ã®ããã«netloadãæ°ååå
¥åããåŸãç§ã¯ããã«ããããããæé ãç°¡çŽ åããæ¹æ³ãæ¢ãå§ããŸããã
æ€çŽ¢äžã«ã.NETãã©ã°ã€ã³ã®èªåèªã¿èŸŒã¿ã«é¢ããèšäºã«åºäŒããŸããã èŠããã«ãã¬ãžã¹ããªã«ããŒãè¿œå ããå¿ èŠããããŸã
説æïŒ
R17.0-Autocad 2007
ãã·ã¢èªçã®å Žåã¯419
è±èªçã®å Žåã¯409
GeocomplexPlugin-äœæãããããŒãã£ã·ã§ã³
LOADCTRLS = 2-èµ·åæã«AutoCADãããŒãããŸãã ç¹å®ã®ããŒã䜿çšããŠãªã³ããã³ãã§èµ·åã§ããŸãããã©ã°ã€ã³ã¯ãã³ãã³ãã®1ã€ãå ¥åããããšããŒããããŸãã
ããŒããŒ-ãã©ã°ã€ã³ãžã®ãã¹
æ€çŽ¢äžã«ã.NETãã©ã°ã€ã³ã®èªåèªã¿èŸŒã¿ã«é¢ããèšäºã«åºäŒããŸããã èŠããã«ãã¬ãžã¹ããªã«ããŒãè¿œå ããå¿ èŠããããŸã
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\AutoCAD\R17.0\ACAD-5001:419\Applications\GeocomplexPlugin] "LOADCTRLS"=dword:00000002 "MANAGED"=dword:00000001 "LOADER"="C:\\GeoComplexAutocadPlugin\\AutocadGeocomplexPlugin.dll"
説æïŒ
R17.0-Autocad 2007
ãã·ã¢èªçã®å Žåã¯419
è±èªçã®å Žåã¯409
GeocomplexPlugin-äœæãããããŒãã£ã·ã§ã³
LOADCTRLS = 2-èµ·åæã«AutoCADãããŒãããŸãã ç¹å®ã®ããŒã䜿çšããŠãªã³ããã³ãã§èµ·åã§ããŸãããã©ã°ã€ã³ã¯ãã³ãã³ãã®1ã€ãå ¥åããããšããŒããããŸãã
ããŒããŒ-ãã©ã°ã€ã³ãžã®ãã¹
2.ãããã° ãªããªã ãã©ã°ã€ã³ã§ã¯ãVSã§æ®µéçãªãããã°ãéå§ããããšã¯äžå¯èœã§ãããããããã€ãã®æ®µéã§ãããã°ã¡ãã»ãŒãžã衚瀺ããå¿
èŠããããŸããã
ãã®ç®çã®AutoCADã®ãšãã£ã¿ãŒã¯äœ¿çšããã®ãäžäŸ¿ãªã®ã§ãæšæºã®Debug.WriteMessageïŒïŒããŒã«ã䜿çšããŠã¡ãã»ãŒãžãåºåããŸã
ãããã°ã¯ããããã°ã¢ãŒãã§ã³ã³ãã€ã«ããå Žåã«ã®ã¿è¡šç€ºãããŸããåºåããŒã¿ã¯ãDebugViewããã°ã©ã ãå®è¡ããŠè¡šç€ºã§ããŸãã
æŽæ°ïŒæ®µéçãªãããã°ã®åé¡ã解決ããŸããïŒ
ãã®æ¹æ³ã§ãã®åé¡ãæã¡è² ãããŸããïŒ
autocadæ§æãã¡ã€ã«ã§ãacad.exe.configã¯v4.0ã«ã©ã³ã¿ã€ã ãã€ã³ã¹ããŒã«ããŸããã
ãã©ã°ã€ã³ã©ã³ã¿ã€ã ã4.0ã¯ã©ã€ã¢ã³ããããã¡ã€ã«ã«å€æŽããŸãã
ãŸããã¢ã»ã³ããªèšå®AssemblyInfo.csã¯å±æ§AllowPartiallyTrustedCallersãã³ã¡ã³ãã¢ãŠãããŸãã
æŽæ°ïŒæ®µéçãªãããã°ã®åé¡ã解決ããŸããïŒ
ãã®æ¹æ³ã§ãã®åé¡ãæã¡è² ãããŸããïŒ
autocadæ§æãã¡ã€ã«ã§ãacad.exe.configã¯v4.0ã«ã©ã³ã¿ã€ã ãã€ã³ã¹ããŒã«ããŸããã
<configuration> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0"/> </startup> <runtime> <generatePublisherEvidence enabled="false"/> </runtime> </configuration>
ãã©ã°ã€ã³ã©ã³ã¿ã€ã ã4.0ã¯ã©ã€ã¢ã³ããããã¡ã€ã«ã«å€æŽããŸãã
ãŸããã¢ã»ã³ããªèšå®AssemblyInfo.csã¯å±æ§AllowPartiallyTrustedCallersãã³ã¡ã³ãã¢ãŠãããŸãã
3.ãšãã£ã¿ãŒã§ã³ãã³ããéä¿¡ãã
äžéšã®ã¢ã¯ã·ã§ã³ã¯ãAutocad .NET APIã«å®è£
ãããŠããªãããã³ãã³ãã©ã€ã³ã§å®è¡ããæ¹ãã¯ããã«ç°¡åã§ãã
ã³ãã³ããå®è¡ããæãç°¡åãªæ¹æ³ã¯ãZoomExtentsã®äŸã§ããé¢æ°ãå®è¡ããããšã§ãã
AutoCADã§ã¯ãã¹ããŒã¹ã¯Enterã«çžåœããŸãããã®ãããæ«å°Ÿã®ã¹ããŒã¹ãªãã§ã³ãã³ããéä¿¡ãããšã_eãeditor'eã«å ¥åãããããã«å ¥åãåŸ ã€ããšã«ãªããŸãã
ãã ãããã®æ¹æ³ã¯åžžã«äœ¿çšã§ãããšã¯éããŸããã SendStringToExecuteã³ãã³ãã®ååã¯ãã³ãã³ãã«ãã£ãŠåŒã³åºãããé¢æ°ãå®äºããåŸã«ã®ã¿ã³ãã³ããéä¿¡ããããšããããšã§ãã ãããã£ãŠãæåã«ãã®ã³ãã³ããåŒã³åºããŠãããããšãã°ããŠãŒã¶ãŒãå³å ã®ãªããžã§ã¯ããéžæããããã«èŠæ±ãããšã2è¡ãéžæé¢æ°ã_zoomããã_ eãã«éä¿¡ããã誀ã£ããªããžã§ã¯ããšããŠèªèãããŸãã
ããã«å®è¡ãããã¢ããã°ãæ¢ãå¿ èŠããããŸãã ãã®å ŽåïŒ
ã³ãã³ããå®è¡ããæãç°¡åãªæ¹æ³ã¯ãZoomExtentsã®äŸã§ããé¢æ°ãå®è¡ããããšã§ãã
var doc = Application.DocumentManager.MdiActiveDocument; doc.SendStringToExecute("_zoom _e ",false,false,true);
AutoCADã§ã¯ãã¹ããŒã¹ã¯Enterã«çžåœããŸãããã®ãããæ«å°Ÿã®ã¹ããŒã¹ãªãã§ã³ãã³ããéä¿¡ãããšã_eãeditor'eã«å ¥åãããããã«å ¥åãåŸ ã€ããšã«ãªããŸãã
ãã ãããã®æ¹æ³ã¯åžžã«äœ¿çšã§ãããšã¯éããŸããã SendStringToExecuteã³ãã³ãã®ååã¯ãã³ãã³ãã«ãã£ãŠåŒã³åºãããé¢æ°ãå®äºããåŸã«ã®ã¿ã³ãã³ããéä¿¡ããããšããããšã§ãã ãããã£ãŠãæåã«ãã®ã³ãã³ããåŒã³åºããŠãããããšãã°ããŠãŒã¶ãŒãå³å ã®ãªããžã§ã¯ããéžæããããã«èŠæ±ãããšã2è¡ãéžæé¢æ°ã_zoomããã_ eãã«éä¿¡ããã誀ã£ããªããžã§ã¯ããšããŠèªèãããŸãã
ããã«å®è¡ãããã¢ããã°ãæ¢ãå¿ èŠããããŸãã ãã®å ŽåïŒ
object acad = Application.AcadApplication; acad.GetType().InvokeMember("ZoomExtents", BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod, null, acad, null);
4.ãªããžã§ã¯ãã®ãŠãŒã¶ãŒéžæ
ãªããžã§ã¯ããéžæããã«ã¯ãeditor'a Get *é¢æ°ã䜿çšããŸã
ããšãã°ãè€æ°ã®ãªããžã§ã¯ãã®éžæ-GetSelectionã1ã€ã®GetEntityã®éžæ...
ããšãã°ãè€æ°ã®ãªããžã§ã¯ãã®éžæ-GetSelectionã1ã€ã®GetEntityã®éžæ...
var editor = Application.DocumentManager.MdiActiveDocument.Editor; var promtResult = editor.GetEntity(" "); editor.WriteMessage(Environment.NewLine); if (promtResult.Status == PromptStatus.OK) { editor.WriteMessage("Selected Object's ID: " + promtResult.ObjectId+Enviropment.NewLine); }
ããã¥ã¡ã³ããã©ã«ããŒãžã®ãã¹ãååŸãã
ã€ã³ã¿ãŒãããã§æ€çŽ¢ãããšãå®å
šãªãã¡ã€ã«åã«ã¢ã¯ã»ã¹ãã2ã€ã®æ¹æ³ãçæãããŸããã
MdiActiveDocument.Database.Filename
MdiActiveDocument.Name
äžèŠããããã¯åãã§ããã
æšæºã®.NETããŒã«ã䜿çšããŠããã©ã«ããŒãžã®ãã¹ãååŸããŸããã
Path.GetDirectoryNameïŒApplication.DocumentManager.MdiActiveDocument.NameïŒ;
è¿ãããæååã空ã®å Žåãããã¥ã¡ã³ãã¯äœæãããŸããä¿åãããŸãã
MdiActiveDocument.Database.Filename
MdiActiveDocument.Name
äžèŠããããã¯åãã§ããã
ãããã¯ã«ã€ããŠ-Database.Filenameããããã£ã®äœ¿çšã¯ãå§ãããŸããã èªåä¿ååŸããã¡ã€ã«èªäœã§ã¯ãªããèªåä¿åã³ããŒã瀺ããŸã-Document.Nameãšã¯ç°ãªããŸã
æšæºã®.NETããŒã«ã䜿çšããŠããã©ã«ããŒãžã®ãã¹ãååŸããŸããã
Path.GetDirectoryNameïŒApplication.DocumentManager.MdiActiveDocument.NameïŒ;
è¿ãããæååã空ã®å Žåãããã¥ã¡ã³ãã¯äœæãããŸããä¿åãããŸãã
ãããŠãããã«äŸ¿å©ãªã³ãŒãã¹ããããïŒ
ããªã©ã€ã³åº§æšã®å€æŽïŒå»¶é·æ¹æ³ïŒ
// ( ): public static void UpdatePoints(this Polyline polyline, List<Point2d> newPoints) { if (polyline == null) throw new ArgumentNullException("polyline"); if (newPoints.Count < 2) throw new ArgumentException(" "); using (var transaction = Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction()) { // , var pline = transaction.GetObject(polyline.ObjectId,OpenMode.ForWrite) as Polyline; if (pline == null) throw new DataException("! "); var bulge = pline.GetBulgeAt(0); var start_width = pline.GetStartWidthAt(0); var end_width = pline.GetEndWidthAt(0); var prevPointsCount = pline.NumberOfVertices; // // , , .. Autocad 0 1 // for (int i = prevPointsCount; i < prevPointsCount + newPoints.Count; i++) pline.AddVertexAt(i, newPoints[i - prevPointsCount], bulge, start_width, end_width); // for (int i = prevPointsCount - 1; i >= 0; i--) pline.RemoveVertexAt(i); transaction.Commit(); } }
ããªã©ã€ã³ã®åº§æšãååŸããïŒæ¡åŒµã¡ãœããïŒïŒ
// ( ): public static Point2d[] GetPoints(this Polyline polyline) { if (polyline == null) { Debug.WriteLine(" ! "); return null; } if (polyline.NumberOfVertices == 0) return null; var points = new List<Point2d>(); for (int i = 0; i < polyline.NumberOfVertices; i++) points.Add(polyline.GetPoint2dAt(i)); return points.ToArray(); }
䟿å©ãªãªã³ã¯
1. AutoCAD .NETéçºè ã¬ã€ã
è±èªã®ãããªãã¡ã¬ã³ã¹ã¯ãVB.NETãCïŒ.NETãVBAã®ã³ãŒããµã³ãã«ã§Autocadããã€ã¹ã®æ¬è³ªã説æããŠããŸã
2. ã€ã³ã¿ãŒãã§ã€ã¹ãä»ããŠ
Kean Walmsleyã®ããã°ãå€ãã®Howtoã CïŒãCïŒ+ COMãVB.NETãC ++ã®äŸããããŸãã ããã§æ€çŽ¢ããããšã¯ã§ããŸããããGoogleããã®ãªã¯ãšã¹ãã®ååã§ããããããè¡ãæ¹æ³ãã¯ããã®ãµã€ãã«ã€ãªãããŸãã
3. caduser.ruããµããã©ãŒã©ã ã.NETã
ãããã¯ã«ç²ŸéããŠãããã·ã¢èªã話ã人ã ãšã®ã³ãã¥ãã±ãŒã·ã§ã³ã å€ãã®å Žåãå°é£ãªå Žæãç解ããã®ã«åœ¹ç«ã¡ãŸãã