measuring tools

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

moke@napconet.com
User
Posts: 60
Joined: Fri Oct 24, 2008 5:17 pm

measuring tools

Post by moke@napconet.com »

For some reason the following code has stopped working... .I am not sure if a change I made elsewhere could have had an effect on it so any help would be appreciated.

Code: Select all

    Call CoPDFXCview1.SetProperty("Tools.Distance.Measure.Simple.FromValue", 1#)
    Call CoPDFXCview1.SetProperty("Tools.Distance.Measure.Simple.FromUnit", "in")
    Call CoPDFXCview1.SetProperty("Tools.Distance.Measure.Simple.ToValue", 16#)
    Call CoPDFXCview1.SetProperty("Tools.Distance.Measure.Simple.ToUnit", "ft")
    Call CoPDFXCview1.SetProperty("Tools.Area.Measure.Simple.FromValue", 1#)
    Call CoPDFXCview1.SetProperty("Tools.Area.Measure.Simple.FromUnit", "in")
    Call CoPDFXCview1.SetProperty("Tools.Area.Measure.Simple.ToValue", 16#)
    Call CoPDFXCview1.SetProperty("Tools.Area.Measure.Simple.ToUnit", "ft")
    Call CoPDFXCview1.SetProperty("Tools.Perimeter.Measure.Simple.FromValue", 1#)
    Call CoPDFXCview1.SetProperty("Tools.Perimeter.Measure.Simple.FromUnit", "in")
    Call CoPDFXCview1.SetProperty("Tools.Perimeter.Measure.Simple.ToValue", 16#)
    Call CoPDFXCview1.SetProperty("Tools.Perimeter.Measure.Simple.ToUnit", "ft")
Thanks
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2445
Joined: Thu Jun 30, 2005 4:11 pm

Re: measuring tools

Post by Vasyl - PDF-XChange »

Hi, moke.

The correct example code:

Code: Select all

// to change measurement options for current style of "Distance" tool 
// (currently this tool can have some different styles, like to any other commenting tool)

int curStyleID;
ctrl.GetProperty("Tools.Distance.Style", curStyleID);

string prefix = "Commenting.Distance.Styles[#" + curStyleID + "].Measure.Simple.";

ctrl.SetProperty(prefix + "FromValue", 1#);
ctrl.SetProperty(prefix + "FromUnit", "in");
...

// The same for "Area" and "Perimeter" tools...
Best
Regards.
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
moke@napconet.com
User
Posts: 60
Joined: Fri Oct 24, 2008 5:17 pm

Re: measuring tools

Post by moke@napconet.com »

It would seem that the ability to have styles in the measuring tools has affected my code. The current ID seems like it is not accesable until a merasuring tool is selected. I have tried the code sample above with no result. No error and no change. Shouldn't I be able to preset the measuring values? It used to work fine...?
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2445
Joined: Thu Jun 30, 2005 4:11 pm

Re: measuring tools

Post by Vasyl - PDF-XChange »

Hi, moke.
The current ID seems like it is not accesable until a merasuring tool is selected.
You may use following 'trick':

Code: Select all

// ...
// ... change measurement for distance tool as in my previous post and if this tool is selected currently:
string activeToolName;
ctrl.GetProperty("Tools.Active", out activeToolName, PXCVA_GetNamed);
if (activeToolName == "Distance")
{
      ctrl.SetProperty("Tools.Active", "Hand", 0);
      ctrl.SetProperty("Tools.Active", activeToolName, 0);
};
HTH.
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
moke@napconet.com
User
Posts: 60
Joined: Fri Oct 24, 2008 5:17 pm

Re: measuring tools

Post by moke@napconet.com »

Thank you Vasyl,

I was able to work out that I could trap the event and set the scale at that time. My code originally set the scale at the time of loading a document which no longer seems possible.(?)

A few comments…

The lack of error msg threw me off. My old commands were accepted yet not executed. This is just an FYI. I appreciate the difficulty in finding every detail and just thought I would pass it along. :)

It would be helpful to preset the measuring scale at the time of loading. I have tried a few other optiond but none seem to work. Does the MeasureSetScale command do what I am looking for? The documentation is a little unclear.

Call CoPDFXCview1.DoVerb("Documents[#" & DocId & "]", "ExecuteCommand", "MeasureSetScale", "?Something?", "?SomethingElse?")
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19885
Joined: Mon Jan 12, 2009 8:07 am

Re: measuring tools

Post by Stefan - PDF-XChange »

Glad to hear that you got it all working Moke,

And thank you for your comments. I am sure that the devs have taken them into account, and I will ask Vasyl to see if he has anything else to add to this topic :)

Cheers,
Stefan