hexagon logo

Does someone have python-Adams examples

Hey guys,
 
I am looking into using python scripts in Adams instead of the command language.
So far I have found 2 examples scripts in the 'adamspy' folder and the help function also provides some examples and classes definitions. However, i feel like i am missing examples to problem solve things i encounter. Does anyone know where i could find more examples?
 
As an problem example; i got this simple script that creates 2 markers, and should parametrize one marker to the other marker. However, the location of the marker isn't updated. Do i need to call an mod.update() or something?
 
python script
marker not updated
Thanks in Advance!
Parents
  • Hi Niels,
     
    This looks like a View refresh bug to me, which we will report ASAP. My quick workaround is to use Adams.execute_cmd() instead of Adams.expression() and use the actual marker modify command to ensure that the marker does get placed where it should. Please check out the last line below:
     
    mod = Adams.Models.create(name='tester')
    g = mod.Parts["ground"]
    ref = g.Markers.create(name='ref', location=[0,0,0])
     
    m1=g.Markers.create(name='m1', location=[0,0,0])
    #m1.location = Adams.expression("(LOC_RELATIVE_TO({100.0,0.0,0.0}, %s))" % ref.full_name)
    Adams.execute_cmd("marker modify marker_name = m1 location = (LOC_RELATIVE_TO({100.0, 0.0, 0.0},"+ref.full_name+"))")
     
    I hope this helps.
     
    Thank you,
     
    Maziar Rostamian
    MSC Software
Reply
  • Hi Niels,
     
    This looks like a View refresh bug to me, which we will report ASAP. My quick workaround is to use Adams.execute_cmd() instead of Adams.expression() and use the actual marker modify command to ensure that the marker does get placed where it should. Please check out the last line below:
     
    mod = Adams.Models.create(name='tester')
    g = mod.Parts["ground"]
    ref = g.Markers.create(name='ref', location=[0,0,0])
     
    m1=g.Markers.create(name='m1', location=[0,0,0])
    #m1.location = Adams.expression("(LOC_RELATIVE_TO({100.0,0.0,0.0}, %s))" % ref.full_name)
    Adams.execute_cmd("marker modify marker_name = m1 location = (LOC_RELATIVE_TO({100.0, 0.0, 0.0},"+ref.full_name+"))")
     
    I hope this helps.
     
    Thank you,
     
    Maziar Rostamian
    MSC Software
Children
No Data