Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to create Z-offset Extrusion via API

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
YaGitHub
677 Views, 3 Replies

How to create Z-offset Extrusion via API

Hi, kinds!

I wanna make a function for creating Extrusion easily like that:

Extrusion createExtrusionZ(CurveArrArray pProfile, double bottom, double height)
        {
            // mm to feet
            double bottomF = mmToFeet(bottom);
            double heightF = mmToFeet(height);

            // create Sketch Plane
            Plane pPlane = Plane.CreateByNormalAndOrigin(new XYZ(0.0,0.0,1.0),new XYZ(0.0,0.0,bottomF));
            SketchPlane pSketchPlane = SketchPlane.Create(_rvtDoc, pPlane) as SketchPlane;

            // return new Extrusion
            bool bIsSolid = true;
            return _rvtDoc.FamilyCreate.NewExtrusion(bIsSolid, pProfile, pSketchPlane, heightF);
        }

 

I expect that extrusion from [bottom] to [bottom + height] at Z direction, but I get that from [0] to [height] always.

I suspect that the way to create SketchPlane is mistaken, but I don't have any certain idea.

 

Could you give me a hand, gentles?

3 REPLIES 3
Message 2 of 4
RPTHOMAS108
in reply to: YaGitHub

Try putting your start Z values into the points in your profile.

Message 3 of 4
YaGitHub
in reply to: RPTHOMAS108

Thank you, Sir.

I could understand the specification of NewExtrusion-function.

 

But I wanna make a function as I posted. Therefore I did like below:

 Extrusion createExtrusionZ(CurveArrArray pProfile, double bottom, double height)
        {
            // mmToFeet
            double bottomF = mmToFeet(bottom);
            double heightF = mmToFeet(height);

            // make sketch plane
            Plane pPlane = Plane.CreateByNormalAndOrigin(new XYZ(0.0,0.0,1.0),new XYZ(0.0,0.0,0.0));
            SketchPlane pSketchPlane = SketchPlane.Create(_rvtDoc, pPlane) as SketchPlane;

            // make Extrusion
            bool bIsSolid = true;
            Extrusion newExtrusion = _rvtDoc.FamilyCreate.NewExtrusion(bIsSolid, pProfile, pSketchPlane, heightF);

            // move Extrusion
            XYZ transPoint = new XYZ(0.0, 0.0, bottomF);
            ElementTransformUtils.MoveElement(_rvtDoc, newExtrusion.Id, transPoint);
            return newExtrusion;
        }

 

Step 1 : Make new Extrusion attached to Z=0

Step 2 : Move the Extrusion to expected Z

 

🧐

Message 4 of 4
RPTHOMAS108
in reply to: YaGitHub

Intuitively it would seem that the plane would set the z value as you had it but apparently not.

 

I don't know if there is a better option than moving the item after creation to enable you to have the same form of function. Curves in the profile can be iterated and transformed to new Z but I don't know if that would be advantageous or not.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report