The following will probably work for your use-case.
Pick a model and a type of component to select:
In[]:=
model="Modelica.Mechanics.MultiBody.Examples.Elementary.SpringDamperSystem";​​type="Modelica.Mechanics.MultiBody.Forces.Spring";
Select the components:
In[]:=
selectComps=Select[SystemModel[model,"Components"],#[[-1,1]]===type&]
Out[]=
spring1∈
,spring2∈

Create a string pattern to select the variables inside these components:
In[]:=
stringpattern=(Alternatives@@selectComps[[All,1]])~~"."~~__
Out[]=
spring1|spring2~~.~~__
Find the variables that match the pattern:
In[]:=
vars=SystemModel[model,{"SystemVariables",stringpattern}];
In[]:=
vars//Short
Out[]//Short=
{
spring1.coilWidth
,
spring1.color[1]
,407,
spring2.lineForce.lineShape.R.w[3]
}
The previous approach requires some parsing of the model that may or may not be ideal for your model, depending on the size. If this call is not feasible, you can always simulate the model for 0 seconds indicating that you want to store all the variables, and extract the variables from the simulation results instead:
In[]:=
varsFromSimulation=SystemModelSimulate[model,All,0][{"VariableNames",stringpattern}];
In[]:=
varsFromSimulation//Short
Out[]//Short=
{spring1.coilWidth,spring1.color[1],406,spring2.spring.s_rel,spring2.width}
Notice that the format of the variables is different in each case:
In[]:=
vars[[1]]//Head
Out[]=
QuantityVariable
In[]:=
varsFromSimulation[[1]]//Head
Out[]=
String
This is because when variables are extracted without simulation they are often used in equations that are passed to functions such as NDSolve. And NDSolve does not support string variables:
In[]:=
NDSolve[{"x"'[t]=="x"[t]},{"x"[t]},{t,0,10}]
NDSolve
:x[t] cannot be used as a function.
Out[]=
NDSolve[{
′
x
[t]x[t]},{x[t]},{t,0,10}]