Been watching and reading alot on Fusion and am to the point of coding a solution
I'm taking a stab at designing the whole thing in C++ for 3 Reasons
A - All the examples so far have been in javascript which isn't in Fusion 360
B - C++ is the base language from what I understand, is more fully typed which will help me with all of these variable type mistakes
C - I hopefully can limit the API to the extrude and hole functions
I know this needs more work and will probably blow up my computer in current form but I kind of have a few questions
1 - Is there a console I can <<cout to for debuging or is there a place to download the fusion 360 API so I can put the include files in Visual Studio. It'd be nice to see what i'm doing
2 - Can I take two sketches and subtract them from each other to get a ring for pipe extrusion
3 - What is the best way is to make holes? I have start point(x,y,z), end point(x,y,z) & diameter for each one
4 - Is this in US or Metric by default, user preference or API & is there an easy way to switch back and forth
1st - Create a pole from a length and 2 circles
2nd - Start stacking holes
3rd - Create the candy cane stripe & push onto stack
4th - Fill stripe with a bunch of fake holes between each other so random holes wont be placed there in the future
5th - Randomly pick Points & check their distance to every hole already in the stack using 3DPoint distance for collision detection
6th - Make all the holes
#include <Core/Application/Application.h>
#include <Core/Application/Documents.h>
#include <Core/Application/Document.h>
#include <Core/Application/ObjectCollection.h>
#include <Core/Application/Product.h>
#include <Core/Application/ValueInput.h>
#include <Core/Geometry/Point3D.h>
#include <Core/UserInterface/UserInterface.h>
#include <Fusion/BRep/BRepFace.h>
#include <Fusion/BRep/BRepFaces.h>
#include <Fusion/Components/Component.h>
#include <Fusion/Construction/ConstructionPlane.h>
#include <Fusion/Construction/ConstructionPlanes.h>
#include <Fusion/Construction/ConstructionPlaneInput.h>
#include <Fusion/Features/Features.h>
#include <Fusion/Features/ExtrudeFeature.h>
#include <Fusion/Features/ExtrudeFeatures.h>
#include <Fusion/Features/ExtrudeFeatureInput.h>
#include <Fusion/Features/HoleFeature.h>
#include <Fusion/Features/HoleFeatures.h>
#include <Fusion/Features/HoleFeatureInput.h>
#include <Fusion/Fusion/Design.h>
#include <Fusion/Sketch/Profile.h>
#include <Fusion/Sketch/Profiles.h>
#include <Fusion/Sketch/Sketch.h>
#include <Fusion/Sketch/Sketches.h>
#include <Fusion/Sketch/SketchCircle.h>
#include <Fusion/Sketch/SketchCircles.h>
#include <Fusion/Sketch/SketchCurves.h>
#include <Fusion/Sketch/SketchPoint.h>
#include <Fusion/Sketch/SketchPoints.h>
/*Example is in Javascript not supported*/
//What do I need for US to Metric Conversions
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <ctime> //Random Numbers
#include <random> // Random Numbers
#include <stack>
using namespace std;
using namespace adsk::core;
using namespace adsk::fusion;
// Initialize Variables & Constants
3DPoint Origin = new 3DPoint.create(x, y, z);
<axis> Axis = axis(x)
<plane> Plane = plane(yz)
float LDrillBit = 5/8in;
float MDrillBit = 1/2in;
float SDrillBit = 3/8in;
int MakeHoles = 3000;
int LHoles = 1000;
int MHoles = 1000;
int SHoles = 1000;
float PoleOD = math.convertInToMm(2);
float PoleID = math.convertInToMm(1.5);
float PoleLength = math.convertInToMm(96);
float PoleGapBottom = math.convertInToMm(6);
float PoleGapTop = math.convertInToMm(6);
int Slices = 12; Number of times 360 degrees is split up
float SliceSize = pie*PoleOD/slices;
float Radius = PoleOD/2 + 10mm; //Makes sure srilling starts above pipe surface
/* Create Input Box for above variables & ?Convert US/Metric System? */
//Check to make sure # of Holes is feasable
//Need to finish
if ( MakeHoles >= ceiling(pie*PoleOD/SDrillBit)*(PoleLength-PoleGapBottom-PoleGapTop)/SDrillBit)//Reject Input
if ( MakeHoles >= ceiling(pie*PoleOD/LDrillBit)*(PoleLength-PoleGapBottom-PoleGapTop)/LDrillBit)//Warn user and give option to continue
// Extrude Pole
Extrude = (centerDiameterCircle(origin,PoleODMM) - centerDiameterCircle(origin,PoleIDMM), Pole Length);
//stack of structures
struct hole
{
bool real = true;
float x, y, z;
float size = 0;
//Don't need end coordinates since its always (x,0,0)
}
vector <hole> holes;
hole temp;
temp.x = PoleGapBottom + LDrillBit/2;
temp.size = LDrillBit;
temp.real = true;
float degrees=0;
srand(time(NULL));
Ptr<Point3D> tempPoint = Point3D::create(0, 0, 0);
do // Create 3 hole wide spiral candycane the length of pole with end gaps in mind.
{
temp.y = cos(degrees)*Radius;
temp.z = sin(degrees)*Radius;
holes.push_back(temp); // 1st of 3 holes wide
temp.y = cos((degrees+360/slices)%360);
temp.z = sin((degrees+360/slices)%360);
holes.push_back(temp); // 2nd hole
temp.y = cos((degrees+360/slices*2)%360);
temp.z = sin((degrees+360/slices*2)%360);
holes.push_back(temp); // 3rd hole
degrees = (degrees + 360/slice/2)%360; //Move starting point for next round
temp.x += LDrillBit;
}while(temp.x <= PoleLength - PoleGapTop - LDrillBit/2 );
//How do I make sure random holes wont be put in stripe.
//calculate distance left right stripe for height is passed for each random hole
//fill in blanks holes in stripe for collision calculations
temp.real = false;
int templength = holes.size();
int count = 0;
for(count = 0; count < templength; count+=3)
{
//left hole -> middle hole same row
temp.x = (holes[count+1].x - holes[count].x) / 2 + holes[count].x;
temp.y = (holes[count+1].y - holes[count].y) / 2 + holes[count].y;
temp.z = (holes[count+1].z - holes[count].z) / 2 + holes[count].z;
holes.push_back(temp);
//left hole -> uprow left
temp.x = (holes[count+3].x - holes[count].x) / 2 + holes[count].x;
temp.y = (holes[count+3].y - holes[count].y) / 2 + holes[count].y;
temp.z = (holes[count+3].z - holes[count].z) / 2 + holes[count].z;
holes.push_back(temp);
//middle hole -> uprow left
temp.x = (holes[count+3].x - holes[count+1].x) / 2 + holes[count+1].x;
temp.y = (holes[count+3].y - holes[count+1].y) / 2 + holes[count+1].y;
temp.z = (holes[count+3].z - holes[count+1].z) / 2 + holes[count+1].z;
holes.push_back(temp);
//middle hole -> uprow middle
temp.x = (holes[count+4].x - holes[count+1].x) / 2 + holes[count+1].x;
temp.y = (holes[count+4].y - holes[count+1].y) / 2 + holes[count+1].y;
temp.z = (holes[count+4].z - holes[count+1].z) / 2 + holes[count+1].z;
holes.push_back(temp);
//middle hole -> right same row
temp.x = (holes[count+2].x - holes[count+1].x) / 2 + holes[count+1].x;
temp.y = (holes[count+2].y - holes[count+1].y) / 2 + holes[count+1].y;
temp.z = (holes[count+2].z - holes[count+1].z) / 2 + holes[count+1].z;
holes.push_back(temp);
//right hole -> uprow middle hole
temp.x = (holes[count+4].x - holes[count+2].x) / 2 + holes[count+2].x;
temp.y = (holes[count+4].y - holes[count+2].y) / 2 + holes[count+2].y;
temp.z = (holes[count+4].z - holes[count+2].z) / 2 + holes[count+2].z;
holes.push_back(temp);
//right hole -> uprow right hole
temp.x = (holes[count+5].x - holes[count+2].x) / 2 + holes[count+2].x;
temp.y = (holes[count+5].y - holes[count+2].y) / 2 + holes[count+2].y;
temp.z = (holes[count+5].z - holes[count+2].z) / 2 + holes[count+2].z;
holes.push_back(temp);
}
//Fill in last row of fake holes
//left -> middle
temp.x = (holes[count+1].x - holes[count].x) / 2 + holes[count].x;
temp.y = (holes[count+1].y - holes[count].y) / 2 + holes[count].y;
temp.z = (holes[count+1].z - holes[count].z) / 2 + holes[count].z;
holes.push_back(temp);
//middle -> right
temp.x = (holes[count+2].x - holes[count+1].x) / 2 + holes[count+1].x;
temp.y = (holes[count+2].y - holes[count+1].y) / 2 + holes[count+1].y;
temp.z = (holes[count+2].z - holes[count+1].z) / 2 + holes[count+1].z;
holes.push_back(temp);
//Pick Random X, Y & Z 3Dpoints
degrees = rand(0,359);
tempPoint = Point3D::create(float_rand(PoleGapBottom,PoleLength-PoleGapTop),cos(degrees)*Radius,sin(degrees)*Radius);
temp.x = float_rand(PoleGapBottom,PoleLength-PoleGapTop);
temp.y = cos(degrees) * Radius;
temp.z = sin(degrees) * Radius;
temp.real= true;
//Compare to all holes for distance of radius*3 LG, Med, Small
temp.size = LDrillBit;
for(int holeCount = 0; holeCount < LHoles; holeCount++)
{
degrees = rand(0, 359);
tempPoint = Point3D::create(float_rand(PoleGapBottom, PoleLength - PoleGapTop), cos(degrees)*Radius, sin(degrees)*Radius);
temp.x = float_rand(PoleGapBottom, PoleLength - PoleGapTop);
temp.y = cos(degrees) * Radius;
temp.z = sin(degrees) * Radius;
temp.real = true;
for(int xArray = 0; xArray < holes.length(); x++)
{
if(tempPoint_var->distanceTo(holes[xArray]) < 1.5*LDrillBit)
break();
else
if(xArray == holes.length()-1)
holes.push_back(temp);
}
}
temp.size = MDrillBit;
for(int holeCount = 0; holeCount < MHoles; holeCount++)
{
degrees = rand(0, 359);
tempPoint = Point3D::create(float_rand(PoleGapBottom, PoleLength - PoleGapTop), cos(degrees)*Radius, sin(degrees)*Radius);
temp.x = float_rand(PoleGapBottom, PoleLength - PoleGapTop);
temp.y = cos(degrees) * Radius;
temp.z = sin(degrees) * Radius;
temp.real = true;
for(int xArray = 0; xArray < holes.length(); x++)
{
if(tempPoint_var->distanceTo(holes[xArray]) < 1.5*MDrillBit)
break();
else
if(xArray == holes.length()-1)
holes.push_back(temp);
}
}
temp.size = SDrillBit;
for(int holeCount = 0; holeCount < SHoles; holeCount++)
{
degrees = rand(0, 359);
tempPoint = Point3D::create(float_rand(PoleGapBottom, PoleLength - PoleGapTop), cos(degrees)*Radius, sin(degrees)*Radius);
temp.x = float_rand(PoleGapBottom, PoleLength - PoleGapTop);
temp.y = cos(degrees) * Radius;
temp.z = sin(degrees) * Radius;
temp.real = true;
for(int xArray = 0; xArray < holes.length(); x++)
{
if(tempPoint_var->distanceTo(holes[xArray]) < 1.5*SDrillBit)
break();
else
if(xArray == holes.length()-1)
holes.push_back(temp);
}
}
//Drill All The holes (from PointA, to PointB, with Diameter)
<Point3D> PointA, PointB;
for(int pos = 0; pos<holes.length()-1; pos++)
if (holes[pos].real == true)
{
PointA = Point3D::create(holes[pos].x, holes[pos].y, holes[pos].z);
PointB = Point3D::create(holes[pos].x, 0, 0);
<SketchPoints> sketchPoints_var;
sketchPoints_var->add(PointA);
sketchPoints_var->add(PointB);
<HoleFeatures> holeFeature_var;
holeFeature_var->setPositionBySketchPoints(sketchPoints)
holeFeature_var->holeDiameter(drill);
holeFeatures_var->add(holeFeature);
}
}