data recovery from a best-fit alignment

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • data recovery from a best-fit alignment

    A little code which allow recovery displacements and rotations of a bf alignment.
    It's realized here from 9 points, there are some modifications to do if the alignment is constructed from different features...
    Have a nice week-end !

    Thx to neil.challinor for the help !
    ​​​​​​​
    Code:
    A3 =ALIGNMENT/START,RECALL:STARTUP,LIST=YES
    ALIGNMENT/BF3D,LEAST_SQR,CREATE WEIGHTS=NO,ROTANDTRANS,USE SCALING=NO,0.002,-0.001,-0.008,0.026,-0.021,-0.011
    ITERATEANDREPIERCECAD=NO
    Deviation Threshold=0.01
    SHOWALLINPUTS=YES,SHOWALLPARAMS=YES
    ID=PNT1,Points,,1,YES,YES,YES,YES
    ID=PNT9,Points,,1,YES,YES,YES,YES
    ID=PNT2,Points,,1,YES,YES,YES,YES
    ID=PNT3,Points,,1,YES,YES,YES,YES
    ID=PNT4,Points,,1,YES,YES,YES,YES
    ID=PNT5,Points,,1,YES,YES,YES,YES
    ID=PNT6,Points,,1,YES,YES,YES,YES
    ID=PNT7,Points,,1,YES,YES,YES,YES
    ID=PNT8,Points,,1,YES,YES,YES,YES
    ID=
    ALIGNMENT/END
    WORKPLANE/ZPLUS
    ASSIGN/V10=GETCOMMAND(15,"UP",1)
    ASSIGN/DEPL_X=GETTEXT(74,1,V10)
    ASSIGN/DEPL_Y=GETTEXT(74,2,V10)
    ASSIGN/DEPL_Z=GETTEXT(74,3,V10)
    ASSIGN/ROT_Z=GETTEXT(149,1,V10)
    ASSIGN/ROT_X=GETTEXT(149,2,V10)
    ASSIGN/ROT_Y=GETTEXT(149,3,V10)
    COMMENT/OPER,YES,FULL SCREEN=NO,AUTO-CONTINUE=NO,
    DEPL_X
    ROT_Z
    ASSIGN/COUNTER=1
    DO/
    ASSIGN/V13=GETTEXT(3,COUNTER,V10)
    IF/V13<>""
    ASSIGN/COUNTER=COUNTER+1
    END_IF/
    UNTIL/V13==""
    V1 =LOOP/START,ID=YES,NUMBER=COUNTER-1,START=1,SKIP=,
    OFFSET:XAXIS=0,YAXIS=0,ZAXIS=0,ANGLE=0
    ASSIGN/V4="PNT"+V1
    ASSIGN/DEV_PNT[V1]=SQRT(DOT(V4.XYZ-V4.TXYZ,V4.XYZ-V4.TXYZ))
    ASSIGN/V11[V1]=DOT(V4.XYZ-V4.TXYZ,V4.XYZ-V4.TXYZ)
    LOOP/END
    ASSIGN/RMS_ERROR=SQRT(SUM(V11)/(COUNTER-1))
    COMMENT/OPER,YES,FULL SCREEN=NO,AUTO-CONTINUE=NO,
    DEV_PNT
    RMS_ERROR
    ASSIGN/RZ_LN1=MPOINT(COS(DEG2RAD(ROT_Z)),-SIN(DEG2RAD(ROT_Z)),0)
    DISPLAYPRECISION/6
    ASSIGN/RZ_LN2=MPOINT(SIN(DEG2RAD(ROT_Z)),COS(DEG2RAD(ROT_ Z)),0)
    ASSIGN/RZ_LN3=MPOINT(0,0,1)
    ASSIGN/RX_ROW1=MPOINT(1,0,0)
    ASSIGN/RX_ROW2=MPOINT(0,COS(DEG2RAD(ROT_X)),SIN(DEG2RAD(R OT_X)))
    ASSIGN/RX_ROW3=MPOINT(0,-SIN(DEG2RAD(ROT_X)),COS(DEG2RAD(ROT_X)))
    ASSIGN/MTX_ZX_LN1=MPOINT(DOT(RZ_LN1,RX_ROW1),DOT(RZ_LN1,R X_ROW2),DOT(RZ_LN1,RX_ROW3))
    ASSIGN/MTX_ZX_LN2=MPOINT(DOT(RZ_LN2,RX_ROW1),DOT(RZ_LN2,R X_ROW2),DOT(RZ_LN2,RX_ROW3))
    ASSIGN/MTX_ZX_LN3=MPOINT(DOT(RZ_LN3,RX_ROW1),DOT(RZ_LN3,R X_ROW2),DOT(RZ_LN3,RX_ROW3))
    ASSIGN/RY_ROW1=MPOINT(COS(DEG2RAD(ROT_Y)),0,-SIN(DEG2RAD(ROT_Y)))
    ASSIGN/RY_ROW2=MPOINT(0,1,0)
    ASSIGN/RY_ROW3=MPOINT(SIN(DEG2RAD(ROT_Y)),0,COS(DEG2RAD(R OT_Y)))
    ASSIGN/MACHINE2PART_LN1=MPOINT(DOT(MTX_ZX_LN1,RY_ROW1),DO T(MTX_ZX_LN1,RY_ROW2),DOT(MTX_ZX_LN1,RY_ROW3))
    ASSIGN/MACHINE2PART_LN2=MPOINT(DOT(MTX_ZX_LN2,RY_ROW1),DO T(MTX_ZX_LN2,RY_ROW2),DOT(MTX_ZX_LN2,RY_ROW3))
    ASSIGN/MACHINE2PART_LN3=MPOINT(DOT(MTX_ZX_LN3,RY_ROW1),DO T(MTX_ZX_LN3,RY_ROW2),DOT(MTX_ZX_LN3,RY_ROW3))
    COMMENT/OPER,YES,FULL SCREEN=NO,AUTO-CONTINUE=NO,
    transformation machine to part :
    MACHINE2PART_LN1
    MACHINE2PART_LN2
    MACHINE2PART_LN3

  • #2
    When I grow up, if I get to be 1/100th as smart as you, I'll be a happy man.
    SF7107(PCD), SF454(PCD), 152614(Quindos), 9159(Quindos), 7107(Quindos), B&S Manual, M&M Gear Checker

    Comment


    • JEFMAN
      JEFMAN commented
      Editing a comment
      Hey Dan, I'm not so smart, so I believe you're more than this...
      And I hope you can be happy without some code...
      Have a nice week !

  • #3
    So, this "reverts" the BF_ALN made?
    PC-DMIS CAD++ 2o19 R1 SP11

    Comment


    • JEFMAN
      JEFMAN commented
      Editing a comment
      No, it's just allow extracting values...

  • #4
    Monday morning, after a coffee...
    The loop can be replaced by a little reflection in the do / until !
    So, whatever the feature, it should work directly.

    Code:
    A3 =ALIGNMENT/START,RECALL:STARTUP,LIST=YES
    ALIGNMENT/BF3D,LEAST_SQR,CREATE WEIGHTS=NO,ROTANDTRANS,USE SCALING=NO,0.002,-0.001,-0.008,0.026,-0.021,-0.011
    ITERATEANDREPIERCECAD=NO
    Deviation Threshold=0.01
    SHOWALLINPUTS=YES,SHOWALLPARAMS=YES
    ID=PNT1,Points,,1,YES,YES,YES,YES
    ID=PNT9,Points,,1,YES,YES,YES,YES
    ID=PNT2,Points,,1,YES,YES,YES,YES
    ID=PNT3,Points,,1,YES,YES,YES,YES
    ID=PNT4,Points,,1,YES,YES,YES,YES
    ID=PNT5,Points,,1,YES,YES,YES,YES
    ID=PNT6,Points,,1,YES,YES,YES,YES
    ID=PNT7,Points,,1,YES,YES,YES,YES
    ID=PNT8,Points,,1,YES,YES,YES,YES
    ID=
    ALIGNMENT/END
    WORKPLANE/ZPLUS
    ASSIGN/V10=GETCOMMAND(15,"UP",1)
    ASSIGN/DEPL_X=GETTEXT(74,1,V10)
    ASSIGN/DEPL_Y=GETTEXT(74,2,V10)
    ASSIGN/DEPL_Z=GETTEXT(74,3,V10)
    ASSIGN/ROT_Z=GETTEXT(149,1,V10)
    ASSIGN/ROT_X=GETTEXT(149,2,V10)
    ASSIGN/ROT_Y=GETTEXT(149,3,V10)
    COMMENT/OPER,YES,FULL SCREEN=NO,AUTO-CONTINUE=NO,
    DEPL_X
    ROT_Z
    ASSIGN/COUNTER=1
    DO/
    ASSIGN/V13=GETTEXT(3,COUNTER,V10)
    IF/V13<>""
    ASSIGN/DEV_PNT[COUNTER]=SQRT(DOT(V13.XYZ-V13.TXYZ,V13.XYZ-V13.TXYZ))
    ASSIGN/V11[COUNTER]=DOT(V13.XYZ-V13.TXYZ,V13.XYZ-V13.TXYZ)
    ASSIGN/COUNTER=COUNTER+1
    END_IF/
    UNTIL/V13==""
    ASSIGN/RMS_ERROR=SQRT(SUM(V11)/(COUNTER-1))
    COMMENT/OPER,YES,FULL SCREEN=NO,AUTO-CONTINUE=NO,
    DEV_PNT
    RMS_ERROR
    ASSIGN/RZ_LN1=MPOINT(COS(DEG2RAD(ROT_Z)),-SIN(DEG2RAD(ROT_Z)),0)
    DISPLAYPRECISION/6
    ASSIGN/RZ_LN2=MPOINT(SIN(DEG2RAD(ROT_Z)),COS(DEG2RAD(ROT_ Z)),0)
    ASSIGN/RZ_LN3=MPOINT(0,0,1)
    ASSIGN/RX_ROW1=MPOINT(1,0,0)
    ASSIGN/RX_ROW2=MPOINT(0,COS(DEG2RAD(ROT_X)),SIN(DEG2RAD(R OT_X)))
    ASSIGN/RX_ROW3=MPOINT(0,-SIN(DEG2RAD(ROT_X)),COS(DEG2RAD(ROT_X)))
    ASSIGN/MTX_ZX_LN1=MPOINT(DOT(RZ_LN1,RX_ROW1),DOT(RZ_LN1,R X_ROW2),DOT(RZ_LN1,RX_ROW3))
    ASSIGN/MTX_ZX_LN2=MPOINT(DOT(RZ_LN2,RX_ROW1),DOT(RZ_LN2,R X_ROW2),DOT(RZ_LN2,RX_ROW3))
    ASSIGN/MTX_ZX_LN3=MPOINT(DOT(RZ_LN3,RX_ROW1),DOT(RZ_LN3,R X_ROW2),DOT(RZ_LN3,RX_ROW3))
    ASSIGN/RY_ROW1=MPOINT(COS(DEG2RAD(ROT_Y)),0,-SIN(DEG2RAD(ROT_Y)))
    ASSIGN/RY_ROW2=MPOINT(0,1,0)
    ASSIGN/RY_ROW3=MPOINT(SIN(DEG2RAD(ROT_Y)),0,COS(DEG2RAD(R OT_Y)))
    ASSIGN/MACHINE2PART_LN1=MPOINT(DOT(MTX_ZX_LN1,RY_ROW1),DO T(MTX_ZX_LN1,RY_ROW2),DOT(MTX_ZX_LN1,RY_ROW3))
    ASSIGN/MACHINE2PART_LN2=MPOINT(DOT(MTX_ZX_LN2,RY_ROW1),DO T(MTX_ZX_LN2,RY_ROW2),DOT(MTX_ZX_LN2,RY_ROW3))
    ASSIGN/MACHINE2PART_LN3=MPOINT(DOT(MTX_ZX_LN3,RY_ROW1),DO T(MTX_ZX_LN3,RY_ROW2),DOT(MTX_ZX_LN3,RY_ROW3))
    COMMENT/OPER,YES,FULL SCREEN=NO,AUTO-CONTINUE=NO,
    transformation machine to part :
    MACHINE2PART_LN1
    MACHINE2PART_LN2
    MACHINE2PART_LN3

    Comment

    Related Topics

    Collapse

    Working...
    X