|
|
WebLook Basics
Data Extraction
WebLook, like FastLook Plus, has the ability to extract data from an AutoCAD drawing. This data may take the form of:
- Block attributes
- Extended entity data
- Object data
- SQL links
The example below uses VBScript inside Internet Explorer, but you can easily use other popular scripting environments such as JavaScript or JScript.
|
The following is sample code, which shows a very simple integration where the user picks a block, WebLook pulls the data associated with the picked block and the browser presents the data in a dialog box. Obviously, in your application the data could be used in any number of ways.
Example
//This code is copied into the HEADER section
<script ID="clientEventHandlersVBS" LANGUAGE="VBscript">
Dim TagNew
DIM ValueNew
Sub WebLook1_WebLookEvent(EventNumber)
' This is a handler for the potential WebLook events
Select Case EventNumber
Case 2 'User has double-clicked in the WebLook window
Case 4 'Sent when the drawing window has been invalidated.
Case 5 'Sent when the drawing window has finished painting
Case 10 'Sent when FastLook is in entity pick mode and the user has selected an entity.
Call ExtractData
Case 27 'Redline file status changed
Case 28 'Redline/Link selection set changed - user selected or deselected a Redline or Link entity.
Case 30 'WebLook is viewing a new image
End Select
End Sub
Sub ExtractData
success = WebLook1.CmdStr("[GetFirstEntityData]")
If success > 0 Then
DataString = WebLook1.DataString
StringSeparate(DataString)
Msg = Msg + Chr(13) & Chr(10) & TagNew + " = " & ValueNew
Else
If success < 0 Then
MsgBox "GetNextEntityData failed! retVal=" & success
Else
MsgBox "No Attributes were found!"
End If
End If
While success > 0
success = WebLook1.CmdStr("[GetNextEntityData]")
If success > 0 Then
DataString = WebLook1.DataString
StringSeparate(DataString)
Msg = Msg + Chr(13) & Chr(10) & TagNew + " = " & ValueNew
Else
If success < 0 Then
MsgBox "GetNextEntityData failed! retVal=" & success
End If
End If
Wend
MsgBox Msg
End Sub
Sub StringSeparate(DataString)
'This sub is parsing the string that is returned from the WebLook server. It looks for the
'delimiter, which is the pipe character (|), and splits the string in two.
For i = 1 To Len(DataString)
NewChar = Mid(DataString, i, 1)
If NewChar = "|" Then
TagNew = Mid(DataString, 1, i - 1)
ValueNew = Mid(DataString, i + 1, Len(DataString))
End If
Next
End Sub
</script>
//Copy this code into the BODY of the page.
<form>
<input type="button" value="Pick Block Attribute Data"
onClick="WebLook1.SendFLCommand 171,0">
</form>
<object CLASSID="CLSID:0BFB6D15-B6E1-11D3-8BED-00104B885ED1"
ID="WebLook1" HEIGHT="300" WIDTH="350"
CODEBASE="http://www.kamelsoftware.com/weblook.cab">
<param NAME="src" VALUE="http://www.kamelsoftware.com/blocks.dwg.ifl">
</object>
|
|
|