Announcements

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Create random & candy cane pattern holes on pole

kevin
Enthusiast

Create random & candy cane pattern holes on pole

kevin
Enthusiast
Enthusiast

I'm trying to figure out how to create a candy cane stripe of 3 hole width up a pole. Creating another 3 hole set every 30 degrees, spiraling up the whole way like a red stripe. In the left over space I'd like to generate random holes of 3 different sizes that don't overlap and have a minimum distance from any other hole for structural integrity. Picture the attached pole that has both structured candy cane pattern and random stars in the sky pattern as well but make it much longer. I'm looking at over 3000 holes in the drawing so I'd like to be able to change the length and have the holes regenerate.

 

 

IMG_5831.JPG

 

large.jpg

0 Likes
Reply
1,477 Views
5 Replies
Replies (5)

etfrench
Mentor
Mentor

Pattern on path can create the regular pattern. Use the Coil command to create the path.  You may also be able to use the same technique to create a psuedo-random pattern by using the Suppress option on some of the faces/holes/bodies.  3000 objects in a pattern may make Fusion 360 sluggish.  If so, try grounding the objects as soon as they are created.

ETFrench

EESignature

0 Likes

davebYYPCU
Consultant
Consultant

Ed - Pattern on a coil Path does not keep the bodies normal to the surface.

 

This problem was discussed as a Spiral Pattern, and there is a Script / Addin mentioned, should be what you are after.

 

Might help....

 

 

0 Likes

kevin
Enthusiast
Enthusiast

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);
	}
}

 

0 Likes

kevin
Enthusiast
Enthusiast

I finished it.
It all runs and sends the correct info to the console.
For the life of me I can't figure out how to make a hole with the info I have (fromPoint, toPoint, diameter).

I thought making a hole would be easy.

If any one knows how to add that in I'd be grateful.

 

2 Points w Diameter.jpg

 

 

//Copyright Kevin Patel

#define _USE_MATH_DEFINES

#include <Core/CoreAll.h>
#include <Fusion/FusionAll.h>
#include <CAM/CAMAll.h>
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <stack>
#include <random>
#include <vector>

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

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

double _poleLength = 8 * 12 * 2.54; //cm
double _gapTop = 6 * 2.54; //cm
double _gapBottom = 6 * 2.54; //cm
double _poleOD = 2 * 2.54 / 2; //cm
double _poleID = 1.5 * 2.54 / 2; //cm
double _bitL = 2.54 * 5 / 8; //cm
double _bitM = 2.54 * 1 / 2; //cm
double _bitS = 2.54 * 3 / 8; //cm
int _numHolesL = 1000;
int _numHolesM = 1000;
int _numHolesS = 1000;
double _slices = 12;
double _sliceArcLength = M_PI * _poleOD / _slices;
double _radius = _poleOD / 2 + .1; //Makes a working radius so drilling starts above pole

struct hole {
	bool real = true;
	double x, y, z, diameter = 0;
};
vector <hole> holes;

struct light {
	double x, y, z, dia, real;
};
vector <light> lights;

extern "C" XI_EXPORT bool run(const char* context)
{
	srand((unsigned)time(NULL));
	ofstream myfile;
	myfile.open("debug.txt");
	myfile << std::to_string(rand()) + " Random Initialized\n";
	myfile << M_PI << " Pi works\n";

	app = Application::get();
	if (!app)
		return false;
	myfile << "OK - Get Application\n";

	ui = app->userInterface();
	if (!ui)
		return false;
	myfile << "OK - Get User Interface\n";

	Ptr<Documents> documents = app->documents();
	if (!documents)
		return false;
	myfile << "OK - Get Documents\n";

	Ptr<Document> doc = documents->add(DocumentTypes::FusionDesignDocumentType);
	if (!doc)
		return false;
	myfile << "OK - Make Document Type Fusion Design\n";

	Ptr<Product> product = app->activeProduct();
	if (!product)
		return false;
	myfile << "OK - Select Active Product\n";

	Ptr<Design> design = product;
	if (!design)
		return false;
	myfile << "OK - Set Design to Active Product\n";

	// Get the root component of the active design
	Ptr<Component> rootComp = design->rootComponent();
	if (!rootComp)
		return false;
	myfile << "OK - Get the root component of the active design\n";

	// Get extrude features
	Ptr<Features> feats = rootComp->features();
	if (!feats)
		return false;
	myfile << "OK - Get extrude features\n";

	Ptr<ExtrudeFeatures> extrudes = feats->extrudeFeatures();
	if (!extrudes)
		return false;
	myfile << "OK - Set Extrudes with all extrude features\n";

	// Create sketch
	Ptr<Sketches> sketches = rootComp->sketches();
	if (!sketches)
		return false;
	myfile << "OK - Create a group of sketches\n";

	Ptr<ConstructionPlane> yz = rootComp->yZConstructionPlane();
	if (!yz)
		return false;
	myfile << "OK - Set Construction Plane to YZ\n";

	Ptr<Sketch> sketch = sketches->add(yz);
	if (!sketch)
		return false;
	myfile << "OK - Add YZ plane to sketch\n";

	Ptr<SketchCurves> sketchCurves = sketch->sketchCurves();
	if (!sketchCurves)
		return false;
	myfile << "OK - Create Sketch Curves\n";

	Ptr<SketchCircles> sketchCircles = sketchCurves->sketchCircles();
	if (!sketchCircles)
		return false;
	myfile << "OK - Create Sketch Circles\n";

	Ptr<Point3D> centerPoint = Point3D::create(0, 0, 0);
	if (!centerPoint)
		return false;
	myfile << "OK - Create Center Point (0,0,0)\n";

	// Created Circles
	Ptr<SketchCircle> circle1 = sketchCircles->addByCenterRadius(centerPoint, _poleID);
	myfile << _poleID << " Inside Diameter Circle\n";
	Ptr<SketchCircle> circle2 = sketchCircles->addByCenterRadius(centerPoint, _poleOD);
	myfile << _poleOD << " Outside Diameter Circle\n";
	Ptr<Profiles> profiles = sketch->profiles();
	Ptr<Profile> outerProfile = profiles->item(1);
	myfile << "OK - Circles created\n";

	//Extrude Pole
	Ptr<ValueInput> distance = ValueInput::createByReal(_poleLength);
	if (!distance)
		return false;
	Ptr<ExtrudeFeature> extrude1 = extrudes->addSimple(outerProfile, distance, adsk::fusion::FeatureOperations::NewBodyFeatureOperation);
	if (!extrude1)
		return false;
	myfile << _poleLength << " - Extruded Pole\n";

	//Initialize Hole Variables
	hole temp;
	temp.real = true;
	double degrees = 0;
	Ptr<Point3D> tempPoint = Point3D::create(0, 0, 0);
	myfile << "OK - Hole Variables Initialized\n";

	//Vector Array Testing / Initializing
	light tempLight;
	tempLight.x = 3;
	tempLight.y = 4;
	tempLight.z = 5;
	tempLight.dia = _bitL;
	tempLight.real = true;
	myfile << "\nTest Struct\t" << tempLight.x << tempLight.y << tempLight.z << tempLight.dia << tempLight.real << "\n";
	lights.push_back(tempLight);
	myfile << "Array Size " << lights.size() << "\n";
	myfile << "Contents\t" << lights[0].x << lights[0].y << lights[0].z << lights[0].dia << lights[0].real;
	lights.pop_back();
	myfile << "\nPOP\tsize " << lights.size();

	//Test Variables
	myfile << "Test Initialized Variables\n";
	tempLight.x = _gapBottom + _bitL / 2;
	tempLight.y = cos(degrees) * _radius;
	tempLight.z = sin(degrees) * _radius;
	tempLight.dia = 1.5875;
	lights.push_back(tempLight);
	myfile << "\n[" << lights.size() - 1 << "]\t" << lights[lights.size() - 1].x << "\t" << lights[lights.size() - 1].y << "\t" << lights[lights.size() - 1].z << "\t" << lights[lights.size() - 1].dia << "\t" << lights[lights.size() - 1].real;
	lights.pop_back();
	myfile << "\n Brill Bits\t" << _bitL << "\t" << _bitM << "\t" << _bitS;
	myfile << "\n Pole Length & Gaps\t" << _poleLength << "\t" << _gapBottom << "\t" << _gapTop;
	myfile << "\nPoleOD\t" << _poleOD << "\tPoleID\t" << _poleID;
	myfile << "\nNum Holes\t" << _numHolesL << "\t" << _numHolesM << "\t" << _numHolesS;
	myfile << "\nSlices " << _slices << "\tArcLength " << _sliceArcLength << "\tWorkingRadius " << _radius << "\n\n";

	//Create Candy Cane
	myfile << "Candy Cane Coordinates\n";
	for (tempLight.x = _bitL / 2 + _gapBottom; tempLight.x <= _poleLength - _gapTop - _bitL; tempLight.x += _bitL * 2, degrees += 360 / 12 / 2) {
		myfile << "\nX\t" << tempLight.x;
		tempLight.y = cos(degrees) * _radius;
		tempLight.z = sin(degrees) * _radius;
		lights.push_back(tempLight);
		myfile << "\n[" << lights.size() - 1 << "]\t" << lights[lights.size() - 1].x << "\t" << lights[lights.size() - 1].y << "\t" << lights[lights.size() - 1].z << "\t" << lights[lights.size() - 1].dia << "\t" << lights[lights.size() - 1].real;
		tempLight.y = cos(degrees + 15) * _radius;
		tempLight.z = sin(degrees + 15) * _radius;
		lights.push_back(tempLight);
		myfile << "\n[" << lights.size() - 1 << "]\t" << lights[lights.size() - 1].x << "\t" << lights[lights.size() - 1].y << "\t" << lights[lights.size() - 1].z << "\t" << lights[lights.size() - 1].dia << "\t" << lights[lights.size() - 1].real;
		tempLight.y = cos(degrees + 30) * _radius;
		tempLight.z = sin(degrees + 30) * _radius;
		lights.push_back(tempLight);
		myfile << "\n[" << lights.size() - 1 << "]\t" << lights[lights.size() - 1].x << "\t" << lights[lights.size() - 1].y << "\t" << lights[lights.size() - 1].z << "\t" << lights[lights.size() - 1].dia << "\t" << lights[lights.size() - 1].real;
	}

	//Create Phantom Candy Cane Holes
	myfile << "\n\nCreate Phantom Candy Cane Filer Holes\n";
	tempLight.real = false;
	double stop = (double)lights.size() - 3;
	for (int count = 0; count < stop; count += 3)
	{
		//(0)=>(1) left hole -> middle hole same row
		tempLight.x = (lights[count + 1].x - lights[count].x) / 2 + lights[count].x;
		tempLight.y = (lights[count + 1].y - lights[count].y) / 2 + lights[count].y;
		tempLight.z = (lights[count + 1].z - lights[count].z) / 2 + lights[count].z;
		lights.push_back(tempLight);
		myfile << "\n[" << lights.size() - 1 << "]\t" << lights[lights.size() - 1].x << "\t" << lights[lights.size() - 1].y << "\t" << lights[lights.size() - 1].z << "\t" << lights[lights.size() - 1].dia << "\t" << lights[lights.size() - 1].real;

		//(0)=>(3) left hole -> uprow left
		tempLight.x = (lights[count + 3].x - lights[count].x) / 2 + lights[count].x;
		tempLight.y = (lights[count + 3].y - lights[count].y) / 2 + lights[count].y;
		tempLight.z = (lights[count + 3].z - lights[count].z) / 2 + lights[count].z;
		lights.push_back(tempLight);
		myfile << "\n[" << lights.size() - 1 << "]\t" << lights[lights.size() - 1].x << "\t" << lights[lights.size() - 1].y << "\t" << lights[lights.size() - 1].z << "\t" << lights[lights.size() - 1].dia << "\t" << lights[lights.size() - 1].real;

		//(1)=>(3) middle hole -> uprow left
		tempLight.x = (lights[count + 3].x - lights[count + 1].x) / 2 + lights[count + 1].x;
		tempLight.y = (lights[count + 3].y - lights[count + 1].y) / 2 + lights[count + 1].y;
		tempLight.z = (lights[count + 3].z - lights[count + 1].z) / 2 + lights[count + 1].z;
		lights.push_back(tempLight);
		myfile << "\n[" << lights.size() - 1 << "]\t" << lights[lights.size() - 1].x << "\t" << lights[lights.size() - 1].y << "\t" << lights[lights.size() - 1].z << "\t" << lights[lights.size() - 1].dia << "\t" << lights[lights.size() - 1].real;

		//(1)=>(4) middle hole -> uprow middle
		tempLight.x = (lights[count + 4].x - lights[count + 1].x) / 2 + lights[count + 1].x;
		tempLight.y = (lights[count + 4].y - lights[count + 1].y) / 2 + lights[count + 1].y;
		tempLight.z = (lights[count + 4].z - lights[count + 1].z) / 2 + lights[count + 1].z;
		lights.push_back(tempLight);
		myfile << "\n[" << lights.size() - 1 << "]\t" << lights[lights.size() - 1].x << "\t" << lights[lights.size() - 1].y << "\t" << lights[lights.size() - 1].z << "\t" << lights[lights.size() - 1].dia << "\t" << lights[lights.size() - 1].real;

		//(1)=>(2) middle hole -> right same row
		tempLight.x = (lights[count + 2].x - lights[count + 1].x) / 2 + lights[count + 1].x;
		tempLight.y = (lights[count + 2].y - lights[count + 1].y) / 2 + lights[count + 1].y;
		tempLight.z = (lights[count + 2].z - lights[count + 1].z) / 2 + lights[count + 1].z;
		lights.push_back(tempLight);
		myfile << "\n[" << lights.size() - 1 << "]\t" << lights[lights.size() - 1].x << "\t" << lights[lights.size() - 1].y << "\t" << lights[lights.size() - 1].z << "\t" << lights[lights.size() - 1].dia << "\t" << lights[lights.size() - 1].real;

		//(2)=>(4) right hole -> uprow middle hole
		tempLight.x = (lights[count + 4].x - lights[count + 2].x) / 2 + lights[count + 2].x;
		tempLight.y = (lights[count + 4].y - lights[count + 2].y) / 2 + lights[count + 2].y;
		tempLight.z = (lights[count + 4].z - lights[count + 2].z) / 2 + lights[count + 2].z;
		lights.push_back(tempLight);
		myfile << "\n[" << lights.size() - 1 << "]\t" << lights[lights.size() - 1].x << "\t" << lights[lights.size() - 1].y << "\t" << lights[lights.size() - 1].z << "\t" << lights[lights.size() - 1].dia << "\t" << lights[lights.size() - 1].real;

		//(2)=>(5) right hole -> uprow right hole
		tempLight.x = (lights[count + 5].x - lights[count + 2].x) / 2 + lights[count + 2].x;
		tempLight.y = (lights[count + 5].y - lights[count + 2].y) / 2 + lights[count + 2].y;
		tempLight.z = (lights[count + 5].z - lights[count + 2].z) / 2 + lights[count + 2].z;
		lights.push_back(tempLight);
		myfile << "\n[" << lights.size() - 1 << "]\t" << lights[lights.size() - 1].x << "\t" << lights[lights.size() - 1].y << "\t" << lights[lights.size() - 1].z << "\t" << lights[lights.size() - 1].dia << "\t" << lights[lights.size() - 1].real;

		myfile << "\n Count " << count << "\t Lights Size " << lights.size() << "\n";

		if (count < stop && count > stop -6) {
			//Fill in last row of fake holes
			myfile << "\nFill last row of fake holes";
			//(3)=>(4) up left -> up middle
			tempLight.x = (lights[count + 4].x - lights[count + 3].x) / 2 + lights[count + 3].x;
			tempLight.y = (lights[count + 4].y - lights[count + 3].y) / 2 + lights[count + 3].y;
			tempLight.z = (lights[count + 4].z - lights[count + 3].z) / 2 + lights[count + 3].z;
			lights.push_back(tempLight);
			myfile << "\n[" << lights.size() - 1 << "]\t" << lights[lights.size() - 1].x << "\t" << lights[lights.size() - 1].y << "\t" << lights[lights.size() - 1].z << "\t" << lights[lights.size() - 1].dia << "\t" << lights[lights.size() - 1].real;

			//(4)=>(5) up middle -> up right
			tempLight.x = (lights[count + 5].x - lights[count + 4].x) / 2 + lights[count + 4].x;
			tempLight.y = (lights[count + 5].y - lights[count + 4].y) / 2 + lights[count + 4].y;
			tempLight.z = (lights[count + 5].z - lights[count + 4].z) / 2 + lights[count + 4].z;
			lights.push_back(tempLight);
			myfile << "\n[" << lights.size() - 1 << "]\t" << lights[lights.size() - 1].x << "\t" << lights[lights.size() - 1].y << "\t" << lights[lights.size() - 1].z << "\t" << lights[lights.size() - 1].dia << "\t" << lights[lights.size() - 1].real;
			myfile << "\n Count " << count << "\t Lights Size " << lights.size() << "\n"; myfile << "\n Count " << count << "\t Lights Size " << lights.size() << "\n";
		}
	}

	//Pick The Random large Holes
	for (int temp = 0; temp < _numHolesL; temp++) {
		//Pick Random X, Y & Z 3Dpoints
		//myfile << "\nCheck out Random Temp Light Hole";
		tempLight.real = true;
		tempLight.dia = _bitL;
		degrees = rand() % 360;
		tempLight.x = (double)(rand() % (int)(_poleLength - _gapBottom - _gapTop)) + _gapBottom;
		tempLight.y = cos(degrees) * _radius;
		tempLight.z = sin(degrees) * _radius;
		myfile << "\n[temp]\t" << tempLight.x << "\t" << tempLight.y << "\t" << tempLight.z << "\t" << tempLight.dia << "\t" << tempLight.real;
		//Check random point distance to all other current points
		for (int x = 0; x < lights.size(); x++) {
			if (sqrt(pow(tempLight.x - lights[x].x, 2) + pow(tempLight.y - lights[x].y, 2) + pow(tempLight.z - lights[x].z, 2)) > _bitL*2.5) {
				lights.push_back(tempLight);
				myfile << "\n["<<lights.size()<<"][" << x << "] Degrees " << degrees << "\t" << tempLight.x << "\t" << tempLight.y << "\t" << tempLight.z << "\t" << tempLight.dia << "\t" << tempLight.real;
				break;
			}
		}
	}

	//Pick The Random Medium Holes
	for (int temp = 0; temp < _numHolesM; temp++) {
		//Pick Random X, Y & Z 3Dpoints
		//myfile << "\nCheck out Random Temp Light Hole";
		tempLight.real = true;
		tempLight.dia = _bitM;
		degrees = rand() % 360;
		tempLight.x = (double)(rand() % (int)(_poleLength - _gapBottom - _gapTop)) + _gapBottom;
		tempLight.y = cos(degrees) * _radius;
		tempLight.z = sin(degrees) * _radius;
		myfile << "\n[temp]\t" << tempLight.x << "\t" << tempLight.y << "\t" << tempLight.z << "\t" << tempLight.dia << "\t" << tempLight.real;
		//Check random point distance to all other current points
		for (int x = 0; x < lights.size(); x++) {
			if (sqrt(pow(tempLight.x - lights[x].x, 2) + pow(tempLight.y - lights[x].y, 2) + pow(tempLight.z - lights[x].z, 2)) > _bitM*2.5) {
				lights.push_back(tempLight);
				myfile << "\n[" << lights.size() << "][" << x << "] Degrees " << degrees << "\t" << tempLight.x << "\t" << tempLight.y << "\t" << tempLight.z << "\t" << tempLight.dia << "\t" << tempLight.real;
				break;
			}
		}
	}

	//Pick The Random Small Holes
	for (int temp = 0; temp < _numHolesS; temp++) {
		//Pick Random X, Y & Z 3Dpoints
		//myfile << "\nCheck out Random Temp Light Hole";
		tempLight.real = true;
		tempLight.dia = _bitS;
		degrees = rand() % 360;
		tempLight.x = (double)(rand() % (int)(_poleLength - _gapBottom - _gapTop)) + _gapBottom;
		tempLight.y = cos(degrees) * _radius;
		tempLight.z = sin(degrees) * _radius;
		myfile << "\n[temp]\t" << tempLight.x << "\t" << tempLight.y << "\t" << tempLight.z << "\t" << tempLight.dia << "\t" << tempLight.real;
		//Check random point distance to all other current points
		for (int x = 0; x < lights.size(); x++) {
			if (sqrt(pow(tempLight.x - lights[x].x, 2) + pow(tempLight.y - lights[x].y, 2) + pow(tempLight.z - lights[x].z, 2)) > _bitS*2.5) {
				lights.push_back(tempLight);
				myfile << "\n[" << lights.size() << "][" << x << "] Degrees " << degrees << "\t" << tempLight.x << "\t" << tempLight.y << "\t" << tempLight.z << "\t" << tempLight.dia << "\t" << tempLight.real;
				break;
			}
		}
	}

	/*Make Holes popping of lights array*/

	//Ending
	ui->messageBox("Hey Kevin " + std::to_string(rand()));
	return true;
	myfile.close();
}

#ifdef XI_WIN

#include <windows.h>

BOOL APIENTRY DllMain(HMODULE hmodule, DWORD reason, LPVOID reserved)
{
	switch (reason)
	{
	case DLL_PROCESS_ATTACH:
	case DLL_THREAD_ATTACH:
	case DLL_THREAD_DETACH:
	case DLL_PROCESS_DETACH:
		break;
	}
	return TRUE;
}

#endif // XI_WIN


0 Likes

kevin
Enthusiast
Enthusiast

Right now Im stuck with 5 basic blocks

Point, Vector, Line, Circle, cylinder

 

That I have to use to create 15 different sketch types

 

Then use all 20 of these to run and extrude or hole function

 

 

I have no idea which one is going to work.

 

API.jpg

0 Likes