Getting the properties value of connector destination port in system composer

2 ビュー (過去 30 日間)
Sarvesh
Sarvesh 2023 年 11 月 30 日
コメント済み: Josh Kahn 2023 年 12 月 5 日
Hi,
I am writing a script to create a Electrical analysis for architectural model.
Lets suppose my connectors between two ports act as wire, I assign a resistivity and wire lenght to the connector as a stereotype.
And the source of the wire(connector) has a stereotype which mentions a CurrentValue.
Now, suppose there are 10 connections in the model. I want to scan all the connectors in the model; I use following:
connectors = find(modelObj, constraintforConnector , ElementType = "Connector");
Now that I have connectors I want its source port and destination port address and I want to access the properties of the these ports. How can I do it?

採用された回答

Josh Kahn
Josh Kahn 2023 年 12 月 1 日
If the connector is between input/output ports then you can use the SourcePort and DestinationPort properties of the connector handle.
If the connector is between physical ports, then you can use the Ports property of the connector handle (physical ports are non-directional).
model = systemcomposer.loadModel('arch1');
constraint = systemcomposer.query.AnyComponent; % "Select All"
connectors = find(model, constraint, ElementType="Connector");
for connectorIdx = 1:numel(connectors)
connector = connectors(connectorIdx);
if isa(connector, 'systemcomposer.arch.PhysicalConnector')
connector.Ports
else
connector.SourcePort
connector.DestinationPort
end
end
Regards,
Josh
  2 件のコメント
Sarvesh
Sarvesh 2023 年 12 月 5 日
Perfect. Thanks, I ultimately ended up doing the same thing.
I struggled a bit to get the basic properties of the connector than I got to know it is just connector.SourcePort. Made life easy.
Thanks again!
Josh Kahn
Josh Kahn 2023 年 12 月 5 日
No problem, glad to hear you are unblocked.
Josh

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSystem Composer についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by