How do I set the photo eye type in code?

How do I set the photo eye type in code?

axel_kohonen
Not applicable
1,029 Views
5 Replies
Message 1 of 6

How do I set the photo eye type in code?

axel_kohonen
Not applicable

[ FlexSim 16.0.1 ]

Hi,

I have a photo eye that I put on a conveyor using code (just create the photo eye into the conveyor to create the link automatically) and I would want the photo to be a certain pre-defined type that I have created earlier. How can I set the type in code? Should I first create a basic photo eye with createinstance and then set the type or can I create a copy of the instance in the conveyor system?

Thank you!

Kind regards,

Axel

Accepted solutions (1)
1,030 Views
5 Replies
Replies (5)
Message 2 of 6

Matthew_Gillespie
Autodesk
Autodesk
Accepted solution

Photo Eyes (and all conveyor objects) have a type variable that points at their type object. This can either be a global type stored on the Conveyor System object or a custom type stored in the objects variables.

To set the type just point the type variable at the desired type:

treenode photoEye = node("PE1", model());
treenode typeVar = getvarnode(photoEye, "type");
treenode desiredType = node("ConveyorSystem>variables/photoEyeTypes/PEType1", model());

nodepoint(typeVar, desiredType);

You can sample the types in the toolbox from the sampler in the script console to get the paths to each type.

409-typesampler.png

To set the type to custom point the "type" variable at the object's "localType" variable.



Matthew Gillespie
FlexSim Software Developer

Message 3 of 6

arunTTT2P
Collaborator
Collaborator

Hi Mathew,

Can you explain why you used nodepoint() command?

Is the photo eye type a coupling data in the photo-eye object.

Regards,

Arun KR

0 Likes
Message 4 of 6

axel_kohonen
Not applicable

Thank you Matthew! Works well. I would like to know the answer to Arun's comment as well.

Axel

0 Likes
Message 5 of 6

Matthew_Gillespie
Autodesk
Autodesk

Yes, I used the nodepoint command because the type variable has coupling data. This means it stores a reference to another node, or that it "points" at another node. The way that you set what a coupling node is pointing at is to use the nodepoint command.

@Axel Kohonen



Matthew Gillespie
FlexSim Software Developer

Message 6 of 6

Ben_WilsonADSK
Community Manager
Community Manager

Anyone finding this thread looking for more information on couplings, in addition to the nodepoint() command, which is a one-way pointer, be sure to check out createcoupling(), which creates a two-way pointer/reference.