Distinguished Contributor
Posts: 393
Registered: ‎08-15-2003
Message 1 of 5 (298 Views)
Accepted Solution

View Block definition from external program

298 Views, 4 Replies
08-20-2012 10:07 PM



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)





*Expert Elite*
Posts: 1,569
Registered: ‎10-08-2008
Message 2 of 5 (280 Views)

Re: View Block definition from external program

08-21-2012 04:10 AM in reply to: alex_b

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



   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.ImageLocation = dial.FileName
            End If
        End Using
    End Sub

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    End Sub



Distinguished Contributor
Posts: 393
Registered: ‎08-15-2003
Message 3 of 5 (277 Views)

Re: View Block definition from external program

08-21-2012 04:45 AM in reply to: 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


*Expert Elite*
Posts: 946
Registered: ‎04-27-2009
Message 4 of 5 (261 Views)

Re: View Block definition from external program

08-21-2012 09:16 AM in reply to: alex_b

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.

Distinguished Contributor
Posts: 393
Registered: ‎08-15-2003
Message 5 of 5 (255 Views)

Re: View Block definition from external program

08-21-2012 10:04 AM in reply to: norman.yuan



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.



You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community