Re: how to use vb.net/netlink to export a dxf file
- To: mathgroup at smc.vnet.net
- Subject: [mg101849] Re: how to use vb.net/netlink to export a dxf file
- From: "Hans Michel" <hmichel at cox.net>
- Date: Sun, 19 Jul 2009 07:15:31 -0400 (EDT)
- References: <h3pesb$ohj$1@smc.vnet.net> <h3s1up$63u$1@smc.vnet.net>
Jonk: We need more information. And in the end it may be fuitile without that infoormation. What version of Mathematica, what version of .NETLink? Are you sure .NETLink is properly installed. see this message from the group "[mg55482] Re: [mg55466] Re: using Mathematica to plot in visual studio". So from the first line code depending on the version of NETLink your will get an an error. Are your using Visual Studio? Can you set break points? What errors are you getting if any. And please don't just copy paste the errors (Doing so simply means you did not read the errors nor care to see if they are simple errors). Your goals are admirable but this is not about who knows VB. This is about MathLink and in particular here NETLink. You could have asked how to do this using C or C++ and those who know how could contribute. When you export from the mathematica front end, the front end and the kernel communicate in ways WRI have set out. I don't have NETLink installed anymore and I am relying on memory. But there are some Commands that won't run in NETLink as those command require the front end to start some process. For example SetDirectory maybe one of those commands. Is SetDirectory telling the Kernel or the FrontEnd where to put things? Comment out that line and hard code to your root drive "C:\". This is what I would do, because the goal is to export to DXF, the secondary goal is to place it where you want. Keep the path stuff simple at first doing this avoids typo in a path. Pleasw note that instead of exporting a DXF file fist just see if you can export a string to a text file. I can't recall if Export even works in this environment. That is the greater question. Can you use Export in the ..NETLink or MathLink without the Front End? When one write a application that use MathLink, J/Link NETLLink to interface with the Mathematica Kernel. You are in essence replacing the Front End. So all the things the front end handles and you need you will have to take care of. Hans "jonk" <jkontuly at gmail.com> wrote in message news:h3s1up$63u$1 at smc.vnet.net... > On Jul 17, 5:05 am, Bill <WDWNORW... at aol.com> wrote: >> Hi: >> >> I'm not familiar with VB code, but the following may be of furthur >> interest to you... >> >> http://library.wolfram.com/infocenter/Conferences/5812/ >> >> You can do more than just draw pretty pictures with this, it'll output >> parametric sets of equations that you can use to calculate intersections, >> tangents and the like. It's written in Mathematica 5.2 code, but >> shouldn't be too difficult to translate to a latter version, if desired. >> >> Regards, >> >> Bill > > Bill, > Thanks for bringing this to my attention. It does indeed look very > interesting. > > If anyone does know VB. I would still love to hear why this does work. > In general I am trying to call Mathematica from a vb program,evaluate > something that produces a plot and then export that plot as a dxf to > my desktop. Sounds easy and I know you can do it if you are working in > Mathematica but for some reason I can not get it to work. And again > thanks Bill for the response. > > ' This launches the Mathematica kernel: > Dim ml As IKernelLink = MathLinkFactory.CreateKernelLink() > > ml.Evaluate("SetDirectory[\""C:/Documents And Settings/User/Desktop/ > \""]") > ml.WaitForAnswer() > > ml.Evaluate("gr = Plot[ Sin[x], {x, 0, 2*Pi}]") > ml.Evaluate("Export[\""testMATH.dxf\"",gr, \""DXF\""]") > ml.Close() >