Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SketchPoints->add sample not working in C++

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
ArjayHawco
247 Views, 4 Replies

SketchPoints->add sample not working in C++

Hi,

I copied the sketchpoints add C++ example and posted it into my C++ add-in.

// Get sketch texts
Ptr<SketchPoints> sketchPoints = toothSketch->sketchPoints(); // NOTE: toothSketch has been changed from the sample but is a valid sketch
if (!sketchPoints)
return false;

// Create sketch point
Ptr<Point3D> point = Point3D::create(1.0, 1.0, 0);
Ptr<SketchPoint> sketchPoint = sketchPoints->add(point);  // compile error
if (!sketchPoint)
return false;

The sketchPoints->add(point) line gives me the following error:
adsk::fusion::sketchpoints C++ pointer or reference to incomplete type

Btw, using Visual Studio 2022 on Windows 11.

Please help.

Thanks

4 REPLIES 4
Message 2 of 5
john.kirchner
in reply to: ArjayHawco

It looks like the error is probably coming from the 'toothSketch' variable - can you post the code where that is initialized/any additional context where that sketch is coming from?



Message 3 of 5
ArjayHawco
in reply to: ArjayHawco

deleted.  see latest comment.

Message 4 of 5
ArjayHawco
in reply to: john.kirchner

John, thanks for taking the time to respond.  I think I may have figured it out.

When I started my add-in, I basically copied the code from the spurgear.cpp sample.

This sample has a bunch of #include statements which a new c++ sample add-in doesn't include.

When I remove these extra #include statements the sketchPoints->Add problem goes away.

Extra spurgear sample includes:

#include <Core/Utils.h>
#include <Core/Application/Application.h>
#include <Core/Application/Product.h>
#include <Core/Application/ValueInput.h>
#include <Core/Application/UnitsManager.h>
#include <Core/Application/ObjectCollection.h>
#include <Core/Geometry/Point3D.h>
#include <Core/Geometry/Matrix3D.h>
#include <Core/Geometry/Surface.h>
#include <Core/Geometry/Curve3D.h>
#include <Core/Geometry/Line3D.h>
#include <Core/UserInterface/UserInterface.h>
#include <Core/UserInterface/CommandCreatedEventHandler.h>
#include <Core/UserInterface/CommandCreatedEvent.h>
#include <Core/UserInterface/CommandCreatedEventArgs.h>
#include <Core/UserInterface/CommandEvent.h>
#include <Core/UserInterface/CommandEventArgs.h>
#include <Core/UserInterface/CommandEventHandler.h>
#include <Core/UserInterface/ValidateInputsEventHandler.h>
#include <Core/UserInterface/ValidateInputsEvent.h>
#include <Core/UserInterface/ValidateInputsEventArgs.h>
#include <Core/UserInterface/InputChangedEventHandler.h>
#include <Core/UserInterface/InputChangedEvent.h>
#include <Core/UserInterface/InputChangedEventArgs.h>
#include <Core/UserInterface/Command.h>
#include <Core/UserInterface/CommandDefinition.h>
#include <Core/UserInterface/CommandDefinitions.h>
#include <Core/UserInterface/CommandInputs.h>
#include <Core/UserInterface/ValueCommandInput.h>
#include <Core/UserInterface/StringValueCommandInput.h>
#include <Core/UserInterface/DropDownCommandInput.h>
#include <Core/UserInterface/ListItems.h>
#include <Core/UserInterface/ListItem.h>
#include <Core/UserInterface/ImageCommandInput.h>
#include <Core/UserInterface/TextBoxCommandInput.h>
#include <Core/UserInterface/ToolbarPanelList.h>
#include <Core/UserInterface/ToolbarPanels.h>
#include <Core/UserInterface/ToolbarPanel.h>
#include <Core/UserInterface/ToolbarControls.h>
#include <Core/UserInterface/ToolbarControl.h>
#include <Core/UserInterface/CommandControl.h>
#include <Core/UserInterface/Workspaces.h>
#include <Core/UserInterface/Workspace.h>
#include <Core/Application/Attributes.h>
#include <Core/Application/Attribute.h>
#include <Fusion/Fusion/Design.h>
#include <Fusion/Components/Component.h>
#include <Fusion/Components/Occurrences.h>
#include <Fusion/Components/Occurrence.h>
#include <Fusion/BRep/BRepFaces.h>
#include <Fusion/BRep/BRepFace.h>
#include <Fusion/BRep/BRepEdges.h>
#include <Fusion/BRep/BRepEdge.h>
#include <Fusion/BRep/BRepBody.h>
#include <Fusion/Construction/ConstructionPlane.h>
#include <Fusion/Sketch/Sketches.h>
#include <Fusion/Sketch/Sketch.h>
#include <Fusion/Sketch/SketchCurves.h>
#include <Fusion/Sketch/SketchLines.h>
#include <Fusion/Sketch/SketchLine.h>
#include <Fusion/Sketch/SketchArcs.h>
#include <Fusion/Sketch/SketchArc.h>
#include <Fusion/Sketch/SketchPoint.h>
#include <Fusion/Sketch/SketchFittedSplines.h>
#include <Fusion/Sketch/SketchFittedSpline.h>
#include <Fusion/Sketch/SketchCircles.h>
#include <Fusion/Sketch/SketchCircle.h>
#include <Fusion/Sketch/GeometricConstraints.h>
#include <Fusion/Sketch/TangentConstraint.h>
#include <Fusion/Sketch/Profile.h>
#include <Fusion/Sketch/Profiles.h>
#include <Fusion/Sketch/ProfileLoops.h>
#include <Fusion/Features/Features.h>
#include <Fusion/Features/ExtrudeFeatures.h>
#include <Fusion/Features/ExtrudeFeatureInput.h>
#include <Fusion/Features/ExtrudeFeature.h>
#include <Fusion/Features/FilletFeatures.h>
#include <Fusion/Features/FilletFeatureInput.h>
#include <Fusion/Features/FilletFeature.h>
#include <Fusion/Features/CircularPatternFeatures.h>
#include <Fusion/Features/CircularPatternFeatureInput.h>
#include <Fusion/Features/CircularPatternFeature.h>
#include <Fusion/Fusion/Timeline.h>
#include <Fusion/Fusion/TimelineObject.h>
#include <Fusion/Fusion/TimelineGroups.h>
#include <Fusion/Fusion/TimelineGroup.h>

#include <sstream>
#define _USE_MATH_DEFINES
#include <math.h>
#include <memory>

#if defined(_WINDOWS) || defined(_WIN32) || defined(_WIN64)
#include <windows.h>
#else
#include <dlfcn.h>
#endif

using namespace adsk::core;
using namespace adsk::fusion;

 

New sample includes:

#include <Core/CoreAll.h>
#include <Fusion/FusionAll.h>
#include <Cam/CamAll.h>

using namespace adsk::core;
using namespace adsk::fusion;
using namespace adsk::cam;

Ptr<Application> app;
Ptr<UserInterface> ui;

 

Thanks for your help.  I really appreciate it.

Regards,

Arjay

Message 5 of 5
BrianEkins
in reply to: ArjayHawco

The XXXAll.h files include every header file. Although it looks like the Spur Gear sample includes a lot more, it only includes the needed files rather than everything. I would guess that you have some additional code that's not in the Spur Gear add-in that requires adding the includes for that functionality.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com

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

Post to forums  

Autodesk Design & Make Report