Convert Directshape to solid

Convert Directshape to solid

DVanQuyet
Contributor Contributor
948 Views
8 Replies
Message 1 of 9

Convert Directshape to solid

DVanQuyet
Contributor
Contributor

Is there any way to convert directshape to solid?

Screenshot_7.png

0 Likes
Accepted solutions (2)
949 Views
8 Replies
Replies (8)
Message 2 of 9

Mohamed_Arshad
Advisor
Advisor

Hi @DVanQuyet 

 

  There is no Direct method to convert the direct shape to Solid. We can use Element.getGeometry(option) method.
though iteration process From GeometryElement to GeometryObject -->we can able to find the SOLID.

Please check the below Code for additional reference.

Options opt = new Options();
            opt.ComputeReferences = true;

            GeometryElement element = directShape.get_Geometry(opt);

            Solid solid = null;

            foreach (GeometryObject obj in element)
            {
                if (obj is Solid)
                {
                    solid = obj as Solid;
                }
            }

Hope This Helps!!!


Mohamed Arshad K
Software Developer (CAD & BIM)

Message 3 of 9

DVanQuyet
Contributor
Contributor
hi @Mohamed_Arshad
Thank you
Use this way it always returns null
0 Likes
Message 4 of 9

Mohamed_Arshad
Advisor
Advisor

HI @DVanQuyet 

Try to get DirectShape Element from outside the transaction by using its ElementId or Element Name.

Or Can you send me your code snippet?
So that i can check why null is returned.


Mohamed Arshad K
Software Developer (CAD & BIM)

0 Likes
Message 5 of 9

DVanQuyet
Contributor
Contributor
hi @Mohamed_Arshad
I think the problem is that DirectShape returns Mesh but not Solid
0 Likes
Message 6 of 9

Mohamed_Arshad
Advisor
Advisor
Accepted solution

Hi @DVanQuyet 
For this Case My Suggestion :),
Check with the Revit Lookup, After creating or selecting the DirectShape.

 

arshad99_0-1663329684655.png

 


Mohamed Arshad K
Software Developer (CAD & BIM)

0 Likes
Message 7 of 9

DVanQuyet
Contributor
Contributor

I also followed your suggestion but actually the result is mesh
bim06KBNK9_0-1663551907276.pngbim06KBNK9_1-1663552011651.png

 

0 Likes
Message 8 of 9

DVanQuyet
Contributor
Contributor
Accepted solution
hi @Mohamed_Arshad
Thank you, I modified it a bit according to your code

Options opt = new Options();
opt.ComputeReferences = true;

GeometryElement element = el.get_Geometry(opt);

Mesh mesh = null;

foreach (GeometryObject obj in element)
{
if (obj is Mesh)
{
mesh = obj as Mesh;
}
}
0 Likes
Message 9 of 9

Mohamed_Arshad
Advisor
Advisor

Hi @DVanQuyet 


    If your problem is solved, Please accept it as a solution, In the future, it may be easy for other people facing same
problem.

Thank you so much... 🙂


Mohamed Arshad K
Software Developer (CAD & BIM)

0 Likes