In Dynamo code block, can i return a variable input by Functions

hi @markochan2000
you can creat Custom node or using python script.

hello

code block

def XYvector1(x)
{
XYvect=Autodesk.Geometry.Line.Direction(x);
Xvect = Autodesk.Geometry.Vector.X(XYvect);
Yvect = Autodesk.Geometry.Vector.Y(XYvect);

Compaire= Xvect ==0 || Yvect ==0?x:null;
NCompaire= Xvect !=0 && Yvect !=0?x:null;
return {"parallel":Compaire,"Not parallel":NCompaire};

};

Cordially
christian.stan

Hi Sam.
I think I almost got it. Thanks to a post by @ Vikram_Subbaiah in Filter by Bool Mask - #5 by Batman86

Take a look.

The only challenges I have now are

  1. to clean the Empty list

  2. Arrange / Flatten the list in the format

  3. Get Back and pick the actual line rather than the vector from the boolean mask.

I would like to accomplish all these within the function.

Thanks in advance

Hello @markochan2000
I was working for your function after adding flatten and clean function to the design script I did not find a way to pick the actual lines because they are outside of the function so for now this script can only take the vectors because they are inside the function,
i add two Code Blocks as Secondary Solution to achieve your final result
(Take Parallel Lines , Take Not Parallel Lines)

Thanks
Sam;


Function:

def XYvect11(x:var)
{
XYvect=Autodesk.Geometry.Line.Direction(x);
Xvect = Autodesk.Geometry.Vector.X(XYvect);
Yvect = Autodesk.Geometry.Vector.Y(XYvect);

Compaire= Xvect || Yvect ==0?false:true;
t3 =(DSCore.List.FilterByBoolMask(XYvect, Compaire));

t4 = DSCore.List.Flatten((Dictionary.ValueAtKey(t3, “in”))@L3,0);
CleanT4 =List.Clean(t4,false);

t5 = DSCore.List.Flatten((Dictionary.ValueAtKey(t3, “out”))@L3,0);
CleanT5 =List.Clean(t5,false);

return [CleanT4,CleanT5,Compaire];

};

Code Bloc for Parallel Lines:
t4 =List.Clean(Dictionary.ValueAtKey((DSCore.List.FilterByBoolMask(lstLines, Compaire)), “in”),false);

CodeBlock For Not Parallel Lines:
t4 =List.Clean(Dictionary.ValueAtKey((DSCore.List.FilterByBoolMask(lstLines, Compaire)), “out”),false);

1 Like

Thanks a lot. I will try further fromm here.

1 Like

@markochan2000
you welcome .