12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
-
- using GrxCAD.Runtime;
- using GrxCAD.Geometry;
- using GrxCAD.DatabaseServices;
- using GrxCAD.ApplicationServices;
- using GrxCAD.EditorInput;
- using GrxCAD.Internal;
- using System.Windows.Forms;
-
- namespace HCTools
- {
- class BasicFunction
- {
- /// <summary>
- /// 根据点坐标创建圆形标记
- /// </summary>
- public void makeflag(double x, double y, double z, double radius, string layername)
- {
- Database database = HostApplicationServices.WorkingDatabase;
- DocumentLock doclock = GrxCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
- using (Transaction traction = database.TransactionManager.StartTransaction())
- {
-
- BlockTable blocktable = traction.GetObject(database.BlockTableId,
- OpenMode.ForWrite) as BlockTable;
-
- BlockTableRecord blocktablerecord = traction.GetObject(blocktable[BlockTableRecord.ModelSpace],
- OpenMode.ForWrite) as BlockTableRecord;
- Circle circ = new Circle();
- circ.Center = new Point3d(x, y, z);
- circ.Radius = radius;
- circ.Normal = new Vector3d(0, 0, 1);
- circ.SetDatabaseDefaults();
- circ.Layer = layername;
- blocktablerecord.AppendEntity(circ);
- traction.AddNewlyCreatedDBObject(circ, true);
- traction.Commit();
-
- doclock.Dispose();
- traction.Dispose();
- }
-
- }
-
-
- /// <summary>
- /// 获取等高线
- /// </summary>
- public static ObjectId[] getHeight(string LayerName)
- {
- ObjectId[] ids = null;
-
- Document doc = GrxCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
- Database db = doc.Database;
- Editor ed = GrxCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
-
- TypedValue[] value = new TypedValue[]
- {
- new TypedValue((int)DxfCode.LayerName,LayerName),
- new TypedValue((int)DxfCode.Start,"LWPOLYLINE")
- };//设置筛选条件
- SelectionFilter filter = new SelectionFilter(value);
- //选择区域中全部对象
- //PromptSelectionResult psr = ed.SelectAll(filter);
- // 要求在图形区域中手动选择对象
- PromptSelectionResult psr = ed.GetSelection(filter);
-
-
- if (psr.Status == PromptStatus.OK)
- {
- using (Transaction trans = db.TransactionManager.StartTransaction())
- {
- SelectionSet ss = psr.Value;
- ids = ss.GetObjectIds();
- trans.Commit();
- }
- }
- return ids;
- }
-
-
- /// <summary>
- /// 获取二维多段线和多段线
- /// </summary>
- public static ObjectId[] getPll()
- {
- ObjectId[] ids = null;
-
- Document doc = GrxCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
- Database db = doc.Database;
- Editor ed = GrxCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
-
- TypedValue[] value = new TypedValue[]
- {
- new TypedValue((int)DxfCode.Start,"LWPOLYLINE,POLYLINE"),
- };//设置筛选条件
- SelectionFilter filter = new SelectionFilter(value);
- //选择区域中全部对象
- //PromptSelectionResult psr = ed.SelectAll(filter);
- // 要求在图形区域中手动选择对象
- PromptSelectionResult psr = ed.GetSelection(filter);
-
-
- if (psr.Status == PromptStatus.OK)
- {
- using (Transaction trans = db.TransactionManager.StartTransaction())
- {
- SelectionSet ss = psr.Value;
- ids = ss.GetObjectIds();
- trans.Commit();
- }
- }
- return ids;
- }
-
-
-
- /// <summary>
- /// 根据Id获取实体
- /// </summary>
- public static Entity GetDBObject(ObjectId i)
- {
- //Document doc = GrxCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
- //Database db = doc.Database;
- Database db = HostApplicationServices.WorkingDatabase;
- Entity ent = null;
- DocumentLock doclock = GrxCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
- using (Transaction tr = db.TransactionManager.StartTransaction())
- {
- ent = (Entity)tr.GetObject(i, OpenMode.ForRead, true);
- tr.Commit();
- }
- doclock.Dispose();
- return ent;
- }
-
-
- /// <summary>
- /// 根据编号判断地物类型
- /// </summary>
- //2022-7-25-qyx改
- public static string get_TypeName(string key)
- {
- string name = "";
- //switch (key)
- //{
- // case "011":
- // name = "水田";
- // break;
- // case "012":
- // name = "水浇地";
- // break;
- // case "013":
- // name = "旱地";
- // break;
-
- // case "021":
- // name = "果园";
- // break;
- // case "022":
- // name = "茶园";
- // break;
- // case "023":
- // name = "其他园地";
- // break;
-
- // case "031":
- // name = "有林地";
- // break;
- // case "032":
- // name = "灌木林地";
- // break;
- // case "033":
- // name = "其他林地";
- // break;
-
- // case "041":
- // name = "天然牧草地";
- // break;
- // case "042":
- // name = "人工牧草地";
- // break;
- // case "043":
- // name = "其他草地";
- // break;
-
- // case "051":
- // name = "批发零售用地";
- // break;
- // case "052":
- // name = "住宿餐饮用地";
- // break;
- // case "053":
- // name = "商务金融用地";
- // break;
- // case "054":
- // name = "其他商服用地";
- // break;
-
- // case "061":
- // name = "工业用地";
- // break;
- // case "062":
- // name = "采矿用地";
- // break;
- // case "063":
- // name = "仓储用地";
- // break;
-
- // case "071":
- // name = "城镇住宅用地";
- // break;
- // case "072":
- // name = "农村宅基地";
- // break;
-
- // case "081":
- // name = "机关团体用地";
- // break;
- // case "082":
- // name = "新闻出版用地";
- // break;
- // case "083":
- // name = "科教用地";
- // break;
- // case "084":
- // name = "医卫慈善用地";
- // break;
- // case "085":
- // name = "文体娱乐用地";
- // break;
- // case "086":
- // name = "公共设施用地";
- // break;
- // case "087":
- // name = "公园与绿地";
- // break;
- // case "088":
- // name = "风景名胜设施用地";
- // break;
-
-
- // case "091":
- // name = "军事设施用地";
- // break;
- // case "092":
- // name = "使领馆用地";
- // break;
- // case "093":
- // name = "监教场所用地";
- // break;
- // case "094":
- // name = "宗教用地";
- // break;
- // case "095":
- // name = "殡葬用地";
- // break;
-
- // case "101":
- // name = "铁路用地";
- // break;
- // case "102":
- // name = "公路用地";
- // break;
- // case "103":
- // name = "街巷用地";
- // break;
- // case "104":
- // name = "农村道路";
- // break;
- // case "105":
- // name = "机场用地";
- // break;
- // case "106":
- // name = "港口码头用地";
- // break;
- // case "107":
- // name = "管道运输用地";
- // break;
-
- // case "111":
- // name = "河流水面";
- // break;
- // case "112":
- // name = "湖泊水面";
- // break;
- // case "113":
- // name = "水库水面";
- // break;
- // case "114":
- // name = "坑塘水面";
- // break;
- // case "115":
- // name = "沿海滩涂";
- // break;
- // case "116":
- // name = "内陆滩涂";
- // break;
- // case "117":
- // name = "沟渠";
- // break;
- // case "118":
- // name = "水工建筑用地";
- // break;
- // case "119":
- // name = "冰川及永久积雪";
- // break;
-
-
-
- // case "121":
- // name = "空闲地";
- // break;
- // case "122":
- // name = "设施农用地";
- // break;
- // case "123":
- // name = "田坎";
- // break;
- // case "124":
- // name = "盐碱地";
- // break;
- // case "125":
- // name = "沼泽地";
- // break;
- // case "126":
- // name = "沙地";
- // break;
- // case "127":
- // name = "裸地";
- // break;
-
- // default:
- // break;
- //}
- // 编号不同
-
-
-
- switch (key)
- {
- case "0101":
- name = "水田";
- break;
- case "0102":
- name = "水浇地";
- break;
- case "0103":
- name = "旱地";
- break;
-
- case "0201":
- name = "果园";
- break;
- case "0202":
- name = "茶园";
- break;
- case "0203":
- name = "橡胶园";
- break;
- case "0204":
- name = "其他园地";
- break;
-
- case "0301":
- name = "乔木林地";
- break;
- case "0302":
- name = "竹林地";
- break;
- case "0303":
- name = "红树林地";
- break;
- case "0304":
- name = "森林沼泽";
- break;
- case "0305":
- name = "灌木林地";
- break;
- case "0306":
- name = "灌丛沼泽";
- break;
- case "0307":
- name = "其他林地";
- break;
-
- case "0401":
- name = "天然牧草地";
- break;
- case "0402":
- name = "沼泽草地";
- break;
- case "0403":
- name = "人工牧草地";
- break;
- case "0404":
- name = "其他草地";
- break;
-
- case "0501":
- name = "零售商业用地";
- break;
- case "0502":
- name = "批发市场用地";
- break;
- case "0503":
- name = "餐饮用地";
- break;
- case "0504":
- name = "旅馆用地";
- break;
- case "0505":
- name = "商业金融用地";
- break;
- case "0506":
- name = "娱乐用地";
- break;
- case "0507":
- name = "其他商服用地";
- break;
-
- case "0601":
- name = "工业用地";
- break;
- case "0602":
- name = "采矿用地";
- break;
- case "0603":
- name = "盐田";
- break;
- case "0604":
- name = "仓储用地";
- break;
-
- case "0701":
- name = "城镇住宅用地";
- break;
- case "0702":
- name = "农村宅基地";
- break;
-
- case "0801":
- name = "机关团体用地";
- break;
- case "0802":
- name = "新闻出版用地";
- break;
- case "0803":
- name = "教育用地";
- break;
- case "0804":
- name = "科研用地";
- break;
- case "0805":
- name = "医疗卫生用地";
- break;
- case "0806":
- name = "社会福利用地";
- break;
- case "0807":
- name = "文化设施用地";
- break;
- case "0808":
- name = "体育用地";
- break;
- case "0809":
- name = "公用设施用地";
- break;
- case "0810":
- name = "公园与绿地";
- break;
-
- case "0901":
- name = "军事设施用地";
- break;
- case "0902":
- name = "使领馆用地";
- break;
- case "0903":
- name = "监教场所用地";
- break;
- case "0904":
- name = "宗教用地";
- break;
- case "0905":
- name = "殡葬用地";
- break;
- case "0906":
- name = "风景名胜设施用地";
- break;
-
- case "1001":
- name = "铁路用地";
- break;
- case "1002":
- name = "轨道交通用地";
- break;
- case "1003":
- name = "公路用地";
- break;
- case "1004":
- name = "城镇村道路用地";
- break;
- case "1005":
- name = "交通服务场所用地";
- break;
- case "1006":
- name = "农村道路";
- break;
- case "1007":
- name = "机场用地";
- break;
- case "1008":
- name = "港口码头用地";
- break;
- case "1009":
- name = "管道运输用地";
- break;
-
- case "1101":
- name = "河流水面";
- break;
- case "1102":
- name = "湖泊水面";
- break;
- case "1103":
- name = "水库水面";
- break;
- case "1104":
- name = "坑塘水面";
- break;
- case "1105":
- name = "沿海滩涂";
- break;
- case "1106":
- name = "内陆滩涂";
- break;
- case "1107":
- name = "沟渠";
- break;
- case "1108":
- name = "沼泽地";
- break;
- case "1109":
- name = "水工建筑用地";
- break;
- case "1110":
- name = "冰川及永久积雪";
- break;
-
- case "1201":
- name = "空闲地";
- break;
- case "1202":
- name = "设施农用地";
- break;
- case "1203":
- name = "田坎";
- break;
- case "1204":
- name = "盐碱地";
- break;
- case "1205":
- name = "沙地";
- break;
- case "1206":
- name = "裸土地";
- break;
- case "1207":
- name = "裸岩石砾地";
- break;
- default:
- break;
- }
-
- return name;
- }
-
-
-
- public static ObjectId AddObj(Document doc,Entity ent)
- {
- ObjectId id = new ObjectId();
- Database database = doc.Database;
- DocumentLock doclock = GrxCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
- using (Transaction traction = database.TransactionManager.StartTransaction())
- {
-
- BlockTable blocktable = traction.GetObject(database.BlockTableId,OpenMode.ForWrite) as BlockTable;
- BlockTableRecord blocktablerecord = traction.GetObject(blocktable[BlockTableRecord.ModelSpace],
- OpenMode.ForWrite) as BlockTableRecord;
-
- blocktablerecord.AppendEntity(ent);
- traction.AddNewlyCreatedDBObject(ent, true);
- id = ent.ObjectId;
-
- traction.Commit();
- doclock.Dispose();
- }
- return id;
- }
-
-
-
-
- /// <summary>
- /// 添加命令
- /// </summary>
- //public void addCommand()
- //{
- // MainClass main = new MainClass();
- // Utils.AddCommand("COMMAND1", "PLError", "ТЕСТ1", CommandFlags.Modal, main.PLError);
- // Utils.AddCommand("COMMAND1", "PLOverlap", "ТЕСТ2", CommandFlags.Modal, main.PLOverlap);
- // Utils.AddCommand("COMMAND1", "Report", "ТЕСТ3", CommandFlags.Modal, main.Report);
- // Utils.AddCommand("COMMAND1", "Fills", "ТЕСТ4", CommandFlags.Modal, main.Fill);
- // Utils.AddCommand("COMMAND1", "BATChange", "ТЕСТ5", CommandFlags.Modal, main.BATChange);
- // Utils.AddCommand("COMMAND1", "PtCheck", "ТЕСТ6", CommandFlags.Modal, main.PointCheck);
- // Utils.AddCommand("COMMAND1", "Hierarchy", "ТЕСТ7", CommandFlags.Modal, main.Hierarchy);
- // Utils.AddCommand("COMMAND1", "CLCheck", "ТЕСТ8", CommandFlags.Modal, main.CLCheck);
- // //Utils.AddCommand("COMMAND1", "Connect", "ТЕСТ9", CommandFlags.Modal, main.Connect);
- // Utils.AddCommand("COMMAND1", "SelfIntersect", "ТЕСТ10", CommandFlags.Modal, main.SelfIntersect);
- // Utils.AddCommand("COMMAND1", "EachIntersect", "ТЕСТ11", CommandFlags.Modal, main.EachIntersect);
- // Utils.AddCommand("COMMAND1", "combFace", "ТЕСТ12", CommandFlags.Modal, main.combF);
- // Utils.AddCommand("COMMAND1", "splitFace", "ТЕСТ13", CommandFlags.Modal, main.splitF);
- // Utils.AddCommand("COMMAND1", "pickupPoint", "ТЕСТ14", CommandFlags.Modal, main.pickupP);
- // Utils.AddCommand("COMMAND1", "FakeCheck", "ТЕСТ15", CommandFlags.Modal, main.FFake);
- // Utils.AddCommand("COMMAND1", "HangCheck", "ТЕСТ16", CommandFlags.Modal, main.HFake);
- // Utils.AddCommand("COMMAND1", "SlopeLine", "ТЕСТ17", CommandFlags.Modal, main.SlpLine);
- // Utils.AddCommand("COMMAND1", "SheetMap", "ТЕСТ18", CommandFlags.Modal, main.SheetMap);
- //}
-
-
- /// <summary>
- /// 删除命令
- /// </summary>
- //public void deleteCommand()
- //{
- // Utils.RemoveCommand("PLError", "TEST1");
- // Utils.RemoveCommand("PLOverlap", "TEST2");
- // Utils.RemoveCommand("Report", "TEST3");
- // Utils.RemoveCommand("Fills", "TEST4");
- // Utils.RemoveCommand("BATChange", "TEST5");
- // Utils.RemoveCommand("PtCheck", "TEST6");
- // Utils.RemoveCommand("Hierarchy", "TEST7");
- // Utils.RemoveCommand("CLCheck", "TEST8");
- // //Utils.RemoveCommand("Connect", "TEST9");
- // Utils.RemoveCommand("SelfIntersect", "TEST10");
- // Utils.RemoveCommand("EachIntersect", "TEST11");
- // Utils.RemoveCommand("combFace", "TEST12");
- // Utils.RemoveCommand("splitFace", "TEST13");
- // Utils.RemoveCommand("pickupPoint", "TEST14");
- // Utils.RemoveCommand("FakeCheck", "TEST15");
- // Utils.RemoveCommand("HangCheck", "TEST16");
- // Utils.RemoveCommand("SlopeLine", "TEST17");
- // Utils.RemoveCommand("SheetMap", "TEST18");
- //}
- }
-
-
- /// <summary>
- /// 对图层的操作处理,包括新建图层、
- /// 把指定图层设置为当前图层和检查是否包含某个图层名
- /// </summary>
- class LayerControl
- {
- /// <summary>
- /// 创建高程点错误标记层
- /// </summary>
- /// <param name="layername">要创建的图层的名字</param>
- /// <param name="colo">RGB三原色</param>
- public void creatlayer(string layername, colorgb colo)
- {
- Database database = GrxCAD.DatabaseServices.HostApplicationServices.WorkingDatabase;
- DocumentLock doclock = GrxCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
- Transaction traction = database.TransactionManager.StartTransaction();
- LayerTable lt = traction.GetObject(database.LayerTableId, OpenMode.ForWrite) as LayerTable;
- try
- {
- LayerTableRecord layertablerecord = new LayerTableRecord();
- layertablerecord.Name = layername;//设置层表记录的名字
- layertablerecord.Color = GrxCAD.Colors.Color.FromRgb(colo.red, colo.green, colo.blue);//为层表记录赋颜色紫色
- //layertablerecord.Color = GrxCAD.Colors.Color.FromColor(System.Drawing.Color.Magenta);
-
-
- lt.Add(layertablerecord);
- traction.AddNewlyCreatedDBObject(layertablerecord, true);
- traction.Commit();
- }
- catch (GrxCAD.Runtime.Exception)
- {
- traction.Abort();
- }
- finally
- {
- traction.Dispose();
- doclock.Dispose();
- }
- }
-
-
- /// <summary>
- /// 将指定图层设置为当前图层
- /// </summary>
- /// <param name="layername">要设置为当前图层的图层名字</param>
- public void movelayertofront(string layername)
- {
- Database database = GrxCAD.DatabaseServices.HostApplicationServices.WorkingDatabase;
- DocumentLock doclock = GrxCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
- Transaction traction = database.TransactionManager.StartTransaction();
- try
- {
- LayerTable layertable = traction.GetObject(database.LayerTableId, OpenMode.ForRead) as LayerTable;
- database.Clayer = layertable[layername];//把图层选为当前图层
- traction.Commit();
- }
- catch (GrxCAD.Runtime.Exception)
- {
- traction.Abort();
- }
- finally
- {
- traction.Dispose();
- doclock.Dispose();
- }
- }
-
-
-
- /// <summary>
- /// 判断所命图层名是否已经存在
- /// </summary>
- /// <param name="layername">要判断的图层名字</param>
- /// <returns>返回true表示在层表中存在要判断的图层名,
- /// 返回false表示层表中不存在判断的图层名</returns>
- public bool haslayername(string layername)
- {
- Database database = GrxCAD.DatabaseServices.HostApplicationServices.WorkingDatabase;
- using (Transaction traction = database.TransactionManager.StartTransaction())
- {
- LayerTable lt = traction.GetObject(database.LayerTableId, OpenMode.ForRead) as LayerTable;
-
- if (lt.Has(layername))
- {
- traction.Commit();
- return true;
- }
- else
- {
- traction.Commit();
- return false;
- }
- }
-
-
-
- }
-
-
-
- public void clear(string layername)
- {
-
- Document document = GrxCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
- Database database = HostApplicationServices.WorkingDatabase;
-
- DocumentLock documentlock = null;
- Transaction traction = null;
- try
- {
- traction = database.TransactionManager.StartTransaction();
- documentlock = GrxCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
-
- BlockTable blocktable = traction.GetObject(database.BlockTableId,
- OpenMode.ForWrite) as BlockTable;
-
- BlockTableRecord blocktablerecord = traction.GetObject(blocktable[BlockTableRecord.ModelSpace],
- OpenMode.ForWrite) as BlockTableRecord;
-
-
- Editor editor = GrxCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
- TypedValue[] typedvalue = new TypedValue[2];
-
- typedvalue.SetValue(new TypedValue((int)DxfCode.Start, "Circle"), 0);
- typedvalue.SetValue(new TypedValue((int)DxfCode.LayerName, "Cir"), 1);
-
- SelectionFilter selectionfilter = new SelectionFilter(typedvalue);
- PromptSelectionResult select = editor.SelectAll(selectionfilter);
-
- if (select.Status == PromptStatus.OK)
- {
- SelectionSet set = select.Value;
-
- ObjectId[] obj = new ObjectId[set.Count];
- obj = set.GetObjectIds();
- for (int i = 0; i < obj.Length; i++)
- {
- ObjectId objid = obj[i];
- Entity entity = (Entity)traction.GetObject(objid, OpenMode.ForWrite);
- entity.Erase();
- }
- }
- traction.Commit();
- }
- catch (GrxCAD.Runtime.Exception)
- {
-
- }
- }
- }
-
-
-
- /// <summary>
- /// RGB三原色
- /// </summary>
- public struct colorgb
- {
- public byte red;
- public byte green;
- public byte blue;
-
- public colorgb(byte r, byte g, byte b)
- {
- this.red = r;
- this.green = g;
- this.blue = b;
- }
- }
-
-
- /// <summary>
- /// 创建图廓
- /// </summary>
- class CreateSheetMap
- {
- private Point3d LB;
- private Point3d LT;
- private Point3d RB;
- private Point3d RT;
- private List<List<Point3d>> TKpts = new List<List<Point3d>>();
- double dist = 200; //格网间距
-
- string layername = "9800";
-
- string Number; //图幅号
- string Left_Number;
- string Right_Number;
- string Leftup_Number;
- string Leftdown_Number;
- string Rightup_Number;
- string Rightdown_Number;
- string Centrolup_Number;
- string Centroldown_Number;
-
- public void create()
- {
- int BLC = TKInfo.BLC;
- if (BLC == 1000)
- {
- dist = 100;
-
- }
- if (BLC == 500)
- {
- dist = 50;
-
- }
- getinfo();
- for (int i = 0; i < TKpts.Count; i++)
- {
- LB = TKpts[i][0];
- LT = TKpts[i][1];
- RB = TKpts[i][2];
- RT = TKpts[i][3];
- //左编号
- Point3d p1 = new Point3d(LB.X - dist * 5 - 100, LB.Y - 100, 0);
- Point3d p2 = new Point3d(LT.X + 50, LT.Y + 50, 0);
- Left_Number = GetNumber(p1, p2);
- //右编号
- p1 = new Point3d(RT.X + dist * 5 + 100, RT.Y + 100, 0);
- p2 = new Point3d(RB.X - 50, RB.Y - 50, 0);
- Right_Number = GetNumber(p1, p2);
- //左上编号
- p1 = new Point3d(LT.X - dist * 5 - 100, LT.Y + dist * 5 + 100, 0);
- p2 = new Point3d(LT.X + 50, LT.Y - 50, 0);
- Leftup_Number = GetNumber(p1, p2);
- //左下编号
- p1 = new Point3d(LB.X - dist * 5 - 100, LB.Y - dist * 5 - 100, 0);
- p2 = new Point3d(LB.X + 50, LB.Y + 50, 0);
- Leftdown_Number = GetNumber(p1, p2);
- //中上编号
- p1 = new Point3d(LT.X - 100, LT.Y - 100, 0);
- p2 = new Point3d(RT.X + 50, RT.Y + dist * 5 + 50, 0);
- Centrolup_Number = GetNumber(p1, p2);
- //中下编号
- p1 = new Point3d(LB.X - 100, LB.Y - dist * 5 - 100, 0);
- p2 = new Point3d(RB.X + 50, RB.Y + 50, 0);
- Centroldown_Number = GetNumber(p1, p2);
- //右上编号
- p1 = new Point3d(RT.X - 100, RT.Y - 100, 0);
- p2 = new Point3d(RT.X + dist * 5 + 50, RT.Y + dist * 5 + 50, 0);
- Rightup_Number = GetNumber(p1, p2);
- //右下编号
- p1 = new Point3d(RB.X - 100, RB.Y + 100, 0);
- p2 = new Point3d(RB.X + dist * 5 + 50, RB.Y - dist * 5 - 50, 0);
- Rightdown_Number = GetNumber(p1, p2);
-
-
- //图幅号
- p1 = new Point3d(LB.X - 100, LB.Y - 100, 0);
- p2 = new Point3d(RT.X + 100, RT.Y + 100, 0);
- Number = GetNumber(p1, p2);
-
- //新建一个dwg
- string templatePath = "acad.dwt";
- DocumentCollection documentcoll = GrxCAD.ApplicationServices.Application.DocumentManager;
- Document document = documentcoll.Add(templatePath);
- Database database = document.Database;
-
-
-
- LayerControl layerscontrol = new LayerControl();
- if (layerscontrol.haslayername(layername) == false)
- {
- colorgb col = new colorgb(255, 0, 0);
- layerscontrol.creatlayer(layername, col);
- layerscontrol.movelayertofront(layername);
- }
- else
- layerscontrol.movelayertofront(layername);
-
-
- createTextStyle();
-
- draw();
-
- zoom();
- //database.SaveAs(TKInfo.SV + "\\" + Number.ToString() + ".dwg", DwgVersion.AC1024);
- database.SaveAs(TKInfo.SV + "\\" + Number.ToString() + ".dwg", true, DwgVersion.AC1021, database.SecurityParameters);
- //document.CloseAndSave(Number.ToString() + ".dwg");
- document.CloseAndDiscard();
- }
- }
-
-
-
- private void getinfo()
- {
- Document document = GrxCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
- Database database = HostApplicationServices.WorkingDatabase;
-
-
- using (Transaction traction = database.TransactionManager.StartTransaction())
- {
- DocumentLock documentlock = GrxCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
-
- BlockTable blocktable = traction.GetObject(database.BlockTableId,
- OpenMode.ForRead) as BlockTable;
-
- Editor editor = GrxCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
- TypedValue[] typedvalue = new TypedValue[1];
-
- typedvalue.SetValue(new TypedValue((int)DxfCode.Start, "3dFace,LWPolyline"), 0);
- SelectionFilter selectionfilter = new SelectionFilter(typedvalue);
- PromptSelectionResult psr = editor.GetSelection(selectionfilter);
-
-
- if (psr.Status == PromptStatus.OK)
- {
- SelectionSet selectionset = psr.Value;
-
- ObjectId[] obj = new ObjectId[selectionset.Count];
- obj = selectionset.GetObjectIds();
- for (int i = 0; i < obj.Length; i++)
- {
- ObjectId objid = obj[i];
-
-
- Entity entity = (Entity)traction.GetObject(objid, OpenMode.ForRead);
- Point3dCollection coll = new Point3dCollection();
-
- if (entity is Face)
- {
- Face f = entity as Face;
- f.GetStretchPoints(coll);
- }
- else if (entity is Polyline)
- {
- Polyline line = entity as Polyline;
- line.GetStretchPoints(coll);
- }
-
- LB = coll[0];
- LT = coll[0];
- RB = coll[0];
- RT = coll[0];
-
- for (int ii = 1; ii < coll.Count; ii++)
- {
- double x = coll[ii].X;
- double y = coll[ii].Y;
-
- if (x <= LB.X && y <= LB.Y)
- {
- LB = coll[ii];
- }
- if (x <= LT.X && y >= LT.Y)
- {
- LT = coll[ii];
- }
- if (x >= RB.X && y <= RB.Y)
- {
- RB = coll[ii];
- }
- if (x >= RT.X && y >= RT.Y)
- {
- RT = coll[ii];
- }
- }
- List<Point3d> temp = new List<Point3d>();
- temp.Add(LB);
- temp.Add(LT);
- temp.Add(RB);
- temp.Add(RT);
- TKpts.Add(temp);
- }
- }
- traction.Commit();
- documentlock.Dispose();
- }
- }
-
-
-
- private void draw()
- {
- int BLC = TKInfo.BLC;
-
-
- double len = 10; //分幅框标长度
- double D22 = 22; //内图廓线和外图廓线距离
- double D1 = 1.0; //间距为1
- double D2 = 2.0; //间距为2
- double D3 = 3.0; //间距为3
- double D4 = 4.0; //间距为4
- double D4_8 = 4.8; //间距为4.8
- double D5 = 5.0; //间距为5
- double D6 = 6.0; //间距为6
- double D7 = 7.0; //间距为7
- double D8 = 8.0; //间距为8
- double D10 = 10.0; //间距为10
- double D12 = 12.0; //间距为12
- double D140 = 140; //右下角附注
- double D90 = 90;
- double D48 = 48;
-
-
- double dist1 = 1.625; //接图表第一格填充间距
- double dist2 = Math.Sqrt(8); //接图表填充间距
-
- if (BLC == 1000)
- {
- len = len / 2; //分幅框标长度
- D22 = D22 / 2; //内图廓线和外图廓线距离
- D1 = D1 / 2; //间距为1
- D2 = D2 / 2; //间距为2
- D3 = D3 / 2; //间距为3
- D4 = D4 / 2; //间距为4
- D4_8 = D4_8 / 2; //间距为4.8
- D5 = D5 / 2; //间距为5
- D6 = D6 / 2; //间距为6
- D7 = D7 / 2; //间距为7
- D8 = D8 / 2; //间距为8
- D10 = D10 / 2; //间距为10
- D12 = D12 / 2; //间距为12
- D140 = D140 / 2; //右下角附注
- D90 = D90 / 2;
- D48 = D48 / 2;
-
- dist1 = dist1 / 2; //接图表第一格填充间距
- dist2 = dist2 / 2; //接图表填充间距
-
- }
-
- if (BLC == 500)
- {
- len = len / 4; //分幅框标长度
- D22 = D22 / 4; //内图廓线和外图廓线距离
- D1 = D1 / 4; //间距为1
- D2 = D2 / 4; //间距为2
- D3 = D3 / 4; //间距为3
- D4 = D4 / 4; //间距为4
- D4_8 = D4_8 / 4; //间距为4.8
- D5 = D5 / 4; //间距为5
- D6 = D6 / 4; //间距为6
- D7 = D7 / 4; //间距为7
- D8 = D8 / 4; //间距为8
- D10 = D10 / 4; //间距为10
- D12 = D12 / 4; //间距为12
- D140 = D140 / 4; //右下角附注
- D90 = D90 / 4;
- D48 = D48 / 4;
-
- dist1 = dist1 / 4; //接图表第一格填充间距
- dist2 = dist2 / 4; //接图表填充间距
-
- }
-
-
- ObjectId HZ = gettextstyleID("HZ");
- ObjectId st = gettextstyleID("st");
- ObjectId ht = gettextstyleID("ht");
- ObjectId Standard = gettextstyleID("Standard");
- ObjectId ID12 = gettextstyleID("12");
- ObjectId ID123 = gettextstyleID("123");
-
- //ObjectId XDXT = gettextstyleID("细等线体");
- //ObjectId ZDXT = gettextstyleID("中等线体");
- //ObjectId ST = gettextstyleID("宋体");
-
- double xx1, yy1;
- double xx2, yy2;
- int DH;
-
-
- Document document = GrxCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
- Database database = HostApplicationServices.WorkingDatabase;
-
- Transaction traction = database.TransactionManager.StartTransaction();
-
- DocumentLock documentlock = GrxCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
-
-
- BlockTable blocktable = traction.GetObject(database.BlockTableId,
- OpenMode.ForWrite) as BlockTable;
-
- BlockTableRecord blocktablerecord = traction.GetObject(blocktable[BlockTableRecord.ModelSpace],
- OpenMode.ForWrite) as BlockTableRecord;
- Editor editor = GrxCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
-
-
- //try
- //{
-
-
- //内图廓
-
- //左边线
- Point3dCollection In1 = new Point3dCollection();
- In1.Add(new Point3d(LT.X, LT.Y + D22 + D1, 0));
- In1.Add(new Point3d(LB.X, LB.Y - D22 - D1, 0));
- Polyline2d LeftLine = new Polyline2d(Poly2dType.SimplePoly, In1, 0, false, 0, 0, null);
- //LeftLine.Color = GrxCAD.Colors.Color.FromColor(System.Drawing.Color.Red);
- LeftLine.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 1);
- LeftLine.Layer = layername;
-
- LeftLine.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(LeftLine);
- traction.AddNewlyCreatedDBObject(LeftLine, true);
-
- //下边线
- Point3dCollection In2 = new Point3dCollection();
- In2.Add(new Point3d(LB.X - D22 - D1, LB.Y, 0));
- In2.Add(new Point3d(RB.X + D22 + D1, RB.Y, 0));
- Polyline2d LowLine = new Polyline2d(Poly2dType.SimplePoly, In2, 0, false, 0, 0, null);
- LowLine.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 1);
-
- LowLine.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(LowLine);
- traction.AddNewlyCreatedDBObject(LowLine, true);
-
- //右边线
- Point3dCollection In3 = new Point3dCollection();
- In3.Add(new Point3d(RT.X, RT.Y + D22 + D1, 0));
- In3.Add(new Point3d(RB.X, RB.Y - D22 - D1, 0));
- Polyline2d RightLine = new Polyline2d(Poly2dType.SimplePoly, In3, 0, false, 0, 0, null);
- RightLine.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 1);
- RightLine.Layer = layername;
-
- RightLine.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(RightLine);
- traction.AddNewlyCreatedDBObject(RightLine, true);
-
- //上边线
- Point3dCollection In4 = new Point3dCollection();
- In4.Add(new Point3d(LT.X - D22 - D1, LT.Y, 0));
- In4.Add(new Point3d(RT.X + D22 + D1, RT.Y, 0));
- Polyline2d TOPLine = new Polyline2d(Poly2dType.SimplePoly, In4, 0, false, 0, 0, null);
- TOPLine.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 1);
- TOPLine.Layer = layername;
-
- TOPLine.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(TOPLine);
- traction.AddNewlyCreatedDBObject(TOPLine, true);
-
- //外图廓
- Point3dCollection Outcoll = new Point3dCollection();
- Outcoll.Add(new Point3d(LT.X - D22 - D1, LT.Y + D22 + D1, 0));
- Outcoll.Add(new Point3d(LB.X - D22 - D1, LB.Y - D22 - D1, 0));
- Outcoll.Add(new Point3d(RB.X + D22 + D1, RB.Y - D22 - D1, 0));
- Outcoll.Add(new Point3d(RT.X + D22 + D1, RT.Y + D22 + D1, 0));
- Outcoll.Add(new Point3d(LT.X - D22 - D1, LT.Y + D22 + D1, 0));
-
- Polyline2d line = new Polyline2d(Poly2dType.SimplePoly, Outcoll, 0, true, D2, D2, null);
-
- line.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 1);
- line.Layer = layername;
-
- line.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(line);
- traction.AddNewlyCreatedDBObject(line, true);
- line.UpgradeOpen();
- line.ConstantWidth = D2;
-
-
-
-
- //分幅框标
- for (int i = 1; i <= 4; i++)
- {
- for (int j = 1; j <= 4; j++)
- {
- //中心点
- double x = LB.X + i * dist;
- double y = LB.Y + j * dist;
-
- //横线
- Point3d p1 = new Point3d(x - len, y, 0);
- Point3d p2 = new Point3d(x + len, y, 0);
- Point3dCollection kb = new Point3dCollection();
- kb.Add(p1);
- kb.Add(p2);
- Polyline2d kbline = new Polyline2d(Poly2dType.SimplePoly, kb, 0, false, 0, 0, null);
- kbline.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 1);
- kbline.Layer = layername;
-
- kbline.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(kbline);
- traction.AddNewlyCreatedDBObject(kbline, true);
-
- //竖线
- p1 = new Point3d(x, y - len, 0);
- p2 = new Point3d(x, y + len, 0);
- kb = new Point3dCollection();
- kb.Add(p1);
- kb.Add(p2);
- kbline = new Polyline2d(Poly2dType.SimplePoly, kb, 0, false, 0, 0, null);
- kbline.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 1);
- kbline.Layer = layername;
-
- kbline.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(kbline);
- traction.AddNewlyCreatedDBObject(kbline, true);
-
- }
- }
-
- for (int i = 1; i <= 4; i++)
- {
-
- double x;
- double y;
- Point3d p1;
- Point3d p2;
-
- //下边线
- x = LB.X;
- y = LB.Y;
- p1 = new Point3d(x + i * dist, y + len, 0);
- p2 = new Point3d(x + i * dist, y, 0);
- Point3dCollection kb = new Point3dCollection();
- kb.Add(p1);
- kb.Add(p2);
- Polyline2d kbline = new Polyline2d(Poly2dType.SimplePoly, kb, 0, false, 0, 0, null);
- kbline.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 1);
- kbline.Layer = layername;
-
- kbline.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(kbline);
- traction.AddNewlyCreatedDBObject(kbline, true);
-
-
- //上边线
- x = LB.X;
- y = LT.Y;
- p1 = new Point3d(x + i * dist, y - len, 0);
- p2 = new Point3d(x + i * dist, y, 0);
- kb = new Point3dCollection();
- kb.Add(p1);
- kb.Add(p2);
- kbline = new Polyline2d(Poly2dType.SimplePoly, kb, 0, false, 0, 0, null);
- kbline.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 1);
- kbline.Layer = layername;
-
- kbline.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(kbline);
- traction.AddNewlyCreatedDBObject(kbline, true);
-
-
- //左边线
- x = LB.X;
- y = LB.Y;
- p1 = new Point3d(x, y + i * dist, 0);
- p2 = new Point3d(x + len, y + i * dist, 0);
- kb = new Point3dCollection();
- kb.Add(p1);
- kb.Add(p2);
- kbline = new Polyline2d(Poly2dType.SimplePoly, kb, 0, false, 0, 0, null);
- kbline.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 1);
- kbline.Layer = layername;
-
- kbline.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(kbline);
- traction.AddNewlyCreatedDBObject(kbline, true);
-
-
- //右边线
- x = RB.X;
- y = LB.Y;
- p1 = new Point3d(x, y + i * dist, 0);
- p2 = new Point3d(x - len, y + i * dist, 0);
- kb = new Point3dCollection();
- kb.Add(p1);
- kb.Add(p2);
- kbline = new Polyline2d(Poly2dType.SimplePoly, kb, 0, false, 0, 0, null);
- kbline.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 1);
- kbline.Layer = layername;
-
- kbline.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(kbline);
- traction.AddNewlyCreatedDBObject(kbline, true);
-
- }
-
- //右下角附注
- double xx = RB.X;
- double yy = RB.Y;
- xx = xx - D140;
- yy = yy - D22 - D2 - D6;
-
- List<string> RLnote = new List<string>();
- string str = "";
- if (string.IsNullOrEmpty(TKInfo.CTY) == false)
- {
- str = TKInfo.CTY;
- RLnote.Add(str);
- }
- if (string.IsNullOrEmpty(TKInfo.TDY) == false)
- {
- str = TKInfo.TDY;
- RLnote.Add(str);
- }
- if (string.IsNullOrEmpty(TKInfo.SHY) == false)
- {
- str = TKInfo.SHY;
- RLnote.Add(str);
- }
- if (string.IsNullOrEmpty(TKInfo.JCY) == false)
- {
- str = TKInfo.JCY;
- RLnote.Add(str);
- }
- str = "复查员 ";
- RLnote.Add(str);
- //秘密等级
- if (string.IsNullOrEmpty(TKInfo.Secret) == false)
- {
- str = TKInfo.Secret;
- DBText text1_secret = new DBText();
- text1_secret.TextString = str;
- text1_secret.WidthFactor = 1.333;
- text1_secret.HorizontalMode = TextHorizontalMode.TextLeft;
- text1_secret.Height = D6;
- text1_secret.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 4);
- text1_secret.Layer = layername;
- text1_secret.TextStyleId = ht;
- double s_x = RT.X - (text1_secret.Bounds.Value.MaxPoint.X - text1_secret.Bounds.Value.MinPoint.X) - D1;
- double s_y = LT.Y + D22 + D2 + D10;
- text1_secret.Position = new Point3d(s_x, s_y, 0);
-
- text1_secret.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(text1_secret);
- traction.AddNewlyCreatedDBObject(text1_secret, true);
- }
-
- for (int i = 0; i < RLnote.Count; i++)
- {
- yy = yy - D6;
- DBText text1_fz = new DBText();
- text1_fz.TextString = RLnote[i];
- text1_fz.Position = new Point3d(xx, yy, 0);
- text1_fz.Height = D6;
- text1_fz.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 4);
- text1_fz.Layer = layername;
- text1_fz.TextStyleId = HZ;
-
- text1_fz.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(text1_fz);
- traction.AddNewlyCreatedDBObject(text1_fz, true);
-
- yy = yy - D4;
- }
-
-
-
- //比例尺
- xx = (RB.X - LB.X) / 2 + LB.X;
- yy = LB.Y - D22 - D2 - D10 - D8;
-
- DBText text2_blc = new DBText();
- text2_blc.TextString = "1:" + BLC;
- text2_blc.Position = new Point3d(xx, yy, 0);
- text2_blc.Height = D8;
- text2_blc.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 2);
- text2_blc.Layer = layername;
- text2_blc.HorizontalMode = TextHorizontalMode.TextCenter;
- text2_blc.AlignmentPoint = new Point3d(xx, yy, 0);
- text2_blc.TextStyleId = st;
- text2_blc.WidthFactor = 0.75;
-
- text2_blc.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(text2_blc);
- traction.AddNewlyCreatedDBObject(text2_blc, true);
-
-
-
-
-
- //图幅号
- xx = (RB.X - LB.X) / 2 + LB.X;
- yy = LT.Y + D22 + D2 + D10;
- DBText text3_tfh = new DBText();
- text3_tfh.TextString = "(" + Number.ToString() + ")";
- text3_tfh.Position = new Point3d(xx, yy, 0);
- text3_tfh.Height = D10;
- text3_tfh.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 2);
- text3_tfh.Layer = layername;
- text3_tfh.HorizontalMode = TextHorizontalMode.TextCenter;
- text3_tfh.AlignmentPoint = new Point3d(xx, yy, 0);
- text3_tfh.TextStyleId = HZ;
- text3_tfh.WidthFactor = 0.8;
-
- text3_tfh.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(text3_tfh);
- traction.AddNewlyCreatedDBObject(text3_tfh, true);
-
- //图名
- xx = (RB.X - LB.X) / 2 + LB.X;
- yy = LT.Y + D22 + D2 + D10 + D10 + D6;
- DBText text4_tm = new DBText();
- text4_tm.TextString = TKInfo.name;
- text4_tm.Position = new Point3d(xx, yy, 0);
- text4_tm.Height = D10;
- text4_tm.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 6);
- text4_tm.Layer = layername;
- text4_tm.HorizontalMode = TextHorizontalMode.TextCenter;
- text4_tm.AlignmentPoint = new Point3d(xx, yy, 0);
- text4_tm.TextStyleId = ht;
- text4_tm.WidthFactor = 1;
-
- text4_tm.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(text4_tm);
- traction.AddNewlyCreatedDBObject(text4_tm, true);
-
-
- //图名后的日期
- //string Time_str = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString("00");
-
- ////左括号
- //string tem_str = text4_tm.TextString;
- //xx = (RB.X - LB.X) / 2 + LB.X + tem_str.Length / 2.0 * (D12);
- //yy = LT.Y + D22 + D2 + D10 + D10 + D6;
- //DBText text_F = new DBText();
- //string black = "";
- //for (int i = 0; i < D12; i++)
- //{
- // black += " ";
- //}
- //text_F.TextString = "(" + Time_str + ")";
- //text_F.Position = new Point3d(xx, yy, 0);
- //text_F.Height = D12;
- //text_F.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 2);
- //text_F.Layer = layername;
- //text_F.HorizontalMode = TextHorizontalMode.TextLeft;
- ////text_F.TextStyleId = ID12;
- //text_F.TextStyleId = ht;
-
- //text_F.SetDatabaseDefaults();
- //blocktablerecord.AppendEntity(text_F);
- //traction.AddNewlyCreatedDBObject(text_F, true);
-
-
- //日期
- //xx = xx + D1;
- //yy = LT.Y + D22 + D2 + D10 + D10 + D6;
- //DBText text_T = new DBText();
-
- //text_T.TextString = Time_str;
- //text_T.Position = new Point3d(xx, yy, 0);
- //text_T.Height = D12;
- //text_T.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 2);
- //text_T.Layer = layername;
- //text_T.HorizontalMode = TextHorizontalMode.TextLeft;
- //text_T.TextStyleId = ht;
-
- //text_T.SetDatabaseDefaults();
- //blocktablerecord.AppendEntity(text_T);
- //traction.AddNewlyCreatedDBObject(text_T, true);
-
-
-
-
-
- //左下附注
- string notes = TKInfo.note;
- char[] ch = new char[] { '\r', '\n' };
- string[] strs = notes.Split(ch);
- xx = LB.X;
- yy = LB.Y - D22 - D2 - D6;
- for (int i = 0; i < strs.Length; i++)
- {
- xx = LB.X;
- yy = yy - D6;
-
- if (i == strs.Length - 3)
- {
- string[] str1 = strs[i].Split(' ');
- DBText text_fz1 = new DBText();
- text_fz1.TextString = str1[0];
- text_fz1.Position = new Point3d(xx, yy, 0);
- text_fz1.Height = D6;
- text_fz1.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 4);
- text_fz1.Layer = layername;
- text_fz1.TextStyleId = HZ;
- text_fz1.WidthFactor = 0.8;
-
- text_fz1.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(text_fz1);
- traction.AddNewlyCreatedDBObject(text_fz1, true);
-
- xx = xx + D140 / 2 + D2;
- DBText text_fz2 = new DBText();
- text_fz2.TextString = str1[1] + " " + str1[2];
- text_fz2.Position = new Point3d(xx, yy, 0);
- text_fz2.Height = D6;
- text_fz2.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 4);
- text_fz2.Layer = layername;
- text_fz2.TextStyleId = HZ;
- text_fz2.WidthFactor = 1;
-
- text_fz2.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(text_fz2);
- traction.AddNewlyCreatedDBObject(text_fz2, true);
- yy = yy - D4;
-
- continue;
- }
- else if (i == strs.Length - 2)
- {
- string[] str2 = strs[i].Split(' ');
- DBText text_1 = new DBText();
- text_1.TextString = str2[0]+" "+ str2[1] + " "+ str2[2];
- text_1.Position = new Point3d(xx, yy, 0);
- text_1.Height = D6;
- text_1.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 4);
- text_1.Layer = layername;
- text_1.TextStyleId = HZ;
- text_1.WidthFactor = 0.8;
-
- text_1.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(text_1);
- traction.AddNewlyCreatedDBObject(text_1, true);
-
- xx = xx + D90;
- DBText text_2 = new DBText();
- text_2.TextString = str2[3];
- text_2.Position = new Point3d(xx, yy, 0);
- text_2.Height = D6;
- text_2.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 4);
- text_2.Layer = layername;
- text_2.TextStyleId = HZ;
- text_2.WidthFactor = 1;
-
- text_2.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(text_2);
- traction.AddNewlyCreatedDBObject(text_2, true);
- yy = yy - D4;
-
- continue;
- }
-
-
- DBText text5 = new DBText();
- text5.TextString = strs[i];
- text5.Position = new Point3d(xx, yy, 0);
- text5.Height = D6;
- text5.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 4);
- text5.Layer = layername;
- text5.TextStyleId = HZ;
- text5.WidthFactor = 1;
-
- text5.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(text5);
- traction.AddNewlyCreatedDBObject(text5, true);
-
- yy = yy - D4;
- }
-
-
-
-
- //公司名称
-
- string Company = "四川中水成勘院测绘工程有限责任公司";
- xx = LB.X - D22 - D2 - D6 - D8;
- yy = LB.Y;
- for (int i = Company.Length - 1; i >= 0; i--)
- {
- DBText text6_gs = new DBText();
- text6_gs.TextString = Company[i].ToString();
- text6_gs.Position = new Point3d(xx, yy, 0);
- text6_gs.Height = D8;
- text6_gs.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 2);
- text6_gs.Layer = layername;
- text6_gs.TextStyleId = HZ;
- text6_gs.WidthFactor = 1;
-
- text6_gs.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(text6_gs);
- traction.AddNewlyCreatedDBObject(text6_gs, true);
- yy = yy + D8 + D2;
- }
-
-
- //接图表
- //接图表左下角坐标
- xx = LT.X;
- yy = LT.Y + D22 + D2 + D6;
- for (int i = 0; i < 2; i++)
- {
- Point3dCollection Lcoll = new Point3dCollection();
- Lcoll.Add(new Point3d(xx, yy + D48, 0));
- Lcoll.Add(new Point3d(xx, yy, 0));
- Polyline2d JTB = new Polyline2d(Poly2dType.SimplePoly, Lcoll, 0, true, 0, 0, null);
- JTB.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 1);
- JTB.Layer = layername;
-
- JTB.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(JTB);
- traction.AddNewlyCreatedDBObject(JTB, true);
-
- xx = xx + D90;
- }
-
- xx = LT.X;
- yy = LT.Y + D22 + D2 + D6;
- for (int i = 0; i < 4; i++)
- {
- Point3dCollection Lcoll = new Point3dCollection();
- Lcoll.Add(new Point3d(xx, yy, 0));
- Lcoll.Add(new Point3d(xx + D90, yy, 0));
- Polyline2d JTB = new Polyline2d(Poly2dType.SimplePoly, Lcoll, 0, true, 0, 0, null);
- JTB.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 1);
- JTB.Layer = layername;
-
- JTB.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(JTB);
- traction.AddNewlyCreatedDBObject(JTB, true);
-
- yy = yy + D48 / 3;
- }
-
- xx = LT.X;
- yy = LT.Y + D22 + D2 + D6;
- for (int i = 0; i < 2; i++)
- {
- Point3dCollection Lcoll = new Point3dCollection();
- //Lcoll.Add(new Point3d(xx + D90 / 3, yy + D48 / 3, 0));
- Lcoll.Add(new Point3d(xx + D90 / 3, yy, 0));
- //Lcoll.Add(new Point3d(xx + D90 / 3, yy + D48 / 3 * 2, 0));
- Lcoll.Add(new Point3d(xx + D90 / 3, yy + D48, 0));
- Polyline2d JTB = new Polyline2d(Poly2dType.SimplePoly, Lcoll, 0, true, 0, 0, null);
- JTB.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 1);
- JTB.Layer = layername;
-
- JTB.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(JTB);
- traction.AddNewlyCreatedDBObject(JTB, true);
-
- xx = xx + D90 / 3;
- }
-
-
-
-
-
-
- //接图表填充
- //接图表左上角坐标
- xx = LT.X + D90 / 3;
- yy = LT.Y + D22 + D2 + D6 + (D48 / 3) * 2;
- Point3dCollection coll = new Point3dCollection();
- coll.Add(new Point3d(xx, yy, 0));
- coll.Add(new Point3d(xx, yy - D48 / 3, 0));
- coll.Add(new Point3d(xx + D90 / 3, yy - D48 / 3, 0));
- coll.Add(new Point3d(xx + D90 / 3, yy, 0));
- coll.Add(new Point3d(xx, yy, 0));
-
- Polyline2d line2d = new Polyline2d(Poly2dType.SimplePoly, coll, 0, false, 0, 0, null);
- xx = xx + dist1;
- for (int i = 0; i < 30; i++)
- {
- Line l = new Line();
- l.StartPoint = new Point3d(xx + 90, yy + 90, 0);
- l.EndPoint = new Point3d(xx - 90, yy - 90, 0);
- Point3dCollection IP = new Point3dCollection();
-
- l.IntersectWith(line2d, Intersect.ExtendThis, IP, IntPtr.Zero, IntPtr.Zero);
- Polyline2d FillLine = new Polyline2d(Poly2dType.SimplePoly, IP, 0, false, 0, 0, null);
- FillLine.Layer = layername;
- FillLine.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 1);
-
- FillLine.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(FillLine);
- traction.AddNewlyCreatedDBObject(FillLine, true);
-
- xx = xx + Math.Sqrt(dist2);
- }
-
- //接图表中间行——左
- if (string.IsNullOrEmpty(Left_Number) == false)
- {
- //接图表左下角坐标
- xx1 = LT.X;
- yy1 = LT.Y + D22 + D2 + D6;
-
- xx2 = xx1 + D90 / 3 / 2;
- yy2 = yy1 + D48 / 3 * 1.5;
-
- DBText text_L = new DBText();
- text_L.TextString = Left_Number;
- text_L.Position = new Point3d(xx2, yy2, 0);
- text_L.Height = D5;
- text_L.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 4);
- text_L.Layer = layername;
- text_L.TextStyleId = HZ;
- text_L.HorizontalMode = TextHorizontalMode.TextCenter;
- text_L.VerticalMode = TextVerticalMode.TextVerticalMid;
- text_L.AlignmentPoint = new Point3d(xx2, yy2, 0);
-
- text_L.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(text_L);
- traction.AddNewlyCreatedDBObject(text_L, true);
- }
-
- //接图表中间行——右
- if (string.IsNullOrEmpty(Right_Number) == false)
- {
- //接图表左下角坐标
- xx1 = LT.X;
- yy1 = LT.Y + D22 + D2 + D6;
-
- xx2 = xx1 + D90 / 3 * 2.5;
- yy2 = yy1 + D48 / 3 * 1.5;
-
- DBText text_R = new DBText();
- text_R.TextString = Right_Number;
- text_R.Position = new Point3d(xx2, yy2, 0);
- text_R.Height = D5;
- text_R.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 4);
- text_R.Layer = layername;
- text_R.TextStyleId = HZ;
- text_R.HorizontalMode = TextHorizontalMode.TextCenter;
- text_R.VerticalMode = TextVerticalMode.TextVerticalMid;
- text_R.AlignmentPoint = new Point3d(xx2, yy2, 0);
-
- text_R.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(text_R);
- traction.AddNewlyCreatedDBObject(text_R, true);
- }
- //接图表首行——左
- if (string.IsNullOrEmpty(Leftup_Number) == false)
- {
- xx1 = LT.X;
- yy1 = LT.Y + D22 + D2 + D6;
-
- xx2 = xx1 + D90 / 3 / 2;
- yy2 = yy1 + D48 / 3 * 2.5;
- filjtb(Leftup_Number,traction, HZ, blocktablerecord, xx2, yy2, D5);
- }
- //接图表首行——中
- if (string.IsNullOrEmpty(Centrolup_Number) == false)
- {
- xx1 = LT.X;
- yy1 = LT.Y + D22 + D2 + D6;
-
- xx2 = xx1 + D90 / 3 * 1.5;
- yy2 = yy1 + D48 / 3 * 2.5;
- filjtb(Centrolup_Number,traction, HZ, blocktablerecord, xx2, yy2, D5);
- }
- //接图表首行——右
- if (string.IsNullOrEmpty(Rightup_Number) == false)
- {
- xx1 = LT.X;
- yy1 = LT.Y + D22 + D2 + D6;
-
- xx2 = xx1 + D90 / 3 * 2.5;
- yy2 = yy1 + D48 / 3 * 2.5;
- filjtb(Rightup_Number,traction, HZ, blocktablerecord, xx2, yy2, D5);
- }
- //接图表尾行——左
- if (string.IsNullOrEmpty(Leftdown_Number) == false)
- {
- xx1 = LT.X;
- yy1 = LT.Y + D22 + D2 + D6;
-
- xx2 = xx1 + D90 / 3 / 2;
- yy2 = yy1 + D48 / 3 / 2;
- filjtb(Leftdown_Number,traction, HZ, blocktablerecord, xx2, yy2, D5);
- }
- //接图表尾行——中
- if (string.IsNullOrEmpty(Centroldown_Number) == false)
- {
- xx1 = LT.X;
- yy1 = LT.Y + D22 + D2 + D6;
-
- xx2 = xx1 + D90 / 3 * 1.5;
- yy2 = yy1 + D48 / 3 / 2;
- filjtb(Centroldown_Number,traction, HZ, blocktablerecord, xx2, yy2, D5);
- }
- //接图表尾行——右
- if (string.IsNullOrEmpty(Rightdown_Number) == false)
- {
- xx1 = LT.X;
- yy1 = LT.Y + D22 + D2 + D6;
-
- xx2 = xx1 + D90 / 3 * 2.5;
- yy2 = yy1 + D48 / 3 / 2;
- filjtb(Rightdown_Number,traction, HZ, blocktablerecord, xx2, yy2, D5);
- }
-
-
-
-
- ////坐标
-
- //左上
- xx = LT.X;
- yy = LT.Y;
-
- //X坐标
- xx1 = xx - D4_8 * 0.75 * 2 - D1;
- yy1 = yy + D22 - D7;
-
- DBText text7 = new DBText();
- string value7 = (xx / 1000.0 % 100).ToString("F1");
- if (value7.Length == 3)
- {
- value7 = "0" + value7;
- }
- text7.TextString = value7;
- text7.Position = new Point3d(xx1, yy1, 0);
- text7.Height = D4_8;
- text7.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 3);
- text7.Layer = layername;
- text7.TextStyleId = HZ;
- text7.WidthFactor = 0.75;
-
- text7.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(text7);
- traction.AddNewlyCreatedDBObject(text7, true);
-
-
- //带号
- xx1 = xx - D4_8 * 0.75 * 2 - D3 * 0.75 * 3 - D2;
- yy1 = yy + D22 - D7 + (D4_8 - D3);
-
-
- if (TKInfo.DH != -1)
- {
- DH = TKInfo.DH * 10 + (int)xx / 1000 / 100;
- }
- else
- {
- DH = (int)xx / 1000 / 100;
- }
- DBText text8 = new DBText();
- text8.TextString = DH.ToString();
- text8.Position = new Point3d(xx1, yy1, 0);
- text8.Height = D3;
- text8.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 3);
- text8.Layer = layername;
- text8.HorizontalMode = TextHorizontalMode.TextRight;
- text8.VerticalMode = TextVerticalMode.TextTop;
-
-
- xx2 = xx - D4_8 * 0.75 * 2 - D2;
- yy2 = yy + D22 - D7 + D4_8;
- text8.AlignmentPoint = new Point3d(xx2, yy2, 0);
- text8.TextStyleId = HZ;
- text8.WidthFactor = 0.75;
-
- text8.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(text8);
- traction.AddNewlyCreatedDBObject(text8, true);
-
-
-
- //Y坐标下标
- xx1 = xx - D4_8 * 0.75 * 4 - D1;
- yy1 = yy + D2;
- DBText text9 = new DBText();
- string value9 = (yy / 1000.0 % 100).ToString("F1");
- if (value9.Length == 3)
- {
- value9 = "0" + value9;
- }
- text9.TextString = value9;
- text9.Position = new Point3d(xx1, yy1, 0);
- text9.Height = D4_8;
- text9.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 3);
- text9.Layer = layername;
- text9.TextStyleId = HZ;
- text9.WidthFactor = 0.75;
-
- text9.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(text9);
- traction.AddNewlyCreatedDBObject(text9, true);
-
- //Y坐标上标
- xx1 = xx - D4_8 * 0.75 * 4 - D1;
- yy1 = yy + D2 + D4_8 - D3;
- DBText text10 = new DBText();
- int value10 = (int)(yy / 1000 / 100);
- text10.TextString = value10.ToString();
- text10.Position = new Point3d(xx1, yy1, 0);
- text10.Height = D3;
- text10.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 3);
- text10.Layer = layername;
- text10.HorizontalMode = TextHorizontalMode.TextRight;
- text10.VerticalMode = TextVerticalMode.TextTop;
-
- xx2 = xx - D4_8 * 0.75 * 4 - D1;
- yy2 = yy + D2 + D4_8;
- text10.AlignmentPoint = new Point3d(xx2, yy2, 0);
- text10.TextStyleId = HZ;
- text10.WidthFactor = 0.75;
-
- text10.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(text10);
- traction.AddNewlyCreatedDBObject(text10, true);
-
-
-
-
-
- //左下
- xx = LB.X;
- yy = LB.Y;
-
- //X坐标
- xx1 = xx - D4_8 * 0.75 * 2 - D1;
- yy1 = yy - D22 + D2;
-
- DBText text11 = new DBText();
- string value11 = (xx / 1000.0 % 100).ToString("F1");
- if (value11.Length == 3)
- {
- value11 = "0" + value11;
- }
- text11.TextString = value11;
- text11.Position = new Point3d(xx1, yy1, 0);
- text11.Height = D4_8;
- text11.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 3);
- text11.Layer = layername;
- text11.TextStyleId = HZ;
- text11.WidthFactor = 0.75;
-
- text11.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(text11);
- traction.AddNewlyCreatedDBObject(text11, true);
-
-
- //带号
- xx1 = xx - D4_8 * 0.75 * 2 - D3 * 0.75 * 3 - D2;
- yy1 = yy - D22 + D7 - (D4_8 - D3);
-
- if (TKInfo.DH != -1)
- {
- DH = TKInfo.DH * 10 + (int)xx / 1000 / 100;
- }
- else
- {
- DH = (int)xx / 1000 / 100;
- }
- DBText text12 = new DBText();
- text12.TextString = DH.ToString();
- text12.Position = new Point3d(xx1, yy1, 0);
- text12.Height = D3;
- text12.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 3);
- text12.Layer = layername;
- text12.HorizontalMode = TextHorizontalMode.TextRight;
- text12.VerticalMode = TextVerticalMode.TextTop;
-
- xx2 = xx - D4_8 * 0.75 * 2 - D2;
- yy2 = yy - D22 + D7;
- text12.AlignmentPoint = new Point3d(xx2, yy2, 0);
- text12.TextStyleId = HZ;
- text12.WidthFactor = 0.75;
-
- text12.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(text12);
- traction.AddNewlyCreatedDBObject(text12, true);
-
-
-
- //Y坐标
- xx1 = xx - D4_8 * 0.75 * 4 - D1;
- yy1 = yy + D2;
- DBText text13 = new DBText();
- string value13 = (yy / 1000.0 % 100).ToString("F1");
- if (value13.Length == 3)
- {
- value13 = "0" + value13;
- }
- text13.TextString = value13;
- text13.Position = new Point3d(xx1, yy1, 0);
- text13.Height = D4_8;
- text13.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 3);
- text13.Layer = layername;
- text13.TextStyleId = HZ;
- text13.WidthFactor = 0.75;
-
- text13.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(text13);
- traction.AddNewlyCreatedDBObject(text13, true);
-
- //Y坐标上标
- xx1 = xx - D4_8 * 0.75 * 4 - D1;
- yy1 = yy + D2 + D4_8 - D3;
- DBText text14 = new DBText();
- int value14 = (int)(LB.Y / 1000 / 100);
- text14.TextString = value14.ToString();
- text14.Position = new Point3d(xx1, yy1, 0);
-
- text14.Height = D3;
- text14.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 3);
- text14.Layer = layername;
- text14.HorizontalMode = TextHorizontalMode.TextRight;
- text14.VerticalMode = TextVerticalMode.TextTop;
-
- xx2 = xx - D4_8 * 0.75 * 4 - D1;
- yy2 = yy + D2 + D4_8;
- text14.AlignmentPoint = new Point3d(xx2, yy2, 0);
- text14.TextStyleId = HZ;
- text14.WidthFactor = 0.75;
-
- text14.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(text14);
- traction.AddNewlyCreatedDBObject(text14, true);
-
-
-
-
-
- //右上
- xx = RT.X;
- yy = RT.Y;
-
- //X坐标
- xx1 = xx - D4_8 * 0.75 * 2 - D1;
- yy1 = yy + D22 - D7;
-
- DBText text15 = new DBText();
- string value15 = (RT.X / 1000.0 % 100).ToString("F1");
- if (value15.Length == 3)
- {
- value15 = "0" + value15;
- }
- text15.TextString = value15;
- text15.Position = new Point3d(xx1, yy1, 0);
- text15.Height = D4_8;
- text15.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 3);
- text15.Layer = layername;
- text15.TextStyleId = HZ;
- text15.WidthFactor = 0.75;
-
- text15.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(text15);
- traction.AddNewlyCreatedDBObject(text15, true);
-
-
- //带号
- xx1 = xx - D4_8 * 0.75 * 2 - D3 * 0.75 * 3 - D2;
- yy1 = yy + D22 - D7 + (D4_8 - D3);
-
- if (TKInfo.DH != -1)
- {
- DH = TKInfo.DH * 10 + (int)RT.X / 1000 / 100;
- }
- else
- {
- DH = (int)RT.X / 1000 / 100;
- }
- DBText text16 = new DBText();
- text16.TextString = DH.ToString();
- text16.Position = new Point3d(xx1, yy1, 0);
-
- text16.Height = D3;
- text16.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 3);
- text16.Layer = layername;
- text16.HorizontalMode = TextHorizontalMode.TextRight;
- text16.VerticalMode = TextVerticalMode.TextTop;
-
- xx2 = xx - D4_8 * 0.75 * 2 - D2;
- yy2 = yy + D22 - D7 + D4_8;
- text16.AlignmentPoint = new Point3d(xx2, yy2, 0);
- text16.TextStyleId = HZ;
- text16.WidthFactor = 0.75;
-
- text16.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(text16);
- traction.AddNewlyCreatedDBObject(text16, true);
-
-
-
- //Y坐标
- xx1 = xx + D7;
- yy1 = yy + D2;
- DBText text17 = new DBText();
- string value17 = (RT.Y / 1000.0 % 100).ToString("F1");
- if (value17.Length == 3)
- {
- value17 = "0" + value17;
- }
- text17.TextString = value17;
- text17.Position = new Point3d(xx1, yy1, 0);
- text17.Height = D4_8;
- text17.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 3);
- text17.Layer = layername;
- text17.TextStyleId = HZ;
- text17.WidthFactor = 0.75;
-
- text17.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(text17);
- traction.AddNewlyCreatedDBObject(text17, true);
-
- //Y坐标上标
- xx1 = xx + D7;
- yy1 = yy + D2 + D4_8 - D3;
-
- DBText text18 = new DBText();
- int value18 = (int)(RT.Y / 1000 / 100);
- text18.TextString = value18.ToString();
- text18.Position = new Point3d(xx1, yy1, 0);
- text18.Height = D3;
- text18.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 3);
- text18.Layer = layername;
- text18.HorizontalMode = TextHorizontalMode.TextRight;
- text18.VerticalMode = TextVerticalMode.TextTop;
-
- xx2 = xx + D7;
- yy2 = yy + D2 + D4_8;
- text18.AlignmentPoint = new Point3d(xx2, yy2, 0);
- text18.TextStyleId = HZ;
- text18.WidthFactor = 0.75;
-
- text18.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(text18);
- traction.AddNewlyCreatedDBObject(text18, true);
-
-
- //右下
- xx = RB.X;
- yy = RB.Y;
-
- //X坐标
- xx1 = xx - D4_8 * 0.75 * 2 - D1;
- yy1 = yy - D22 + D2;
-
- DBText text19 = new DBText();
- string value19 = (RB.X / 1000.0 % 100).ToString("F1");
- if (value19.Length == 3)
- {
- value19 = "0" + value19;
- }
- text19.TextString = value19;
- text19.Position = new Point3d(xx1, yy1, 0);
- text19.Height = D4_8;
- text19.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 3);
- text19.Layer = layername;
- text19.TextStyleId = HZ;
- text19.WidthFactor = 0.75;
-
- text19.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(text19);
- traction.AddNewlyCreatedDBObject(text19, true);
-
-
- //带号
- xx1 = xx - D4_8 * 0.75 * 2 - D3 * 0.75 * 3 - D2;
- yy1 = yy - D22 + D7 - D3;
- if (TKInfo.DH != -1)
- {
- DH = TKInfo.DH * 10 + (int)RT.X / 1000 / 100;
- }
- else
- {
- DH = (int)RT.X / 1000 / 100;
- }
- DBText text20 = new DBText();
- text20.TextString = DH.ToString();
- text20.Position = new Point3d(xx1, yy1, 0);
- text20.Height = D3;
- text20.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 3);
- text20.Layer = layername;
- text20.HorizontalMode = TextHorizontalMode.TextRight;
- text20.VerticalMode = TextVerticalMode.TextTop;
-
- xx2 = xx - D4_8 * 0.75 * 2 - D2;
- yy2 = yy - D22 + D7;
- text20.AlignmentPoint = new Point3d(xx2, yy2, 0);
- text20.TextStyleId = HZ;
- text20.WidthFactor = 0.75;
-
- text20.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(text20);
- traction.AddNewlyCreatedDBObject(text20, true);
-
-
-
- //Y坐标
- xx1 = xx + D7;
- yy1 = yy + D2;
- DBText text21 = new DBText();
- string value21 = (RB.Y / 1000.0 % 100).ToString("F1");
- if (value21.Length == 3)
- {
- value21 = "0" + value21;
- }
- text21.TextString = value21;
- text21.Position = new Point3d(xx1, yy1, 0);
- text21.Height = D4_8;
- text21.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 3);
- text21.Layer = layername;
- text21.TextStyleId = HZ;
- text21.WidthFactor = 0.75;
-
- text21.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(text21);
- traction.AddNewlyCreatedDBObject(text21, true);
-
- //Y坐标上标
- xx1 = xx + D7;
- yy1 = yy + D2 + D4_8 - D3;
-
- DBText text22 = new DBText();
- int value22 = (int)(RB.Y / 1000 / 100);
- text22.TextString = value18.ToString();
- text22.Position = new Point3d(xx1, yy1, 0);
- text22.Height = D3;
- text22.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 3);
- text22.Layer = layername;
- text22.HorizontalMode = TextHorizontalMode.TextRight;
- text22.VerticalMode = TextVerticalMode.TextTop;
-
- xx2 = xx + D7;
- yy2 = yy + D2 + D4_8;
- text22.AlignmentPoint = new Point3d(xx2, yy2, 0);
- text22.TextStyleId = HZ;
- text22.WidthFactor = 0.75;
-
- text22.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(text22);
- traction.AddNewlyCreatedDBObject(text22, true);
-
-
-
- document.Database.SaveAs(TKInfo.SV + "\\" + Number.ToString() + ".dwg", true, DwgVersion.AC1021, document.Database.SecurityParameters);
- //database.SaveAs(TKInfo.SV + "\\" + Number.ToString() + ".dwg", DwgVersion.AC1024);
- traction.Commit();
-
- //}
- //catch (GrxCAD.Runtime.Exception e)
- //{
- // MessageBox.Show (e.Message);
- //}
- //finally
- //{
- traction.Dispose();
- documentlock.Dispose();
- //}
-
- }
-
-
-
-
-
- public void createTextStyle()
- {
- Database database = HostApplicationServices.WorkingDatabase;
-
- Transaction traction = database.TransactionManager.StartTransaction();
-
- DocumentLock documentlock = GrxCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
-
-
-
- TextStyleTable styletable = traction.GetObject(database.TextStyleTableId, OpenMode.ForWrite) as TextStyleTable;
-
- string stylename = "ht";
- if (styletable.Has(stylename) == false)
- {
- TextStyleTableRecord R1 = new TextStyleTableRecord();
- R1.Name = stylename;
- //R1.FileName = "方正细等线简体";
- R1.FileName = "SIMHEI.TTF";
- //record.BigFontFileName = "hztxt.shx";
- R1.ObliquingAngle = 0;
- R1.XScale = 1;
- ObjectId textstyleID = styletable.Add(R1);
- traction.AddNewlyCreatedDBObject(R1, true);
- //database.TextStyleId = textstyleID;
- }
- stylename = "HZ";
- if (styletable.Has(stylename) == false)
- {
- TextStyleTableRecord R1 = new TextStyleTableRecord();
- R1.Name = stylename;
- //R1.FileName = "方正细等线简体";
- R1.FileName = "rs.shx";
- R1.BigFontFileName = "hztxt.shx";
- R1.ObliquingAngle = 0;
- R1.XScale = 0.75;
- ObjectId textstyleID = styletable.Add(R1);
- traction.AddNewlyCreatedDBObject(R1, true);
- //database.TextStyleId = textstyleID;
- }
- stylename = "st";
- if (styletable.Has(stylename) == false)
- {
- TextStyleTableRecord R1 = new TextStyleTableRecord();
- R1.Name = stylename;
- //R1.FileName = "方正细等线简体";
- R1.FileName = "STSONG.TTF";
- //R1.BigFontFileName = "hztxt.shx";
- R1.ObliquingAngle = 0;
- R1.XScale = 1;
- ObjectId textstyleID = styletable.Add(R1);
- traction.AddNewlyCreatedDBObject(R1, true);
- //database.TextStyleId = textstyleID;
- }
- stylename = "Standard";
- if (styletable.Has(stylename) == false)
- {
- TextStyleTableRecord R1 = new TextStyleTableRecord();
- R1.Name = stylename;
- //R1.FileName = "方正细等线简体";
- R1.FileName = "rs.shx";
- R1.BigFontFileName = "hztxt.shx";
- R1.ObliquingAngle = 0;
- R1.XScale = 0.75;
- ObjectId textstyleID = styletable.Add(R1);
- traction.AddNewlyCreatedDBObject(R1, true);
- //database.TextStyleId = textstyleID;
- }
- stylename = "123";
- if (styletable.Has(stylename) == false)
- {
- TextStyleTableRecord R1 = new TextStyleTableRecord();
- R1.Name = stylename;
- //R1.FileName = "方正细等线简体";
- R1.FileName = "SIMHEI.TTF";
- //R1.BigFontFileName = "hztxt.shx";
- R1.ObliquingAngle = 0;
- R1.XScale = 0.75;
- ObjectId textstyleID = styletable.Add(R1);
- traction.AddNewlyCreatedDBObject(R1, true);
- //database.TextStyleId = textstyleID;
- }
- stylename = "12";
- if (styletable.Has(stylename) == false)
- {
- TextStyleTableRecord R1 = new TextStyleTableRecord();
- R1.Name = stylename;
- //R1.FileName = "方正细等线简体";
- R1.FileName = "complex.shx";
- //R1.BigFontFileName = "hztxt.shx";
- R1.ObliquingAngle = 0;
- R1.XScale = 0.75;
- ObjectId textstyleID = styletable.Add(R1);
- traction.AddNewlyCreatedDBObject(R1, true);
- //database.TextStyleId = textstyleID;
- }
-
- stylename = "细等线体";
- if (styletable.Has(stylename) == false)
- {
- TextStyleTableRecord R1 = new TextStyleTableRecord();
- R1.Name = stylename;
- //R1.FileName = "方正细等线简体";
- R1.FileName = "FZXDXJW.TTF";
- //record.BigFontFileName = "hztxt.shx";
- R1.ObliquingAngle = 0;
- R1.XScale = 1;
- ObjectId textstyleID = styletable.Add(R1);
- traction.AddNewlyCreatedDBObject(R1, true);
- //database.TextStyleId = textstyleID;
- }
-
- stylename = "中等线体";
- if (styletable.Has(stylename) == false)
- {
- TextStyleTableRecord R2 = new TextStyleTableRecord();
- R2.Name = stylename;
- //R2.FileName = "方正中等线简体";
- R2.FileName = "FZZDXJW.TTF";
- //record.BigFontFileName = "hztxt.shx";
- R2.ObliquingAngle = 0;
- R2.XScale = 1;
- ObjectId textstyleID = styletable.Add(R2);
- traction.AddNewlyCreatedDBObject(R2, true);
- //database.TextStyleId = textstyleID;
- }
- stylename = "宋体";
- if (styletable.Has(stylename) == false)
- {
- TextStyleTableRecord R3 = new TextStyleTableRecord();
- R3.Name = stylename;
- //R3.FileName = "华文宋体";
- R3.FileName = "STSONG.TTF";
- //record.BigFontFileName = "hztxt.shx";
- R3.ObliquingAngle = 0;
- R3.XScale = 1;
- ObjectId textstyleID = styletable.Add(R3);
- traction.AddNewlyCreatedDBObject(R3, true);
- //database.TextStyleId = textstyleID;
- }
-
- traction.Commit();
- documentlock.Dispose();
-
- }
-
-
-
-
- public ObjectId gettextstyleID(string Name)
- {
- Database database = HostApplicationServices.WorkingDatabase;
-
- Transaction traction = database.TransactionManager.StartTransaction();
-
- DocumentLock documentlock = GrxCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
-
-
-
- TextStyleTable styletable = traction.GetObject(database.TextStyleTableId, OpenMode.ForWrite) as TextStyleTable;
- //BlockTableRecord blocktablerecord = traction.GetObject(blocktable[BlockTableRecord.ModelSpace],
- // OpenMode.ForWrite) as BlockTableRecord;
- TextStyleTableRecord record = traction.GetObject(styletable[Name], OpenMode.ForRead) as TextStyleTableRecord;
- ObjectId ID = record.ObjectId;
- traction.Commit();
- documentlock.Dispose();
-
- return ID;
-
-
- }
-
-
-
-
- private void zoom()
- {
- Document document = GrxCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
- Database database = HostApplicationServices.WorkingDatabase;
- Editor editor = GrxCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
- using (Transaction traction = database.TransactionManager.StartTransaction())
- {
-
- //删除坐标原点多段线
- Editor ed = GrxCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
- Point3d pt1 = new Point3d(-1, 1, 0);
- Point3d pt2 = new Point3d(0, 0, 0);
- PromptSelectionResult psr = ed.SelectCrossingWindow(pt1, pt2);
- if (psr.Status == PromptStatus.OK)
- {
- SelectionSet sSet = psr.Value;
- ObjectId[] ids = sSet.GetObjectIds();
- foreach (ObjectId id in ids)
- {
- Entity entity1 = traction.GetObject(id, OpenMode.ForWrite) as Entity;
- entity1.Erase();
- }
- }
-
- ViewTableRecord currview = editor.GetCurrentView();
- currview.CenterPoint = new Point2d((RT.X - LT.X) / 2 + LT.X, (LT.Y - LB.Y) / 2 + LB.Y);
- currview.ViewDirection = new Vector3d(0, 0, 1);
- currview.Width = RT.X - LT.X + TKInfo.BLC / 10;
- currview.Height = LT.Y - LB.Y + TKInfo.BLC / 10;
- editor.SetCurrentView(currview);
- traction.Commit();
- }
- }
-
-
-
-
- private string GetNumber(Point3d p1, Point3d p2)
- {
- string TValue = "";
-
- Document document = GrxCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
- Database database = HostApplicationServices.WorkingDatabase;
-
-
- using (Transaction traction = database.TransactionManager.StartTransaction())
- {
- DocumentLock documentlock = GrxCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
-
- BlockTable blocktable = traction.GetObject(database.BlockTableId,
- OpenMode.ForRead) as BlockTable;
-
- Editor editor = GrxCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
- TypedValue[] typed = new TypedValue[1];
- typed.SetValue(new TypedValue((int)DxfCode.Start, "Polyline,LWPolyline"), 0);
- SelectionFilter filter = new SelectionFilter(typed);
-
- PromptSelectionResult psr = editor.SelectWindow(p1, p2, filter);
- if (psr.Status == PromptStatus.OK)
- {
- SelectionSet selectionset = psr.Value;
-
- ObjectId[] obj = new ObjectId[selectionset.Count];
- obj = selectionset.GetObjectIds();
- for (int i = 0; i < obj.Length; i++)
- {
- ObjectId objid = obj[i];
- Entity entity = (Entity)traction.GetObject(objid, OpenMode.ForRead);
-
- if (entity is Face)
- {
- TypedValue[] typed_T = new TypedValue[1];
- typed_T.SetValue(new TypedValue((int)DxfCode.Start, "Text"), 0);
- SelectionFilter filter_T = new SelectionFilter(typed_T);
- PromptSelectionResult psr_T = editor.SelectWindow(p1, p2, filter_T);
-
- if (psr_T.Status == PromptStatus.OK)
- {
- SelectionSet set_T = psr_T.Value;
- ObjectId[] obj_T = new ObjectId[set_T.Count];
- obj_T = set_T.GetObjectIds();
- for (int j = 0; j < obj_T.Length; j++)
- {
-
- ObjectId id_T = obj_T[i];
- Entity entits = (Entity)traction.GetObject(id_T, OpenMode.ForRead);
- if (entits is DBText)
- {
- DBText text = entits as DBText;
- TValue = text.TextString;
- break;
- }
- }
- }
- break;
- }
- else if (entity is Polyline)
- {
-
- TypedValue[] typed_T = new TypedValue[1];
- typed_T.SetValue(new TypedValue((int)DxfCode.Start, "Text"), 0);
- SelectionFilter filter_T = new SelectionFilter(typed_T);
- PromptSelectionResult psr_T = editor.SelectWindow(p1, p2, filter_T);
-
- if (psr_T.Status == PromptStatus.OK)
- {
- SelectionSet set_T = psr_T.Value;
- ObjectId[] obj_T = new ObjectId[set_T.Count];
- obj_T = set_T.GetObjectIds();
- for (int j = 0; j < obj_T.Length; j++)
- {
-
- ObjectId id_T = obj_T[i];
- Entity entits = (Entity)traction.GetObject(id_T, OpenMode.ForRead);
- if (entits is DBText)
- {
- DBText text = entits as DBText;
- TValue = text.TextString;
- break;
- }
- }
- }
- break;
-
- }
-
- }
-
- }
- documentlock.Dispose();
- traction.Commit();
- }
-
- return TValue;
- }
-
-
- private void filjtb(string num,Transaction traction,ObjectId HZ,BlockTableRecord blocktablerecord,double xx2,double yy2,double height)
- {
- DBText text_L = new DBText();
- text_L.TextString = num;
- text_L.Position = new Point3d(xx2, yy2, 0);
- text_L.Height = height;
- text_L.Color = GrxCAD.Colors.Color.FromColorIndex(GrxCAD.Colors.ColorMethod.ByColor, 4);
- text_L.Layer = layername;
- text_L.TextStyleId = HZ;
- text_L.HorizontalMode = TextHorizontalMode.TextCenter;
- text_L.VerticalMode = TextVerticalMode.TextVerticalMid;
- text_L.AlignmentPoint = new Point3d(xx2, yy2, 0);
-
- text_L.SetDatabaseDefaults();
- blocktablerecord.AppendEntity(text_L);
- traction.AddNewlyCreatedDBObject(text_L, true);
- }
-
- }
-
- }
|