четверг, 3 января 2019 г.

Implant text (pml, c#) part 2


In previous post I create NetHelper and get as result PmlNetHelper.dll
Now I need use it in pml language.
Go! Step by step.

1. Copy PmlNetHelper.dll to program folder.
2. Create text file implanttext.pmlfnc and put print next code

define function !!implanttext(!text is string, !addLine is string, !position is real) is string
    using namespace 'PmlNetHelper'
    !o = object StringHelper()
    return !o.ImplantText(!text, !addLine, !position )
endfunction

3.Create folder MyLib inside PMLLIB folder in program directory. And create there folders "common\functions"
4. Save implanttext.pmlfnc file there.
5. In PDMS/E3D in command line print: pml rehash all
For example let create simple report.

!outreport = object array()
!pipes = !!collectallfor('pipe', '', !!ce )
!names = !pipes.Evaluate(object Block(|!pipes[!evalIndex].Name|))
!specs = !pipes.Evaluate(object Block(|!pipes[!evalIndex].Pspe.Name|))

!outreport.Append(!!implanttext('NAME OF PIPE', 'SPEC', 30))
do !i index !names
    !line = !!implanttext(!names[!i], !specs[!i], 30)
    !outreport.Append(!line )
enddo

!file = object File(!!evar('pdmsuser') & '\report.txt')
!file.WriteFile('over', !outreport)
syscom ' "$!file" & '


 6. Paste as macro and voila





 P.S. because there was a pause in the publication the original class was changed. Now it is called PmlNetHelper. See in sources.

 fix in bold text  (05/01/2019 )

суббота, 18 августа 2018 г.

Implant text (pml, c#) part 1

Sometimes to implement in PDMS/E3D some useful functions C# language comes to help.
Examples you can found in the folder "Samples" with the program.
I want to make a function that would insert text into another text in the required position and return new line. And use it in PML. Go!

1. Run Visual Studio and make a project with name NetHelper.


2. Add reference to PMLNet.dll. It exists in program folder.


3. Change your class like that (link).


4. Add new class "StringExtension" and change it (link)




5. Build solution.

Sources

How to use the solution see next post.


How to calculate bend radius? (PML)

It happens that it is necessary to check what the bending radius is equal to.
In the part attributes, this property is missing.
The PML comes to the rescue. To do this, we write the function.


    define function !!bendradius(!bend is dbref) is real
        !line = object line(!bend.ppos[1], !bend.ppos[2])
        !lengthLine = !line.Length().ConvertUnits('mm')
        !angle = 180 - !bend.pdir[1].angle(!bend.pdir[2]).ConvertUnits('degree').Value()
        !sin = sin ( !angle / 2 )
        !raduis = !lengthLine / ( 2 * !sin )
        return !raduis
    endfunction




How to find the radius?

All sources storage

Welcome


Yo!
This is my blog about programming, in particular for Aveva PDMS/E3D, automation of engineering work, etc.
Now my Eglish is pre-intermediate. And I set the goal for the year to reach my level to Upper-Intermediate and  improve my speak skills too.
Leave your comments, wishes and feedback under publications.