Delmia DPE開發-高階函式
多個屬性獲取與賦值
1.多個屬性獲取:dim attributes (1)
attributes(0)="name"
attributes(1)="nameshort"
values = Data.GetAttributesbyId(id, attributes)
attribute = values( i, 0 )
value = values( i, 1 )
多個屬性賦值 :dim attributes (1, 1)
attributes(0, 0) = "name"
attributes(0, 1) = "Assembly"
attributes(1, 0) = "nameshort"
attributes(1, 1) = "123"
call Data.SetAttributesbyId(object_id, attributes)
查詢功能
1.函式說明:
Query.ResetSearch
Query.SetQuery def_tablename1, def_attribute1, def_operator1, def_vartocompare1
call Query.SetConcatenator(bstrConcatenator)
result_id = Query.GetFirstResult
result_id = Query.GetNextResult
說明:(1)def_tablename1:“ergocompbase”:工藝、資源、產品節點;
“ergocompprocessdefault”:工藝節點;
“ergocompplantdefault”:資源節點;
“ergocompproductdefault”:產品節點。
(2) def_attribute1:PTS屬性名稱;
(3) def_operator1:比較符(AND、Or、(、)、XOR、IN_PRECEDING_QUERY);
(4) def_vartocompare1:比較屬性值。
2.注意:(1) 支援模糊查詢”*”
(2) <、<=、>、>=幾個符號時比較大小用的,不進行全字元段比較。(如:1 12 19 30幾個資料,比較符為>2,則只有30符號條件)
獲取當前登入使用者
1.獲取當前登入使用者名稱稱
userid = Rights.GetCurrentUser()
name_user = Data. GetAttributebyId(user_id, "nameshort")
2.獲取當前登入使用者所在組名稱
Dim id_group() ‘當前登入使用者所在組
id_group = Rights.GetUserMemberships(userid)
For i = LBound(id_group, 1) To UBound(id_group, 1)
name_group= Data.GetAttributebyId(id_group(i), "nameshort")
Next
版本處理-版本
1. 建立新版本:
new_version_id = Version.Create(old_base_id)
new_version_id = Version.CreateDeep(old_base_id)
2. 使用某版本:
call Version.Use(new_version_id, parent_id, old_base_id)
3.建立並使用新版本: new_version_id=Version.CheckOut(old_base_id,parent_id,old_sci_id)
new_version_id=Version.CheckOut(old_base_id,parent_id,old_sci_id)
4.獲取第一個版本id:
first_version_id=Version.GetFirstVersion(old_base_id)
版本處理-狀態
1.獲取當前節點狀態:
ps_id = Version.GetPlanningState(base_id)
ps_name = Data.GetAttributebyId(ps_id, "name")
2.獲取當前專案或庫中設定的狀態值
Dim states()
states = Version.GetPlanningStates(Baseid, PlanningState, library)
引數:Baseid:要修改的節點的baseid(專案中其他節點baseid也可以)
PlanningState:值為"ALL"、"WORKING"、"INTEGRATE"、"RELEASED"、"HIGHER_LEVEL"之一,即範圍
Library:值為"LOCAL"、"GLOBAL"之一,即:本專案庫(project library)或全專案庫(library)
3.修改節點狀態 :
For i = 0 To UBound(states, 1)
If states(i) <> "" Then
ps_name = Data.GetAttributebyId(states(i), "name")
If ps_name = ODataState Then
Call Version.SetPlanningState(OBaseid, state_id)
End If
End If
Next
全域性變數獲取
1.讀取變數
value = Data.ReadSessionData(bstrKey, bstrAttribute, bstrLocation)
2.寫入變數:
Call Data.WriteSessionData(bstrKey, bstrAttribute, bstrLocation, vValue)
引數:bstrkey:節點位置;
bstrAttribute:變數名稱;
bstrLocation:變數位置;
vValue:變數值(僅寫入變數值時用);