Measuring, how can I get hold of the latest measuring
Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan
Measuring, how can I get hold of the latest measuring
How can I get hold of the measuring that has just been done? (for example: the user selects to measure a distance/area etc. and when he finishes this I want to be able to pick up this event and process the information), and how can I get hold of all measurings that has been done in a pdf,
I want to be able to process this programmaticaly.
I want to be able to process this programmaticaly.
- Vasyl-Tracker Dev Team
- Site Admin
- Posts: 2353
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: Measuring, how can I get hold of the latest measuring
Hi, magthenop.
This feature is undocumented but you may use next method - you may intercept the next events (in pseudocode):
Best
Regards.
This feature is undocumented but you may use next method - you may intercept the next events (in pseudocode):
Code: Select all
OnEvent(type, name,...)
{
if ((type == PXCVA_OnPropertyChanged) AND (FindSubStrIn(name, ".Measure.Simple."))
{
OnNewMeasurement();
}
}
OnNewMeasurement()
{
// read new measurements
ReadNewMeasurement("Distance");
ReadNewMeasurement("Area");
ReadNewMeasurement("Perimeter");
};
ReadNewMeasurement(string annotType)
{
// read current style
int curStyleID;
ax.GetProperty("Tools." + annotType + ".Style", curStyleID);
string prefix = "Commenting." + annotType + ".Styles[#" + curStyleID + "].Measure.Simple.";
// read new scale ratio
double fromValue;
double toValue;
int fromUnit;
int toUnit;
ax.GetProperty(prefix + "FromValue", fromValue);
ax.GetProperty(prefix + "FromUnit", fromUnit);
// to obtain the name of selected measurement unit such as "Point", "Inch", etc. - you may call the:
// string fromUnitStr;
// ax.GetProperty(prefix + "FromUnit", fromUnitStr, PXCVA_GetNamed);
..
ax.GetProperty(prefix + "ToValue", toValue);
ax.GetProperty(prefix + "ToUnit", toUnit);
};
Regards.
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Re: Measuring, how can I get hold of the latest measuring
Hi!
This onEvent does not trigger the OnNewMeasurement when I do a new measuring (a distance, area etc).
Something is not right.
Here is my code for the onEvent in Delphi:
This onEvent does not trigger the OnNewMeasurement when I do a new measuring (a distance, area etc).
Something is not right.
Here is my code for the onEvent in Delphi:
Code: Select all
procedure TForm1.PDFRitningEvent(ASender: TObject; Type_: Integer;
const Name: WideString; const DataIn: OleVariant; out DataOut: OleVariant;
Flags: Integer);
begin
if (Type_ = PXCVA_OnPropertyChanged) Then Begin
if (Pos('.Measure.Simple.',Name)>0) Then Begin
OnNewMeasurement;
End;
End;
end;
- Vasyl-Tracker Dev Team
- Site Admin
- Posts: 2353
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: Measuring, how can I get hold of the latest measuring
Please update to latest version (2.0.55). It may resolve your problem.
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Re: Measuring, how can I get hold of the latest measuring
Sorry, but after ugrading to 2.0.55 (had 2.0.54) I get the same result as before
Re: Measuring, how can I get hold of the latest measuring
Another thing that happend after upgrading, I can not set the scale after loading an .pdf file,
if I now try to set this scale I get an OLE Error 82130001 on the first code line, this worked in 2.0.54.
if I now try to set this scale I get an OLE Error 82130001 on the first code line, this worked in 2.0.54.
Code: Select all
PDFRitning.SetProperty('Tools.Distance.Measure.Simple.FromValue', 1.0,0);
PDFRitning.SetProperty('Tools.Distance.Measure.Simple.FromUnit', 'cm',0);
PDFRitning.SetProperty('Tools.Distance.Measure.Simple.ToValue', 1.0,0);
PDFRitning.SetProperty('Tools.Distance.Measure.Simple.ToUnit', 'm',0);
- Vasyl-Tracker Dev Team
- Site Admin
- Posts: 2353
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: Measuring, how can I get hold of the latest measuring
Hi, magthenop.
The 'Tools.Distance' does not contain the 'Measure' node. So the next code is wrong:Replace your code by:
Note: the name fragment 'Styles[0]' can be changed to 'Styles[#<CurrentDistanceStyleID>]', example:
'Commenting.Distance.Styles[#6463].Measure.Simple.FromValue' - represents scale ratio part of current style of Distance Tool.
The <CurrentDistanceStyleID> you can obtain by (in Delphi): - Look again to ReadNewMeasurement in my previous post.
Best
Regards.
The 'Tools.Distance' does not contain the 'Measure' node. So the next code is wrong:
Code: Select all
PDFRitning.SetProperty('Tools.Distance.Measure.Simple.FromValue', 1.0,0);
Code: Select all
PDFRitning.SetProperty('Commenting.Distance.Styles[0].Measure.Simple.FromValue', 1.0,0);
'Commenting.Distance.Styles[#6463].Measure.Simple.FromValue' - represents scale ratio part of current style of Distance Tool.
The <CurrentDistanceStyleID> you can obtain by (in Delphi):
Code: Select all
var:
iCurrentStyleIDofDist: integer;
dataOut: OLEVariant;
...
PDFRitning.GetProperty('Tools.Distance.Style', dataOut, 0);
iCurrentStyleIDofDist := dataOut;
Best
Regards.
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
- Vasyl-Tracker Dev Team
- Site Admin
- Posts: 2353
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: Measuring, how can I get hold of the latest measuring
Strange...Sorry, but after ugrading to 2.0.55 (had 2.0.54) I get the same result as before
I checked it again - it working properly: I can intercept events about measurement changing..
Please check version of installed components by GetVersionInfo routine. Probably you haven't updated all components.
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Re: Measuring, how can I get hold of the latest measuring
When checking the versions I get:
Client version: 2.0.0055.0000
Server version: 2.0.0055.0000
Client version: 2.0.0055.0000
Server version: 2.0.0055.0000
- Tracker Supp-Stefan
- Site Admin
- Posts: 17948
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: Measuring, how can I get hold of the latest measuring
Thanks for double checking the version magthenop,
So is the latest solution proposed by Viktor still not working for you as your comment where you said there is no change is before Viktor's latest snippets?
Best,
Stefan
So is the latest solution proposed by Viktor still not working for you as your comment where you said there is no change is before Viktor's latest snippets?
Best,
Stefan
Re: Measuring, how can I get hold of the latest measuring
The latest solution proposed by Viktor, does not work for me.
- Attachments
-
- PdfView.zip
- Here is the source code for my program (Delphi 2006, win32).
- (11.15 KiB) Downloaded 201 times
- Vasyl-Tracker Dev Team
- Site Admin
- Posts: 2353
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: Measuring, how can I get hold of the latest measuring
Hi, magthenop.
Your example working properly, BUT, may be, here exists one misunderstanding. You said at the beginning:
But, if you need to know the current distance/area/perimeter value of the corresponding annotation while the end-user modifies it - it is impossible now, you will be able do it in the new version only (V3).
Your example working properly, BUT, may be, here exists one misunderstanding. You said at the beginning:
I have understood it as: "how do I know the scale-ratio of measurement that has just changed by the end-user in the 'Properties' toolbar?"How can I get hold of the measuring that has just been done? (for example: the user selects to measure a distance/area etc. and when he finishes this I want to be able to pick up this event and process the information), and how can I get hold of all measurings that has been done in a pdf,
But, if you need to know the current distance/area/perimeter value of the corresponding annotation while the end-user modifies it - it is impossible now, you will be able do it in the new version only (V3).
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Re: Measuring, how can I get hold of the latest measuring
Oh, thats to bad.
When will this version be available? I must have some sort of working solution for this shortly after mid october (promised demo to many customers),
after that Beta testing and in the beginning of next year rollout of a new version to all customers.
Can I solve this some other way? for example by looking at the latest annotation and se if this has changed and is of a current date/time (then it is new).
When will this version be available? I must have some sort of working solution for this shortly after mid october (promised demo to many customers),
after that Beta testing and in the beginning of next year rollout of a new version to all customers.
Can I solve this some other way? for example by looking at the latest annotation and se if this has changed and is of a current date/time (then it is new).
- Vasyl-Tracker Dev Team
- Site Admin
- Posts: 2353
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: Measuring, how can I get hold of the latest measuring
You could use the following method for your case:
Please excuse me if there are any small syntax errors, I'm not a Delphi-programmer .
Best
Regards.
Code: Select all
PDFRitning.SetProperty('Notifications.Selection.Filter', 'Annotations', 0);
...
procedure TForm1.PDFRitningEvent(ASender: TObject; Type_: Integer; const Name: WideString; const DataIn: OleVariant; out DataOut: OleVariant; Flags: Integer);
begin
if (Type_ = PXCVA_OnNamedNotify) Then
Begin
if ((CompareText(Name, 'Global::OperationsHistoryChanged') = 0) or (CompareText(Name, 'Notifications.Selection') = 0)) Then
Begin
ReadDimOfSelAnnot();
End;
End;
end;
function ReadDimOfSelAnnot()
var
script:widestring;
result:widestring;
begin
try
script := 'a = this.selectedAnnots; if (a.length) { a[0].intent; };';
result := '';
PDFRitning.RunJavaScript(script, result, 0, 0);
if ((CompareText(result, 'LineDimension') = 0) or (CompareText(result, 'PolyLineDimension') = 0) or (CompareText(result, 'PolygonDimension') = 0)) Then
begin
try
script := 'a = this.selectedAnnots; if (a.length) { a[0].contents; };';
result := '';
PDFRitning.RunJavaScript(script, result, 0, 0);
// after this the 'result' should contain the measure string, like to: '1 200 m'
except
on ex : EOleException do
;
end;
end
...
except
on ex : EOleException do
;
end;
end;
Best
Regards.
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Re: Measuring, how can I get hold of the latest measuring
Nice, work totaly fine for me
Thanks a million.
Thanks a million.
Re: Measuring, how can I get hold of the latest measuring
One more thing
When measuring an Area i can se inte PDFViewer the length of the perimeter, but when finished I can only se the area.
When "reading" the selected annotation for a area measurement can I somehow even get the perimeter length at the same time (or can I translate the selected annotation from a PolygonDimension to a PolyLineDimension so I can get the perimeter length) ?
When measuring an Area i can se inte PDFViewer the length of the perimeter, but when finished I can only se the area.
When "reading" the selected annotation for a area measurement can I somehow even get the perimeter length at the same time (or can I translate the selected annotation from a PolygonDimension to a PolyLineDimension so I can get the perimeter length) ?
- Vasyl-Tracker Dev Team
- Site Admin
- Posts: 2353
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: Measuring, how can I get hold of the latest measuring
I'm afraid that there is no simple way for this..
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Re: Measuring, how can I get hold of the latest measuring
Ok, thats a settback
Can I somehow convert the values in the rect propery of the annotation to a length by any simple means?
Can I somehow convert the values in the rect propery of the annotation to a length by any simple means?
Re: Measuring, how can I get hold of the latest measuring
Sorry, rect is wrong propery, but somewhere the "points" must be saved.
- Vasyl-Tracker Dev Team
- Site Admin
- Posts: 2353
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: Measuring, how can I get hold of the latest measuring
To obtain the points you may use the next JS-script:
If successful then it returns the array of points in format:
x1, y1, x2, y2, x3, y3...
For more details: http://www.adobe.com/devnet/acrobat/pdf ... erence.pdf
Code: Select all
a = this.selectedAnnots;
if (a.length) { a[0].vertices; };
x1, y1, x2, y2, x3, y3...
For more details: http://www.adobe.com/devnet/acrobat/pdf ... erence.pdf
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Re: Measuring, how can I get hold of the latest measuring
Do you have a link that works? I'm getting: Sorry, this page is not available
- Vasyl-Tracker Dev Team
- Site Admin
- Posts: 2353
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: Measuring, how can I get hold of the latest measuring
Hi, magthenop.
The Adobe changed it in the last Friday.
I found it in the new place:
http://www.adobe.com/content/dam/Adobe/ ... erence.pdf
The Adobe changed it in the last Friday.
I found it in the new place:
http://www.adobe.com/content/dam/Adobe/ ... erence.pdf
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Re: Measuring, how can I get hold of the latest measuring
Hi!
I can not find any function where I can send in the vertices from a[0].vertices and get back the perimeter length or create a new Polyline measurement on the same location as the Polygon measurement with the polygon measure as a blueprint.
Can someone help me with this?
Or how to catch the event when a new point is created/edited/deleted on a plygon measurement and then also be able to pick up the perimeter length that is displayed on the screen for this measurement.
Or how to add some functionallity for the "create/change" event when a polygon measurement is created/changed so I also can save the perimeter length in another propery of this object.
I can not find any function where I can send in the vertices from a[0].vertices and get back the perimeter length or create a new Polyline measurement on the same location as the Polygon measurement with the polygon measure as a blueprint.
Can someone help me with this?
Or how to catch the event when a new point is created/edited/deleted on a plygon measurement and then also be able to pick up the perimeter length that is displayed on the screen for this measurement.
Or how to add some functionallity for the "create/change" event when a polygon measurement is created/changed so I also can save the perimeter length in another propery of this object.
- Vasyl-Tracker Dev Team
- Site Admin
- Posts: 2353
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: Measuring, how can I get hold of the latest measuring
Hi, magthenop.
You may use next method:
Method A
1. prepare string obtained from a[0].vertices (how obtain - see above):
the obtained:
x0,y0,x1,y1,x2,y2
to new:
[[x0,y0],[x1,y1],[x2,y2]]
example:
from:
0,0,200,200,300,100,0,0
to:
[[0,0],[200,200],[300,100],[0,0]]
2. Build and launch special script for adding the corresponding polyline annotation (example pseudocode):
Method B
1. extract actual points from a[0].vertices
2. calc perimeter by:3. Transform calculated value by current scale ratio (yow obtain actual scale ratio - see above) and save it to 'subject' property of existsing polygon annotation by:
To intercept "create/change" event:
HTH.
You may use next method:
Method A
1. prepare string obtained from a[0].vertices (how obtain - see above):
the obtained:
x0,y0,x1,y1,x2,y2
to new:
[[x0,y0],[x1,y1],[x2,y2]]
example:
from:
0,0,200,200,300,100,0,0
to:
[[0,0],[200,200],[300,100],[0,0]]
2. Build and launch special script for adding the corresponding polyline annotation (example pseudocode):
Code: Select all
int page; // zero based
string preparedVertices; // can contain for example the string "[[0,0],[200,200],[300,100],[0,0]]" (without quote marks)
scriptToAddPolyLine = "var a = this.addAnnot({page:" + page +", type: "PolyLine", vertices: " + preparedVertices + "});";
1. extract actual points from a[0].vertices
2. calc perimeter by:
Code: Select all
val = 0;
points; // zero bazed
pointsNum; // count of points
for (size_t i = 1; i < pointsNum; i++)
{
double dx = (points[i].x - points[i - 1].x);
double dy = (points[i].y - points[i - 1].y);
val = val + sqrt(dx * dx + dy * dy);
};
Code: Select all
string val; // contain perimeter string
scriptToModifySubjOfAnnot = 'a = this.selectedAnnots; if (a.length) { a.subject = "' + val + '"; };';
Code: Select all
procedure TForm1.PDFRitningEvent(ASender: TObject; Type_: Integer; const Name: WideString; const DataIn: OleVariant; out DataOut: OleVariant; Flags: Integer);
begin
if (Type_ = PXCVA_OnNamedNotify) Then
Begin
if (CompareText(Name, 'Global::OperationsHistoryChanged') = 0) Then
Begin
OnAnyAnnotChangedAddedOrDeleted();
End;
End;
end;
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Re: Measuring, how can I get hold of the latest measuring
When I measure an arean (in this case a triangle)
I get this points from the vertices of the area measure:
[437.95407360805285,1462.71714922049],
[588.6882667505505,1466.467706013363],
[503.19723183391005,1363.7024498886415]
Before I finishes the measurement I know that the circumfence length should be 10,03 meters,
I also know that the scale I have set is 1 cm equals 1 meter ( 1:100), it also says this for the area measurement.
After running this function (descibed in code below) I get the result: 403,03469552
I can not get the value of 403,03469552 to be equal to 10,03 meters if my scale is set to 1:100.
I assume that I am thinking wrong somewhere but how and why?
I get this points from the vertices of the area measure:
[437.95407360805285,1462.71714922049],
[588.6882667505505,1466.467706013363],
[503.19723183391005,1363.7024498886415]
Before I finishes the measurement I know that the circumfence length should be 10,03 meters,
I also know that the scale I have set is 1 cm equals 1 meter ( 1:100), it also says this for the area measurement.
After running this function (descibed in code below) I get the result: 403,03469552
Code: Select all
Omkr:=0; // Set the measured length to 0
for Rkn:=0 To AntalVert-1 Do Begin //AntalVert is the number of points
NyRkn:=Rkn-1; // Set NyRkn to the previous point
If NyRkn=-1 Then NyRkn:=AntalVert-1; // If NyRkn is less than 0 set it to the last point
dx := VertX[NyRkn] - VertX[Rkn];
dy := VertY[NyRkn] - VertY[Rkn];
Omkr := Omkr + sqrt((dx * dx) + (dy * dy));
End;
I assume that I am thinking wrong somewhere but how and why?
- Vasyl-Tracker Dev Team
- Site Admin
- Posts: 2353
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: Measuring, how can I get hold of the latest measuring
Because you obtained the value in points (1 pt = 1/72 inch), it is standard measurement unit in PDF.After running this function (descibed in code below) I get the result: 403,03469552
I can not get the value of 403,03469552 to be equal to 10,03 meters if my scale is set to 1:100.
You should transform this value by corresponding scale ratio. The current scale ratio you can read by:
Code: Select all
PDFRitning.GetProperty('Commenting.Distance.Styles[0].Measure.Simple.FromValue', @valFrom,0);
PDFRitning.GetProperty('Commenting.Distance.Styles[0].Measure.Simple.FromUnit', @unitFrom,PXCVA_GetNamed);
PDFRitning.GetProperty('Commenting.Distance.Styles[0].Measure.Simple.ToValue', @valTo, 0);
PDFRitning.GetProperty('Commenting.Distance.Styles[0].Measure.Simple.ToValue', @unitTo, PXCVA_GetNamed);
Code: Select all
valPerim; // contains the perimeter in points, and scale ration is 1cm=1m
If unitFrom='Centimeter' Then Begin
valPerim := (valPerim / 72.0) * 2.54; // pt to cm, 403,03469552 pt = 14,22 cm, note: your 10,3 is some incorrect
End;
valPerim := valPerim * (valTo / valFrom); // 14,22 cm * (1/1), because 1cm=1m
// after this you have valPerim in unitTo (Meter)
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Re: Measuring, how can I get hold of the latest measuring
It works so nice now! Thanks a million.
- Tracker Supp-Stefan
- Site Admin
- Posts: 17948
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: Measuring, how can I get hold of the latest measuring
All the kudos to Vasyl
Cheers,
Stefan
Cheers,
Stefan
Re: Measuring, how can I get hold of the latest measuring
I could not agree more, all kudos to vasil
- Paul - Tracker Supp
- Site Admin
- Posts: 6901
- Joined: Wed Mar 25, 2009 10:37 pm
- Location: Chemainus, Canada
- Contact:
Re: Measuring, how can I get hold of the latest measuring
"All praise to the Great One..."
Best regards
Paul O'Rorke
Tracker Support North America
http://www.tracker-software.com
Paul O'Rorke
Tracker Support North America
http://www.tracker-software.com