Delphiで作業するときに得られた結果を誰かが役に立つかもしれません。
Tekla Structuresライブラリの接続
Tekla Structuresプログラムが正しくインストールされている場合、 [プロジェクト]-> [タイプライブラリのインポート]で次のことがわかります。
- Tekla_Structures(バージョン__)
- Tekla_Structures_Model(バージョン__)
ほとんどの場合、それらはすぐにはインストールされず、いくつかのクラス名を変更する必要があります。 使用中のTekla_Structures_TLBとTekla_Structures_Model_TLBをプロジェクトに接続することを忘れないでください。
Tekla Structuresに接続する
接続するには、Tekla Structuresが起動され、必要なモデルが開かれている必要があります。
procedure TeklaConnect; var appModel: TModel; pi: ProjectInfo; mi: ModelInfo; mainInfo: String; begin appModel := TModel.Create(self); // Tekla if appModel.GetConnectionStatus then // begin pi := appModel.GetProjectInfo; // - , , .. mi := appModel.GetInfo; // - mainInfo := 'ModelName: ' + mi.ModelName; mainInfo := mainInfo + ' ModelPath: ' + mi.ModelPath; mainInfo := mainInfo + ' ProjectNumber: ' + pi.ProjectNumber; end end;
モデルオブジェクトの取得
モデルからオブジェクトを取得するには、いくつかのオプションがあります。
procedure TeklaConnect; var objEnum: ModelObjectEnumerator; appModel: TModel; mainInfo: String; begin ... objEnum := appModel.GetModelObjectSelector.GetAllObjects; // №1 objEnum := appModel.GetModelObjectSelector.GetAllObjectsWithType(ModelObjectEnum_BEAM); // №2 mainInfo := mainInfo + ' Size: ' + IntToStr(objEnum.GetSize); end;
すべての場合において、モデル要素は繰り返して取得されることに注意してください。 アセンブリK-1がモデルで5回見つかった場合、objEnumで何度も会います。
得られたモデルオブジェクトの分析
procedure TeklaConnect; var appModel: TModel; objEnum, objEnumChild: ModelObjectEnumerator; objModel: ModelObject; BeamObject: Beam; objectInfo: String; p: Profile; m: Material; profile, material: WideString; length,profile_width: Double; begin objEnum := appModel.GetModelObjectSelector.GetAllObjects; while (objEnum.MoveNext) do begin if objEnum.Current <> nil then begin objModel := objEnum.Current; profile := ''; objModel.GetReportProperty('PROFILE',profile); // - , , . material := ''; objModel.GetReportProperty('MATERIAL',material); //, length := 0.0; objModel.GetReportProperty_2('LENGTH',length); // profile_width := 0.0; objModel.GetReportProperty_2('PROFILE.WIDTH',profile_width); // objEnumChild := objModel.GetChildren; // end; end; // objEnum := appModel.GetModelObjectSelector.GetAllObjectsWithType(ModelObjectEnum_BEAM); while (objEnum.MoveNext) do begin BeamObject := objEnum.Current as Beam; if (BeamObject <> nil) then begin p := BeamObject.Profile; // - , , . m := BeamObject.Material; //, objectInfo := BeamObject.GetPartMark; objectInfo := objectInfo + ' ' + p.ProfileString + ' ' + m.MaterialString; objEnumChild := BeamObject.GetChildren; // end; end; end;
コードを作成する際、Tekla Structuresで配布されているAPIヘルプを使用しました。