XYZ C++ constructor

XYZ C++ constructor

rgwessel
Participant Participant
583 Views
2 Replies
Message 1 of 3

XYZ C++ constructor

rgwessel
Participant
Participant

I'm developing a Revit add-in to import models from a 3rd-party format. The code is already written and running on several (OS+BIM) platforms in C++ and I've essentially been filling in the gaps for the wrapper layer for Revit. The add-in is working to the point that it reads the file and creates Levels in Revit for the geometry to be attached to. So far so good.

 

But I've hit an unexpected snag. There's probably an easy answer, but I haven't got to the bottom of it yet: the constructor for an XYZ object in C++ should have two forms:

1) public : XYZ()

    Member of Autodesk::Revit::DB::XYZ

Summary:

Creates a default XYZ with the values (0, 0, 0).

 

2) public : XYZ(double x, double y, double z)

    Member of Autodesk::Revit::DB::XYZ

Summary:

Creates an XYZ with the supplied coordinates.

Parameters:

x: The first coordinate.

y: The second coordinate.

z: The third coordinate.

 

However, VS does not seem to acknowledge the existence of the second. If I try something like:

 

 

 

auto test = gcnew XYZ(0.0, 1.0, 2.0);

 

 

 

…I get an error that there are "too many arguments". The only constructor that works is the default, i.e. XYZ().

 

The XYZ class has no mutating functions that would allow a default to be created and then set the x/y/z coords either. All the Revit API documentation says the second constructor exists, but any examples using it are all in C# or VB.

 

Any suggestions?

0 Likes
Accepted solutions (1)
584 Views
2 Replies
Replies (2)
Message 2 of 3

rgwessel
Participant
Participant

This might be VS flakiness - a clean and rebuild and it compiles. But VS still highlights it as an error in the editor (see attached image). I'll provide another update when I've been able to confirm whether the code actually works.

0 Likes
Message 3 of 3

rgwessel
Participant
Participant
Accepted solution

Ok, I can confirm the error flagged up by VS is incorrect - despite underlining things in red all over the place it compiles without any errors and runs perfectly

0 Likes