SimplifiedLogic / creoson

OpenSource Automation using JSON Transactions for PTC's CREO Parametric
http://www.creoson.com
MIT License
81 stars 23 forks source link

Wrong scaling in file.get_transform() #58

Open Haschtl opened 3 years ago

Haschtl commented 3 years ago

I figured out, that the rotations seem to be wrong, if the sub-model uses different Creo-Units than the parent-model. The model-structure is rather simple:

MAIN.ASM (main model scaled in Meters)
    ASM_CS0  (main coordinate frame)
    SUBPART.ASM (ID:204, sub-model scaled in Millimeters)

I performed the following CreoSon-request:

  "command": "file",
  "function": "get_transform",
  "data": {
    "path": [
      204
    ],
    "csys": "ASM_CS0"
  }
}

MAIN.ASM and SUBPART.ASM in MM:

{
  "y_rot": -100.07476545917558,
  "origin": {
    "x": 30.84250634280203,
    "z": 17.998237600527514,
    "y": -17.23969563833292
  },
  "z_axis": {
    "x": -0.04007299425401964,
    "z": -0.042426339001600206,
    "y": -0.9982956280032678
  },
  "y_axis": {
    "x": -0.9837833212075756,
    "z": -0.1731346262595883,
    "y": 0.04684845892603978
  },
  "x_axis": {
    "x": -0.17482714905102545,
    "z": 0.98398394648941,
    "y": -0.034800301806400424
  },
  "x_rot": 87.31316953472023,
  "z_rot": 1.994313096636586
}

MAIN.ASM and SUBPART.ASM in M:

{
  "y_rot": -100.0747654591756,
  "origin": {
    "x": 0.03084250634280203,
    "z": 0.017998237600527513,
    "y": -0.017239695638332917
  },
  "z_axis": {
    "x": -0.04007299425401963,
    "z": -0.042426339001600206,
    "y": -0.9982956280032678
  },
  "y_axis": {
    "x": -0.9837833212075757,
    "z": -0.1731346262595883,
    "y": 0.04684845892603978
  },
  "x_axis": {
    "x": -0.17482714905102548,
    "z": 0.9839839464894101,
    "y": -0.03480030180640043
  },
  "x_rot": 87.31316953472023,
  "z_rot": 1.9943130966365863
}

MAIN.ASM in M, SUBPART.ASM in MM:

{
  "y_rot": -100.0747654591756,
  "origin": {
    "x": 0.03084250634280203,
    "z": 0.017998237600527513,
    "y": -0.017239695638332917
  },
  "z_axis": {
    "x": -0.000040072994254019635,
    "z": -0.00004242633900160021,
    "y": -0.0009982956280032678
  },
  "y_axis": {
    "x": -0.0009837833212075757,
    "z": -0.00017313462625958832,
    "y": 0.000046848458926039785
  },
  "x_axis": {
    "x": -0.0001748271490510255,
    "z": 0.0009839839464894102,
    "y": -0.000034800301806400433
  },
  "x_rot": 87.31316953472023,
  "z_rot": 0.0019939104196906973
}

We can see, that the translations ("origin") are correct in all three cases, but the rotations are wrong, If the main-model and the sub-model use different Length-Units! It looks like the x,y,z_axis are scaled by 1000 - and z_rot is scaled by 1000.

adama2000 commented 3 years ago

Hm, I will need to investigate. I know that the function as coded does not take into account what the units of the components are -- it assumes that all components in the assembly use the same units.