Help needed with EDG pick in Paragon? How to determine the exact pick position on an element?

Hello experts, 

I need some help. I am trying to create a measuring tool for Paragon (E3D 2.1), like many before I suppose. 

I got stuck at intepreting the position of the pick in the graphic view of Paragon. Which ever picking method I employ, I seem to be unable to get anything out of it except ARC or POINTVECTOR. If I use the position of the pointvector, I expectedly get the point floating somewhere "in the air":


  


What ever kind of picking I've employed (I tried all methods in edgPickType, after trying most higher level methods), I can get only the Pointvector or the Arc part of the pick position information, but never the actual position of the pick on the object. Some methods, like stdPosition(''), don't process at all. 

If I run the same code in the Design module, I get everything I need from the pick and I get the exact pick position. 

I find it symptomatic that if I use positionPlane() in Paragon, it crashes with an error: 

    !pick.description = !desc
    !pick.priority    = 1
    !pick.remove      = false
    !pick.action     = |!!vxaParagonMeasure.$!<pickAction>(!this.return[1])|
    !pick.close      = |!!vxaParagonMeasure.closePick()|
    !pick.escape     = |!!vxaParagonMeasure.escapePick()|
    !pick.pickPacket.picks[1] = object EDGPICKTYPE()
    !pick.pickPacket.picks[1].positionPlane('')
    !pick.pickPacket.picks[1].pick.modifiable = false



In Design, this code works and returns the object where POSITION is the real position of the pick (red dot is exactly where I picked on the pipe):


So I suppose I am either missing some underlying difference in functionality of the Design module view (GM3D) and Paragon module view (G3D) which prevents the edgPickType.snap() method from interpreting the pick correctly and resolving the reference plane in order to intersect it with the Pointvector and derive the POSITION, 

Or I am missing how to interpret the pick position with the pointvector or ARC alone, 

Or I am missing some object I need to raise a global instance of, in order for all of this to work, so far I've done this: 

define method .init()
    -- !!EDGCntrl       = object EDGCntrl()
    --!!edgPosCntrl     = object EDGPOSCNTRL()
    !!AppMathLib    = object AppMathLib()
    pml reload form !!edgPlineFilter
    pml reload form !!edgPointFilter
    pml reload form !!edgElementFilter

    if(undefined(!!edgCntrl)) then
        !edgCntrl = object EDGCNTRL()
        !edgCntrl.globalInstance()
    endif  

    if(undefined(!!edgTypes)) then
        !edgTypes = object EDGTYPES()
        !edgTypes.globalInstance()
    endif
endmethod 

I'd appreciate any kind of help, guidance, pointer to a manual or a helpful tip. 
Is there any info about how EDG is actually initiated at Design startup so I can study it and see what I've possibly missed? 

I do see another way about this; but I would really love to get it to work like this. 
  • Adrijana,

    please find here below a code written some years ago  by me_hungry ( great Forum Member !).

    Hope it helps somehow.

    ------------------------------------------------------------------------
    --
    -- Copyright 2017 to Current Year me_hungry
    --
    -- File: uMeasureInParagon.pmlfrm
    -- Type: PML Form Definition
    -- Group: forms
    -- Keyword: frm
    -- Module: Paragon
    -- Replaces:
    --
    -- Author: Yevhen Hisar
    -- Created: Wed Apr 9 8:42:18 UTC+02:00 2017
    --
    --
    -- Description:
    -- Measures distance between points
    --
    ------------------------------------------------------------------------
    --

    setup form !!uMeasureInParagon resize size 20 2
    title |Measure distance|
    path R
    track |CATACE| call ||

    button .comparecondition |Measure| at xmin form ymin form+0.5 call '!this.runtrack()' width 8 tooltip 'Measure'
    button .clear |Clear| at xmax.comparecondition+2 ymin.comparecondition call 'AID CLEAR ALL' width 6 tooltip 'Clear'

    member .ceitemA is dbref
    member .ceitemB is dbref
    member .numa is real

    exit

    -- ################################## Определение формы ########################################
    define method .uMeasureInParagon()
    if ( Defined(!!MODELVIEW1) ) then
    if ( !!MODELVIEW1.Shown().Not() ) then $* показать форму, если не показана
    !!Alert.Error('Works with open MODELVIEW1!')
    hide !!uMeasureInParagon
    return
    endif
    else
    !!Alert.Error('Works with open MODELVIEW1!')
    hide !!uMeasureInParagon
    return
    endif
    col 1 blue
    col ce yellow
    col aids red
    endmethod
    -- ################################## Задание второго обьекта ########################################
    define method .measuredistB()
    !this.ceitemB = CE
    endmethod
    -- ################################## Метод перенаправления подсчетав зависимости от типа точки########################################
    define method .comparecondition()
    !this.MeasureValues()
    endmethod
    -- ################################## Метод включенияпривязки с ce ########################################
    define method .runtrack()
    if ( Defined(!!MODELVIEW1) ) then
    if ( !!MODELVIEW1.Shown().Not() ) then $* показать форму, если не показана
    !!Alert.Error('Работает при запущенной MODELVIEW1!')
    hide !!uMeasureInParagon
    return
    endif
    else
    !!Alert.Error('Работает при запущенной MODELVIEW1!')
    hide !!uMeasureInParagon
    return
    endif
    -- обнулить все переменные
    !this.numa = 0
    !!uMeasureInParagonnuma = !this.numa
    !this.ceitemA = Nulref
    !this.ceitemB = Nulref

    --перейти на catref
    !catval = !!MODELVIEW1.compAttribList.dtext[1].after('Category').dbref()
    $!catval
    --включить привязку к autorunonce
    !!uMeasureInParagon.autocall = '!this.autorunonce()'
    if(!this.numa.eq(0))then
    prompt 'DEL to exit, Navigate to first Point'
    endif
    endmethod

    -- ################################## Включени поиска точки ########################################
    define method .autorunonce()

    --если элемент точка или п-поинт сет то начать считать (!this.numa = 1) если нет то выполнить autorunonce
    if(!!ce.type eq 'PTAX' OR !!ce.type eq 'PTSE' OR !!ce.type eq 'PTCA' OR !!ce.type eq 'PTMI' )then
    !this.numa = !this.numa + 1
    !!uMeasureInParagonnuma = !!uMeasureInParagonnuma + 1
    else
    return
    endif
    --если по счету первый элемент то выполнить measuredistA если второй то measuredistB + comparecondition + обнулить трек
    if(!this.numa eq 1)then
    !this.measuredistB()
    !this.comparecondition()
    !this.stop()
    endif

    endmethod
    ------------------------------------------------------------------------
    --
    -- Method: Stop
    --
    -- Description: Stop
    --
    ------------------------------------------------------------------------
    define method .Stop()
    !!uMeasureInParagon.autocall = ''
    !this.numa = 0
    prompt ''
    endmethod
    ------------------------------------------------------------------------
    --
    -- Method: MeasureValues
    --
    -- Description: MeasureValues
    --
    ------------------------------------------------------------------------
    define method .MeasureValues()
    -- одна и таже точка or ptse
    if( !this.ceitemB.type eq 'PTSE')then
    !this.stop()
    return
    endif
    !!ce = !!MODELVIEW1.component
    -- FIRST SCOM OF CATE
    handle any
    return
    endhandle

    !bitem = !this.ceitemB.numb
    --
    !PinBPos = P$!bitem POS
    !PinCPos = X0Y0Z0

    !PinBPosE = !PinBPos
    !PinBPosN = !PinBPos
    !PinBPosU = !PinBPos
    !PinBPosE.east = 0
    !PinBPosN.north = 0
    !PinBPosU.up = 0
    -------------------------------------------------
    !getMiddlePosE = !PinBPosE.Midpoint(!PinBPos)
    !getMiddlePosN = !PinBPosN.Midpoint(!PinBPos)
    !getMiddlePosU = !PinBPosU.Midpoint(!PinBPos)
    -----------------------------------------------------------
    !getDistancePosN = !PinBPosN.Distance(!PinBPos).STRING('D1').replace('-','').replace('mm','')
    !getDistancePosE = !PinBPosE.Distance(!PinBPos).STRING('D1').replace('-','').replace('mm','')
    !getDistancePosU = !PinBPosU.Distance(!PinBPos).STRING('D1').replace('-','').replace('mm','')
    ------------------

    var !dirE CONS DIR $!PinBPos TO $!PinBPosE
    var !dirN CONS DIR $!PinBPos TO $!PinBPosN
    var !dirU CONS DIR $!PinBPos TO $!PinBPosU

    var !revE CONS DIR $!PinBPosE TO $!PinBPos
    var !revN CONS DIR $!PinBPosN TO $!PinBPos
    var !revU CONS DIR $!PinBPosU TO $!PinBPos
    -- AID LINE $!PinBPosE TO $!PinBPos LINES DASHED
    -- AID LINE $!PinBPosN TO $!PinBPos LINES DASHED
    -- AID LINE $!PinBPosU TO $!PinBPos LINES DASHED

    if (!getDistancePosE.real().eq(0).not()) then
    AID TEXT '$!getDistancePosE' AT $!getMiddlePosE
    AID ARROW AT $!PinBPosE DIR $!revE HEI $!getDistancePosE Prop 0.1
    AID ARROW AT $!PinBPos DIR $!dirE HEI $!getDistancePosE Prop 0.1
    endif
    if (!getDistancePosN.real().eq(0).not()) then
    AID TEXT '$!getDistancePosN' AT $!getMiddlePosN
    AID ARROW AT $!PinBPosN DIR $!revN HEI $!getDistancePosN Prop 0.1
    AID ARROW AT $!PinBPos DIR $!dirN HEI $!getDistancePosN Prop 0.1
    endif
    if (!getDistancePosU.real().eq(0).not()) then
    AID TEXT '$!getDistancePosU' AT $!getMiddlePosU
    AID ARROW AT $!PinBPosU DIR $!revU HEI $!getDistancePosU Prop 0.1
    AID ARROW AT $!PinBPos DIR $!dirU HEI $!getDistancePosU Prop 0.1
    endif

    endmethod

  • omg Corrado thank you!!!

    you are definitely owed a dinner for this if you ever come visiting at vtx again !!

  • me_hungry is definitely a legend. He had a youtube video posted in his blog (yes, a whole blog about PDMS/E3D customization) about this.
    https://mehungryblog.wordpress.com/2017/10/21/aveva-paragon-measure-p-point-position/

    I think that me_hungry have moved on to become a Software Engineer (.NET) so he is no longer active on the forum.

  • I did see the blog and the video :) I also tried to contact him, but to no effect. I guess you mustr be correct, he moved on to new challenges :) 

    What I didn't like with his software is that it seemed to pick a PPOINT and calculate it's coordinates. Picker code I posted returns the ppoint refno, so it's doable. 

    I'd love to be able to measure stuff other than the ppoints. But I'm planning to use the code Corrado gave me to get what me_hungry did, and then hopefully get ideas from there as soon as I get a moment to play with it :) 

    will post more here when I get around to it. 

  • I really would like to come back to Rijeka!!! Grinning

  • I gave it a go and faced same issue as you do and as you noted: must be somthing with the Paragon view-gadget that does not support proper EDG.

    Is it possible to create a pmlform with a view that supports EDG and run that side-by-side inside Paragon?

    As a workaround, you can add SCOMs into the Model drawlist directly, ADD /scom-name

  • Sorry about the delay everyone, 

    since Corrado was kind enough to publish me_hungry's code, I went and did a little improvement on it and made it public here: 

    https://github.com/zutamacka/parameasure

    Make the pmlfrm available to aveva and show !!vxaParagonMeasure to run.

    The tool uses EDG and, like me_hungry's, allows for picking of p-points only. It can display position of ppoints relative to the central CS, 

    And it also allows measuring of the distance between two picked ppoints. 

    The picker works as EDG does; so you click P-Point Position for example and it will display position of picked P-points until you hit ESC. For P-Points Distance you obviously need to pick 2 ppoints. 
    Works best if yoiu have only 1 Model View open. 
    It will turn the active view green for best visibility of AID lines and display the axes in the corner of the view, also allow for display of Central Axes.
    Tested in E3D 2.1.

    If I figure out how to improve on EDG picking, I will add more measuring options. 

  • Sorry for the delay in answer & thanx for your reply!

    Is it possible to create a pmlform with a view that supports EDG and run that side-by-side inside Paragon?

    I've no idea, but I'll try it out as soon as I get a moment! 

    As a workaround, you can add SCOMs into the Model drawlist directly, ADD /scom-name

    This is great help, thanx!

    HEAVY EDIT: 

    I found that once I ADD /scom-name the picker also doesn't work as expected, not even in Aveva view!
    I can't get correct measurements with either, the Aveva measure, or my own Measuring tool!

    Aveva tools in Model E3D 2.1:

    My tool in Model E3D 2.1:

    Even with these settings, if I pick 2 edges for intersection it's completely out of the ballpark: 

    This leads me to believe it's not so much EDG in Paragon view window, but the actual geometry info in / from Paragon (the SBOX, LCYL, SCTO... elements) that don't interact with EDG properly, regardless of the view environment... 

    This probbaly means that even if I port Aveva Model View gadget to Paragon, EDGpicker won't work :( 

  • I'll be damned - sorry for my false flag - I thought it worked but now when I try I again get the same results as you do.

  • all good, I learned something :) 

    Also thank you for checking & reporting, I was wondering if I was doing something wrong!