hm_measureshortestdistance not working properly

Altair Forum User
Altair Forum User
Altair Employee
edited October 2020 in Community Q&A

                    image.png.aabafc49bd9f6f99cb524bdc5e2f1f30.png                            image.png.1e3de18edb803d25e6c85801c529c879.png

All the brown color elems are 3d elements in the collector solidmap while the green color elems are 2d elems in collector auto1.

I execute the following command

 

*createmark elems 1 599

*createmark elems 2 'by comp name' auto1

hm_measureshortestdistance elems 1 0 elems 2 0 0

 

it returns->  0 0 0 0 599 0 0 0 1 0 0 0

but as we can see the distance between elem id 599 and elem id 1 is not 0.and elem id 1 is not the nearest elem to 599 among all other elems of auto1. 

Can somebody explain this ?

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

Answers

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited March 2019

    I got the ans, elem is not a valid entity type for this type, the Valid values are nodes, points, lines, surfaces and solids.Apart from this is there any api which can do the task which I intend to do ?

  • tinh
    tinh Altair Community Member
    edited March 2019

    How about this:

     

    *createmark nodes 1 'by elem' 599

    *createmark nodes 2 'by comp name' auto1

    set N2 [lindex [hm_measureshortestdistance nodes 1 0 nodes 2 0 0] end-3]

    *createmark elems 1 'by node' $N2

    puts 'closest elems: [hm_getmark elems 1]'

     

    You can use hm_entityinfo centroid elems

    to get centroid of e599 and the closest elems then compare which one is closer to e599 => decide that is closest.

     

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited March 2019

    hello Tinh 

    hm_measureshortestdistance nodes 1 0 nodes 2 0 0 is giving 'expected integer but got '0 ' error ..

  • tinh
    tinh Altair Community Member
    edited March 2019

    maybe, you copy & paste my code. Be not lazy, pls type it again, man!

  • tinh
    tinh Altair Community Member
    edited March 2019

    a relevant command you should refer:

    hwat::utils::GetClosestElement

    in package hwat

     

    Refer HW Help Home> Hyperworks Tools > Hyperworks Automation Toolkit

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited March 2019

    Nopes I didn't copy pasted. I typed myself many times but everytime the same error its giving. 

     

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited March 2019
    hwat::utils::GetClosestElement first three arguments are x y z coordinates but the last argument is assembly name. This argument is not working if I give the collector name as here 'auto1'
  • tinh
    tinh Altair Community Member
    edited March 2019

    hwat::utils::GetClosestElement first three arguments are x y z coordinates but the last argument is assembly name. This argument is not working if I give the collector name as here 'auto1'

     

    put that collector (comp) in an assembly,  and use the assembly name as argument

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited March 2019

    yes putting that component in a different assembly works. Thanks for the solution . And I tried the hm_measureshortestdistance on a different computer but its giving the same error