Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ...Create Imprints on Modeler bodies, not on DesignBodies. The latter makes the script slow. #628

Open
agvarghe opened this issue Jul 31, 2023 · 4 comments
Labels
enhancement New features or code improvements

Comments

@agvarghe
Copy link

📝 Description of the feature

Creating imprints is the slowest operation. We were under the impression that we were using the low-level APIs but that doesn't seem to be the case. We wouldn't create design body untill we are ready to create the Design bodies.

💡 Steps for implementing the feature

No response

🔗 Useful links and references

No response

@agvarghe agvarghe added the enhancement New features or code improvements label Jul 31, 2023
@jonahrb
Copy link
Contributor

jonahrb commented Aug 1, 2023

@agvarghe , Ken @kmental did some testing with imprinting before and after design bodies are created:

I didn't see much difference between imprinting in the two cases. I tried 400 rectangles imprinted onto a block, and it took about the same time in both cases.

Imprint time (copy): 3329
Imprint count (copy): 1600

Imprint time (desBody): 3500
Imprint count (desBody): 1600

Sample C# code:

void TestImprintCurvesPerformance() {
	var desCurves = Window.ActiveWindow.ActiveContext.Selection.OfType<DesignCurve>();
	if (!desCurves.Any())
		return;

	var desBody = Window.ActiveWindow.Document.MainPart.Bodies.First();

	var curves = desCurves.Select(d => d.Shape).ToList();
	var body = desBody.Shape;
	var bodyCopy = desBody.Shape.Copy();

	// Just a modeler body
	var start = Environment.TickCount;
	var imprintedCurves2 = bodyCopy.ImprintCurves(curves, null);
	Trace.WriteLine($"Imprint time (copy): {Environment.TickCount - start}");
	Trace.WriteLine($"Imprint count (copy): {imprintedCurves2.Keys.Count}");
	bodyCopy.Dispose();

	// With a DesignBody
	start = Environment.TickCount;
	var imprintedCurves = body.ImprintCurves(curves, null);
	Trace.WriteLine($"Imprint time (desBody): {Environment.TickCount - start}");
	Trace.WriteLine($"Imprint count (desBody): {imprintedCurves.Keys.Count}");
}

Sample model:
MicrosoftTeams-image (1)

Do you get similar results with your model?

@RobPasMue
Copy link
Member

We might need to provide the Python code for this as well - I'm guessing @agvarghe is using PyGeometry rather than the raw API.

@kmental
Copy link

kmental commented Aug 2, 2023

@RobPasMue Good point, there may be a difference in the PyGeometry layer.

@jonahrb
Copy link
Contributor

jonahrb commented Aug 3, 2023

We might need to provide the Python code for this as well - I'm guessing @agvarghe is using PyGeometry rather than the raw API.

PyGeometry never has the ability to access Modeler bodies, so nothing you write in pygeom could test these 2 cases. I believe he raised the issue concerning our server implementation for imprinting. If the issue was raised requesting the ability to create modeler bodies - we have no plans of supporting that workflow.

@agvarghe It may instead be most helpful if you share your PyGeometry code snippet and I could test the 2 different approaches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New features or code improvements
Projects
None yet
Development

No branches or pull requests

4 participants