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: 

Dimensions disappearing on insert

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
moshebar
604 Views, 4 Replies

Dimensions disappearing on insert

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?

4 REPLIES 4
Message 2 of 5
ekinsb
in reply to: moshebar

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
Message 3 of 5
moshebar
in reply to: ekinsb

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

Message 4 of 5
ekinsb
in reply to: moshebar

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
Message 5 of 5
thekestrel
in reply to: moshebar

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.

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report