project nodes on nearest surface

Pandurang
Pandurang Altair Community Member
edited October 2020 in Community Q&A

HI All,

 

i want to write script to project the face nodes on nearest surface..

is there any API?

any idea how to do this..

@tinh

 

 

Thanks

Answers

  • tinh
    tinh Altair Community Member
    edited July 2019

    Hi

    the script is thought about long time ago

    There are some ways but not actually efficient.

    First i toggle all green lines to form 1 surf only => project easily, don't need script

    But sometimes mess up the mesh!

     

    Then i loop with each surf to project nodes on them. Mesh is not mess up

    But script very slow because large number of small surfs

     

    Then loop with each node to find closest surface, faster as surf list as shorter (appliable because we can limit surfs in a comp)

     

    A script like this

     

    Createmark surfs 1 all (or $slist , example: surfs in a comp => faster)

    Foreach node $nlist (

       Createmark node 1 $node

       Lassign [hm_measureshortestdistance surfs 1 0 0 nodes 1 0 0] => closestSurf x y z

       Nodemodify $node $x $y $z

    )

     

    Then i ....

    am thinking other ways because above one still too long (so usually, i let it run finally, overnight.

     

     

     

    Tips:

    If you can divide a big model file to many files, each file has a few comps, above script will run much faster. And by dividing model you can run files on hm sessions simultenously.

  • Pandurang
    Pandurang Altair Community Member
    edited July 2019

    <?xml version="1.0" encoding="UTF-8"?>image.thumb.png.d67805ff2f9c76e446770752ef54d2b0.png

     

    I wrote this one...this also takes lot of time...

    @tinh

  • tinh
    tinh Altair Community Member
    edited July 2019

    1.Don't *createmark surfs 1 displayed  every loop !

    2.Use *nodemodify is faster than *projectmark

    3.Ignore associated nodes

     

     

    *createmark elems 1 displayed

    *findfaces elems 1

    *createmark nodes 1 'by comp name' ^faces

    *createmark surfs 1 displayed

    *createmark nodes 2 'by surface on mark' 1

    *markdifference nodes 1 nodes 2

    set nd_list ...

     

     

     

    => i think much faster

  • Pandurang
    Pandurang Altair Community Member
    edited July 2019

    Thanks 

     

    This will be much better..