Cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

Native attribute(s) of an Object

Pioneer
Pioneer

Hello everyone,

 

I would like to ask whether there is a way (command in SimTalk) how to check whether a certain (NOT user-defined) attributes of a specific object exists or not. For example, I want to find out, whether a certain object has or has not the attribute "ShiftCalendarObject".

If it was a user-defined object I would use the command "getAttrNo". Yet, I do not know how to ask the same query regarding a "native" attribute.

I do not need to inquire the VALUE of the attribute, but whether it exists or not.

 

Thank you very much in advance.

11 REPLIES 11

Re: Native attribute(s) of an Object

Siemens Phenom Siemens Phenom
Siemens Phenom
<Path>.hasAttribute(AttributeName:string) → boolean

Regards

Always consider using the AttributeExplorer!

Re: Native attribute(s) of an Object

Siemens Phenom Siemens Phenom
Siemens Phenom
I think that the command "<Path>.hasAttribute" is the one you're looking for.

Re: Native attribute(s) of an Object

Legend
Legend

<Path>.isNameUnique("StringName") --> boolean

Re: Native attribute(s) of an Object

Pioneer
Pioneer

Thank you,

 

neither the command "isNameUnique" nor "HasAttribute" works.

Yet, I found the command PutAttributeNamesIntoTable which seems to pot all attributes into a table in which I can then easily find the individual attribute (if its exists).

 

This semms to be a satisfactory solution, so far.

Re: Native attribute(s) of an Object

Phenom
Phenom

@JiriHloska 

 

...neither the command "isNameUnique" nor "HasAttribute" works....

 

Sorry, but I cannot follow you there,  as both methods work.

 

Please provide an example, highlighting in which way you called the methods to fail.

 

 

Re: Native attribute(s) of an Object

Siemens Phenom Siemens Phenom
Siemens Phenom

Also, which version of Plant Simulation are you using? "HasAttributed" was added somewhere between PlantSim 13.1 and 14.0. (I dont' know which one)

 

Edit: Apparenty it was added in PlantSim 14.1

Re: Native attribute(s) of an Object

Pioneer
Pioneer

That might be the case - I am still using PS 13.0.9

 

Therefore, the command HasAttribute is not provided.

The command

SingleProc.isNameUnique("ProcTime") returns false.

 

- I am not sure how to recognize then whether the Attribute exists or not...

 

Best regards.

Re: Native attribute(s) of an Object

Siemens Phenom Siemens Phenom
Siemens Phenom

"IsNameUnique" only checks whether or not the string (in this case "ProcTime") is used as a name on any object already present in the model. Two objects in the same frame can not have the same name, as you probably already know.

 

Edit: ignore the advice above, it seem like I misunderstood how the command "IsNameUnique" works.

 

I see two solutions: Either check the objects manually, either with the help guide or the "Show attributes and methods" window. (right click on an object/select the object and press F8)

 

Or do as @Eventdebugger usually says:

Always consider using the AttributeExplorer!

Re: Native attribute(s) of an Object

Phenom
Phenom

@MarcusA ,

@JiriHloska 

 

If I read well, checking, if an attribute (name)  exits or not,

 

is what @JiriHloska is looking for.

 

IsNameUnique does exactly this (also in v13 s.b.)

 

returning false means the name / attribute is not unique -> exists

 

returning true means the name / attribute is unique -> does not yet exist

 

 

For more details have a look at "isNameUnique" in the help file

 

Unbenannt.PNG