Block Viewer for AutoCAD 2008

Block Viewer for AutoCAD 2008

Anonymous
Not applicable
428 Views
3 Replies
Message 1 of 4

Block Viewer for AutoCAD 2008

Anonymous
Not applicable
Hi,

I'm looking for an ocx te create a block viewer in my AutoCAD VBa code. I
have searched the Internet but can't find a proper one. What must it do,
well very simple, just show a 2D Block in an Image in a dialog.

Has anyone experience with this?

TIA

/Leo
0 Likes
429 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Quite a while ago I made an application for making a block library that was in a database. What I did for images was make export WMF (with and without backgrounds). This routine actually resizes the application window to get a the smallest bounding box for the WMF image. WMF works well with VBA userforms. Lots of code in here you don't need, this was part of a detail database cataloging application. Here is a snip of code:

'~~~start code, after you have wblocked the objects
'you wish to make an image of
Set wBlkDwg = Application.Documents.Open(catDtlPath & catDetailID & ".dwg")
For Each ent In ssetUserSel
ent.Move Origin, ZeroPnt
'moving all objects relative of origin -disregard
Next
wBlkDwg.Application.ZoomExtents
'chngFld wBlkDwg, "DTL_ID", catDetailID
'chngFld wBlkDwg, "Entered_By", Environ("USERNAME")
acdPref.OpenSave.SavePreviewThumbnail = True
wBlkDwg.PurgeAll
Sleep (250)
wBlkDwg.Save
Sleep (250)
'create new selection set in wblkdwg
Set ssetUserSel = wBlkDwg.SelectionSets.Add("SSdtlCat")
rectMax(0) = rectMax(0) - 1
If ssBBox = False Then GoTo errCaseC
ssetUserSel.Select acSelectionSetWindow, rectMax, rectMin
Sleep (250)
'wmf export with picture cropping, with and without backgrounds
wBlkDwg.width = Round(wBlkDwg.width / (rectMax(0) - rectMin(0))) * (rectMax(1) - rectMin(1))
wBlkDwg.Application.ZoomWindow rectMin, rectMax
wBlkDwg.Application.Update
wBlkDwg.Regen acActiveViewport
wBlkDwg.SetVariable "WMFBKGND", 0
wBlkDwg.Export catWmfPath & catDetailID & "-OFF", "WMF", ssetUserSel
Sleep (250)
wBlkDwg.SetVariable "WMFBKGND", 1
wBlkDwg.Export catWmfPath & catDetailID & "-ON", "WMF", ssetUserSel
'~~~end code

Here is dirty way to make SLD images: (qm = """")

wBlkDwg.SendCommand ("(command " & qM & "mslide" & qM & _
" " & qM & Replace(catSldPath, "\", "\\") & _
Replace(catDetailID, "\", "\\") & ".sld" & qM & ")" & vbCr)

Hope it helps, no time to explain further. I'm sure there are lots of ways to do this.
0 Likes
Message 3 of 4

Anonymous
Not applicable
Hi!

Thnx for your input It is not really what I'm searching for. I'm more
looking for a realtime Block Viewer. Via a dialog a user can give options
which are translated in a Block and I want to show the result directly in
teh dialog.

/Leo

schreef in bericht news:5822422@discussion.autodesk.com...
Quite a while ago I made an application for making a block library that was
in a database. What I did for images was make export WMF (with and without
backgrounds). This routine actually resizes the application window to get a
the smallest bounding box for the WMF image. WMF works well with VBA
userforms. Lots of code in here you don't need, this was part of a detail
database cataloging application. Here is a snip of code:

'~~~start code, after you have wblocked the objects
'you wish to make an image of
Set wBlkDwg = Application.Documents.Open(catDtlPath & catDetailID & ".dwg")
For Each ent In ssetUserSel
ent.Move Origin, ZeroPnt
'moving all objects relative of origin -disregard
Next
wBlkDwg.Application.ZoomExtents
'chngFld wBlkDwg, "DTL_ID", catDetailID
'chngFld wBlkDwg, "Entered_By", Environ("USERNAME")
acdPref.OpenSave.SavePreviewThumbnail = True
wBlkDwg.PurgeAll
Sleep (250)
wBlkDwg.Save
Sleep (250)
'create new selection set in wblkdwg
Set ssetUserSel = wBlkDwg.SelectionSets.Add("SSdtlCat")
rectMax(0) = rectMax(0) - 1
If ssBBox = False Then GoTo errCaseC
ssetUserSel.Select acSelectionSetWindow, rectMax, rectMin
Sleep (250)
'wmf export with picture cropping, with and without backgrounds
wBlkDwg.width = Round(wBlkDwg.width / (rectMax(0) - rectMin(0))) *
(rectMax(1) - rectMin(1))
wBlkDwg.Application.ZoomWindow rectMin, rectMax
wBlkDwg.Application.Update
wBlkDwg.Regen acActiveViewport
wBlkDwg.SetVariable "WMFBKGND", 0
wBlkDwg.Export catWmfPath & catDetailID & "-OFF", "WMF", ssetUserSel
Sleep (250)
wBlkDwg.SetVariable "WMFBKGND", 1
wBlkDwg.Export catWmfPath & catDetailID & "-ON", "WMF", ssetUserSel
'~~~end code

Here is dirty way to make SLD images: (qm = """")

wBlkDwg.SendCommand ("(command " & qM & "mslide" & qM & _
" " & qM & Replace(catSldPath, "\", "\\") & _
Replace(catDetailID, "\", "\\") & ".sld" & qM & ")" & vbCr)

Hope it helps, no time to explain further. I'm sure there are lots of ways
to do this.
0 Likes
Message 4 of 4

Anonymous
Not applicable
I created a block manager a while ago with a preview window. Its quite involved and required a fair bit of coding. I managed to get the help I needed by searching for drawing preview.

I would post the code but its all over the place in my forms and modules.

Daniel
0 Likes