DWF Viewer (Read Only)
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem calling TransformPoint function

4 REPLIES 4
Reply
Message 1 of 5
Momo67
253 Views, 4 Replies

Problem calling TransformPoint function

Hi everyone!

Can someone give me a coding sample showing how to call the TransformPoint function from javascript.

Thank you for your help.

Maurice
4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: Momo67

In article , maurice.pittet@lausanne.ch says...
> Hi everyone!

Can someone give me a coding sample showing how to call the TransformPoint function from javascript.

Thank you for your help.

Maurice
>
If I understood correctly it cannot be done with JavaScript, only from VBScript.
The output of the function is passed in the parameters. JavaScript does not support ByRef
parameters, VBScript does.

Anyway, a VBScript(!) example that works for me:
Function screenToXYtxt(x, y, typ)
Dim px(3)
px(0)=2 ' Source screen coordinates
px(1)=x
px(2)=y
Dim py1(3)
py1(0)=typ
Eview.Viewer.TransformPoint px, py1

' Look a little further
px(1)=x+1
px(2)=y+1
Dim py2(3)
py2(0)=typ
Eview.Viewer.TransformPoint px, py2
accuracy=Log(py2(1)-py1(1))/Log(10)
ll=accuracy
If (accuracy>0) Then
accuracy=0
Else
accuracy = 1+Int(-accuracy)
End If
screenToXYtxt = "x="&FormatNumber(py1(1), accuracy)&" y="&FormatNumber(py1(2),
accuracy)
End Function

Sub Eview_OnMouseMove(nButtons, mX, mY, handled)
document.all.tooltip.innerHTML = "Drawing "&screenToXYtxt(mX, mY, 0) ' Drawing
document.all.tooltip2.innerHTML = "Paper "&screenToXYtxt(mX, mY, 1) ' Paper
handled = False
End Sub
--
Jos Groot Lipman
Visit www.furix.com for BetterWMF and CompareDWG
Furix BV

Message 3 of 5
ggoodnig
in reply to: Momo67

Do you have to use vb script when calling a function which locates the x, y coordinates? If so do you have an example of this? I have been using JavaScript and the viewer keeps crashing.
Message 4 of 5
Anonymous
in reply to: Momo67

Yes, unfortunately VBScript and Javascript have
completely different mechanism for array storage and being an ActiveX control, I
opted to implement for the former. However (and you probably know this already
but just for those who don't) you can call VBScript from Javascript and visa
versa so you can create a small VBScript wrapper function around TransformPoint
and keep the rest of your code in Javascript. Attached is a sample app that uses
the TranformPoint method in VBScript.

 

hope this helps,

Larry Horner


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Do
you have to use vb script when calling a function which locates the x, y
coordinates? If so do you have an example of this? I have been using
JavaScript and the viewer keeps crashing.
Message 5 of 5
Anonymous
in reply to: Momo67

You access an existing VBArray from JavaScript
using the VBArray() object:

 

<scri pt language="vbscript">
 
'-------------------------------------------------------------------'
 
' This demonstrates using the TranformPoint method
 
'-------------------------------------------------------------------'
  
function TransformPoint_
    dim src(2),
dst(2)
    src(0) = 1   ' Paper
point
    src(1) = 0.0 ' Paper point x
   
src(2) = 8.5 ' Paper point y
    dst(0) = 2   '
Screen point

 

    call
ExpressViewer.Viewer.WaitForPageLoaded
    call
ExpressViewer.Viewer.TransformPoint(src, dst)
   
TransformPoint_ = dst
  end function

</scr ipt>

 

<scri pt language="javascript">
function
TransformPoint()
{
   var a = new
color=#ff0000>VBArray
(TransformPoint_());
   var b =
a.toArray();
   alert(b[1]);
  
alert(b[2]);
}
</scr ipt>

 

   Dan

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">

Yes, unfortunately VBScript and Javascript have
completely different mechanism for array storage and being an ActiveX control,
I opted to implement for the former. However (and you probably know this
already but just for those who don't) you can call VBScript from Javascript
and visa versa so you can create a small VBScript wrapper function around
TransformPoint and keep the rest of your code in Javascript. Attached is a
sample app that uses the TranformPoint method in VBScript.

 

hope this helps,

Larry Horner


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Do
you have to use vb script when calling a function which locates the x, y
coordinates? If so do you have an example of this? I have been using
JavaScript and the viewer keeps
crashing.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report