请教delphi控制AutoCAD问题
我用VB写了一段代码,望能将其转换成delphi代码,如下:<br/>Sub AddPath()<br/> dim AcadApp as Object<br/> dim CurPath As Variant<br/> dim Path as string<br/> Path="c:\wmz"<br/> set AcadApp=CreatObject("AutoCAD.Application.16)<br/> AcadApp.Visible=True<br/> AcadApp.Application.Preferences.Files=Path & ";" & AcadApp.Application.Preferences.Files<br/> AcadApp.Quit<br/>end Sub<br/>注:以上代码是将路径为"c:\wmz"的加到AutoCAD的支持路径的最前面中去<br/> <div>在网上搜索了一下,终于找到可以和前面VB代码有相同作用的delphi代码了,不知可不可行:</div><div></div><div>procedure TForm1.Button1Click(Sender: TObject);<br/> var</div><div></div><div> MyReg : TRegistry;<br/> f:string;<br/>begin</div><div></div><div> MyReg := TRegistry.Create;</div><div></div><div> MyReg.RootKey := HKEY_CURRENT_USER;</div><div></div><div> try</div><div></div><div> if MyReg.OpenKey('\Software\Autodesk\AutoCAD\R16.0\ACAD-201:804\Profiles\<<未命名配置>>\General',true) then<br/> begin<br/> f:= 'c:\wmz;' + MyReg.ReadString('ACAD');<br/> MyReg.WriteString('ACAD',f);<br/> MyReg.CloseKey;<br/> end;<br/> finally</div><div></div><div> MyReg.Free;</div><div></div><div> end;</div> <p>我这里有一段给你参考吧</p><p>procedure TForm1.Button4Click(Sender: TObject);<br/>var<br/> vCadApp:Variant;<br/> vActiveDoc:Variant;<br/> sfilename,cmdsfile:string;<br/> i : integer;<br/>begin<br/> sfilename := ParamStr(1); //取运行参数,也就是带处理的dwg文件<br/> vCadApp := CreateOleObject('autoCad.Application');<br/> vCadApp.Visible := true;<br/> vActiveDoc := vCadApp.ActiveDocument;</p><p> cmdsfile := ExtractFileDir(Application.ExeName)+'\zn_main_s.fas';<br/> cmdsfile := StringReplace(cmdsfile,'\','\\', );<br/> vActiveDoc.SendCommand('(load "'+cmdsfile+'")'+#13);<br/> vActiveDoc.SendCommand('(print "\n欢迎使用室内分布系统CAD辅助画图软件,版权属于50868,\nEmail:050868@163.com,陈海容2006年11月11日" )'+#13);<br/> cmdsfile := ExtractFileDir(Application.ExeName);<br/> cmdsfile := StringReplace(cmdsfile,'\','\\', );<br/> vActiveDoc.SendCommand('(zn_main_s_t "'+cmdsfile + '")'+#13);<br/> vActiveDoc.SendCommand('(repeat 400(print ))'+#13);<br/> end;</p> <div>非常感谢,就本问题而言,我只要下面这两句就够了</div><div> vActiveDoc := vCadApp.ActiveDocument;</div><div> vActiveDoc.SendCommand('(load "'+cmdsfile+'")'+#13);</div>
页:
[1]