Dimensions disappearing on insert

Dimensions disappearing on insert

moshebar
Contributor Contributor
1,494 Views
4 Replies
Message 1 of 5

Dimensions disappearing on insert

moshebar
Contributor
Contributor

when programmatically making dimensions between two points all the dimensions become invisible within an active sketch, as it they were set to hide..

 

has anyone else encountered this?

0 Likes
Accepted solutions (1)
1,495 Views
4 Replies
Replies (4)
Message 2 of 5

ekinsb
Alumni
Alumni

It's not clear what the workflow is in your case.  Can you explain in more detail the steps to reproduce the problem or provide some sample code that demonstrates it?  Thanks.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes
Message 3 of 5

moshebar
Contributor
Contributor

Hi,

 

the original code is too spaghetti - convoluted, here is a simplified recreation:

extern "C" XI_EXPORT bool run(const char* context)
{
	app = Application::get();
	if (!app)
		return false;

	ui = app->userInterface();
	if (!ui)
		return false;

	//ref active sketch
	Ptr<Base> active_base = app->activeEditObject();
	if (!active_base)
		return false;
	//cast to sketch
	Ptr<Sketch> sketch = active_base;
	if (!sketch)
	{
		ui->messageBox("can only edit an active sketch");
		return false;
	}
	

	//ref points
	Ptr<SketchPoints> points = sketch->sketchPoints();
	if (!points)
		return false;

	//ref 3d sketch origin
	Ptr<Point3D> D3origin = sketch->origin();
	if (!D3origin)
		return false;

	//make a sketch point at origin
	Ptr<SketchPoint> sketch_origin = points->add(D3origin);
	if (!sketch_origin)
		return false;
	sketch_origin->isFixed(true);




	//create dimensions object
	Ptr<SketchDimensions> dimensions = sketch->sketchDimensions();
	if (!dimensions)
		return false;

	//traverse points
	for (size_t j = 0; j < points->count(); j++)
	{

		//ref the sketch point
		Ptr<SketchPoint> point = points->item(j);
		if (!point)
			continue;


		//add dimensions to non constrained points
		if (!(point->isFullyConstrained()))
		{
			//Ptr <Point3D> point_3D = point->worldGeometry();
			//if (!point_3D)
			//	continue;
			Ptr<Point3D> textPos = point->geometry();
			if (!textPos)
				continue;


			Ptr<SketchLinearDimension> sketchDimension1 = dimensions->addDistanceDimension(sketch_origin, point, HorizontalDimensionOrientation, textPos, true);



			//if still un constrained add second dimension
			if (!(point->isFullyConstrained()))
			{

				Ptr<SketchLinearDimension> sketchDimension2 = dimensions->addDistanceDimension(sketch_origin, point, VerticalDimensionOrientation, textPos, true);

			}

		}

	}



	return true;
}

 

if you run this scrip on an active sketch with unconstrained points, the result does not display the dimensions. you need to reload the sketch to see the created dimensions.

 

Thanks

0 Likes
Message 4 of 5

ekinsb
Alumni
Alumni
Accepted solution

Thank you for the sample code.  I'm able to reproduce the problem and have logged a bug.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes
Message 5 of 5

Anonymous
Not applicable

Hi,

     I think I'm encountering the same thing and when you programatically add dimensions they are hidden by default. See this thread to see how to turn them on manually.....I'm currently trying to find out how to do this programatically.

 

Paul.

0 Likes