Hi
I need to view a block definition from an out-of-process app (written in C#).
The app uses True View Acctrl to as a viewer.
It works fine for whole dwgs, but when it comes to viewing just one block definition' the best I could come up with was:
<pseudo code>
start a new Autocad instance;
open the dwg in Autocad;
perform a Wblock of the block definition to some temporary file;
open and view the file in the Acctrl;
erase the temporary file;
</pseudo code>
It seems clumsy though.
Is there any API for doing this? (preferably not higher than Acad 2008)
Thanx
alex
Solved! Go to Solution.
Solved by norman.yuan. Go to Solution.
To avoid using AcCtrl.dll try the following way:
Drop on form OpenfileDialog
You can save screen of the temp drawing in jpeg file
in the same folder, then adrop this code on your form, assume
the Button1 is a button for showing selected image in your picturebox
Hth,
Public Sub OpenDialog(dial As OpenFileDialog) Using dial dial.Filter = "Jpeg Image|*.jpeg|Bitmap Image|*.bmp|Gif Image|*.gif|Png Image|*.png" dial.Title = "Open picture" dial.FileName = "atest.jpeg" dial.RestoreDirectory = True dial.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) dial.Multiselect = False If dial.ShowDialog() = DialogResult.OK Then Me.PictureBox1.Refresh() Me.PictureBox1.ImageLocation = dial.FileName End If End Using End Sub Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click OpenDialog(Me.OpenFileDialog1) End Sub
~'J'~
Hallex:
Thank you for answering.
I must confess I understand almost nothing in VB, but from what (I think) I understood, there is a misunderstanding - no pun intended - here:
I'm not trying to avoid using the Acctrl, in fact we get along very well.
My 'problem' is viewing just one block definition in a dwg (as opposed to viewing the whole dwg).
The clumsy (in my opinion) part has to do with WBLOCK-ing to a temp file etc.
I was hoping for a more elegant and effective API-based approach.
Any way, viewing just an image won't do, I need the zoom capability of the dwg format.
Thanks again
alex
Since the external program is TrueView, there is nothing you can do except for having the blocks you want to view as actual DWG file.
So, you either have to have the block definitions in a drawing to be wblocked out as drawing files in advance, or have some application process the drawing and retireve the blocks out and saved as drawing file for your True View to show it ( the process as you described), if you want the block definitions in a drawing to be viewed dynamically. However, for the latter, you need AutoCAD installed and run (by the current user) anyway, then why bother with True View? The user has AutoCAD at hand, he/she can simply open the drawing in AutoCAD and view the blocks with Design Center, saving the tedius (and possible slow) process of wblock as drawing->load into True View->Delete saved drawing.
Norman Yuan
Norman:
You confirm that my clumsy-looking solution is the best one can do under the circumstances.
<why bother with TrueView?>
Because the program addresses all versions of Autocad, so instead of having 3 or 4 in-process versions, I went for an external program.
Thank you.
alex