Hi,
Any one knows that how to get X & Y co-ordinate of Model Attribute using ARIS Script? Please help.
Hi,
Any one knows that how to get X & Y co-ordinate of Model Attribute using ARIS Script? Please help.
Your code is missing an iteration, and I also made a mistake.
I'm not used to Ariene Kroeze's way of doing for loops, that's why I got confused. You can compress something like
for (var i in oAttrOccList ){
var oAttrOcc = oAttrOccList[i]into a single line
for each (var oAttrOcc in oAttrOccList ){What is important is that you don't forget the "each" like I did with my original comment.
my entire (tested) proof-of-concept test script, maybe it helps:
var allModels = ArisData.getSelectedModels();
for each(var singleModel in allModels){
var allObjOccs = singleModel.ObjOccList();
for each (var singleObjOcc in allObjOccs){
var oAttrOccList = singleObjOcc.AttrOccList();
for each (var oAttrOcc in oAttrOccList ){
var iX = oAttrOcc.OffsetX()
var iY = oAttrOcc.OffsetY()
}
}
}
//placement of model attributes
var oTextOccs = oModel.TextOccList()
for each(var oTextOcc in oTextOccs){
var oModelAttrOccList = oTextOcc.AttrOccList();
if (oModelAttrOccList.length>0){
var AttrNo= oModelAttrOccList[0].AttrDef(-1).getValue()
if (parseInt(AttrNo)>0){
// content of textbox is model attribute
var iX = oTextOcc.X() //x-pos of the free-form text in 1/10 mm (LOMETRIC).
var iY = oTextOcc.Y() //y-pos of the free-form text in 1/10 mm (LOMETRIC).
}
}
}
//Placements of attributes of ObjOccs
var oAttrOccList = oObjOcc.AttrOccList()
for (var i in AttrOccList){
var oAttrOcc = oAttrOccList[i]
var iX = oAttrOcc.OffsetX() //Offset in 1/10 mm (LOMETRIC).
var iY = oAttrOcc.OffsetY() //Offset in 1/10 mm (LOMETRIC).
}Best regards, Ariene Kroeze
Thank you Ariene, It is realy helpfull. but how can I find X, Y cordidate of specific Attribute. for example. I want to draw 'Last Change' Attribute in place of 'Last user' Attribute in diagram at exact X, Y cordinate location of 'Last user' attribute. once draw the 'Last Change' attribute then I'll remove the 'Last user' attribute. can you help me in this?
var oAttrOccList = oObjOcc.AttrOccList()
for (var i in AttrOccList){
var oAttrOcc = oAttrOccList[i]
Shouldn't those three lines look something closer to those two lines?
var oAttrOccList = oObjOcc.AttrOccList()
for (var oAttrOcc in oAttrOccList){
Hi Kay,
Thanks
I am doing as below and oObjOcc.AttrOccList() this line throw error can't find function
var oObjOcc= oModel.ObjOccList()
var oAttrOccList = oObjOcc.AttrOccList() // This line gives error can't find function
for (var i in oAttrOccList ){
var oAttrOcc = oAttrOccList[i]
var iX = oAttrOcc.OffsetX() //Offset in 1/10 mm (LOMETRIC).
var iY = oAttrOcc.OffsetY() //Offset in 1/10 mm (LOMETRIC).
}
Your code is missing an iteration, and I also made a mistake.
I'm not used to Ariene Kroeze's way of doing for loops, that's why I got confused. You can compress something like
for (var i in oAttrOccList ){
var oAttrOcc = oAttrOccList[i]into a single line
for each (var oAttrOcc in oAttrOccList ){What is important is that you don't forget the "each" like I did with my original comment.
my entire (tested) proof-of-concept test script, maybe it helps:
var allModels = ArisData.getSelectedModels();
for each(var singleModel in allModels){
var allObjOccs = singleModel.ObjOccList();
for each (var singleObjOcc in allObjOccs){
var oAttrOccList = singleObjOcc.AttrOccList();
for each (var oAttrOcc in oAttrOccList ){
var iX = oAttrOcc.OffsetX()
var iY = oAttrOcc.OffsetY()
}
}
}//to create a textbox with a reference to a model attribute: oModel.CreateTextOcc (iX, iY, p_nAttrTypeNum )
//to remove a model attribute e.g. attribute 'Name'
var oTextOccs = oModel.TextOccList()
for each(var oTextOcc in oTextOccs){
var oModelAttrOccList = oTextOcc.AttrOccList();
if (oModelAttrOccList.length>0){
var AttrNo= oModelAttrOccList[0].AttrDef(-1).getValue()
if (parseInt(AttrNo)>0){
// content of textbox is model attribute
if (AttrNo == Constants.AT_NAME){
oTextOcc.Remove(true)
}
}
}
}
manoj chauhan Author on
Please anyone can help