Macro / PLC, Changing Spline to Arc

Hello
I'd like to create a Macro to automate a process.
After importing the AI files, I have a generated sketch consisting of Spline or straight lines
I'd like a Macro that creates a new sketch and turns all the splines into arcs.
So that afterwards I can use the mechanically welded trim which only works on arcs and straight segments
I can't redo the arcs on the same spline sketch because I can't select segments during the mechanically welded dressing, I have to hide the spline sketch.


Thank you for guiding me to be able to create a Macro.

1 Like

Check out this link (not tested):
https://www.cadforum.net/viewtopic.php?t=324
Edit or other method without macro:

1 Like

Hello @Farouk

Why would you want a macro?
You can create a sketch on top of the spline one in a single operation.
So in the new sketch you have a line that has the shape of the spline but can no longer be changed.

You can copy this entire shaped curve and insert it into anything without it ever being able to move.
You can even create a block of this sketch, so you can use the full figure many times for other projects.

Duration of the operation 3 minutes while pouring the coffee

Kind regards

Here's a block to insert anywhere
Sketch18.SLDBLK (23.0 KB)

1 Like

Zozo_mp

Thank you for your answer, I downloaded the block file but unfortunately, the sketch remains a spline, I can't do the wrapping with the mechanically welded function.

Sbadenis
Thank you for your answer
I downloaded the macro but I can't run it.

1

I'm going to download DS DraftSight and I'm going to try it out

@Farouk

Sorry to contradict you but the block is not a spline.

In addition, if you don't edit the spline of the block, nothing moves

Maybe something escapes me in your explanation or in what you want to do.
What do you mean [quote="Farouk, post:4, topic:108806"]
I can't do the dressing with the mechanically welded function.
[/quote]

Send you the complete file, I'll give you an example of what I offer you

Kind regards

1 Like

@Zozo_mp
Do I have to change some parameters so that the block is not a spline?
I attach the Solidworks 2023 file


P1.SLDPRT (447.2 KB)

@Farouk

Ouch! I only have the 2022 version.

Cdlt

Hello @Farouk ,

There are few members of this forum today who have a 2023 version...
Can you produce the document in a previous version of SolidWorks?
Alternatively, you can export it in IGES format, by checking the options for sketch entities and curves, so as to allow the retrieval of " generic" splines.

@m.blt @Zozo_mp

Here's a SolidWorks 2022 release
Item1.SLDPRT (412.9 KB)
Thank you
Can you help me run the Macro proposed by @sbadenis
splines2arcs.swp (266.0 KB)

The macro doesn't work at home either, nor is the file probably corrupted (impossible to edit it)
We will have to find her elsewhere or another who does the same thing.

1 Like

Your initial sketch is written in a square of 4900 mm on each side. It consists of 938 entities, mainly splines, and a few segments of lines (45).
I used the C++ code proposed by Biarc Interpolation - RyanJuckett.com to process this sketch of the " Lions ". Each spline is approximated by arcs of tangent circles, at the rate of N arcs per curve segment, N being even and between 2 and 16.
Since each spline has only one segment, the number of features is approximately N x 938.
The attached document (SW 2021) includes the basic sketch and 3 3D sketches from the processing, with respectively N = 2, N = 8 and N = 16 arcs per segment.

Finding:

  • For N = 2 arcs per curve segment, the general pace is 90% correct, but some portions of curves are very badly approximated. This is the case when the curvature of the spline is greatly reduced as it approaches an end (cf. the almost rectilinear rays of the sun in the central part of the sketch).
  • For N = 8, the shape is closer to the original, with deviations of the order of 5 mm at most. But the number of " arc" entities increases to more than 7500. Is this large number compatible with the use you want to make of this model?
  • For N = 16, the approximation is very good, but at the cost of 15000 entities (more than 10 min of processing). Is it manageable?

It's up to you to judge the interest of this approximation from the sketches of the attached document.
A question: what do you call " mechanically welded cladding", is it realistic given the number of entities in the sketch?
If the answer is positive, I will finalize the code...

Kind regards.
Lions.SLDPRT (1.8 MB)

3 Likes

Hello
@m.blt Thank you for your answer, it's great, you're saving my life.

I tried to illustrate the steps of my work on this photo to better understand example of 3D sets (same for a 2D set as sent before)
Mechanically welded cladding is the selection of the arcs and lines of the sketches,
The choice of the profile that will be bent to the desired shape to form the decoration is chosen according to several criteria
Sometimes I make sketches for each profile that is going to be used and other times I make sketches that can have several different profiles.

I have to select segment by segment (arc or line) when I am on the " mechanically welded element " function The number N = 16 seems too large to me (for the selection and for the processing of SolidWorks) is it possible to have the two macros N = 2 and N = 8?

1 Like

Hello @Farouk ,

The macro (actually an executable module) is attached, accompanied by an explanation page and a light part document to perform my tests, taking up one of the lions of your initial sketch.

Kind regards.

Attached document deleted...

1 Like

Hello again @m.blt

Thank you for your efforts and your very precious help.
I tried to launch the application on SolidWorks 2023 and 2022. being the file I wanted to process open and close again, running in administrator mode, the Lion attachment file and another file
I get a message saying unknown file
image

Thank you for your feedback.

This message is displayed if the document to be opened is not defined.
You have to fill it in the input box at the top of the sheet...

I uploaded the steps I performed, I did the test by selecting the version of SolidWorks first and then the file after connection.

Difference Between Operating in the Development Environment and Operating on the End User's PC...
Second attempt with the zip attached.
AppliBiArc_1.zip (1.6 MB)

2 Likes

Mission Accomplished!!
Thank you so much
:grinning::innocent: :heart_eyes: :smiling_face_with_three_hearts:

1 Like

Hello @m.blt
I hope you're doing well.
I encountered a problem using the conversion application, I try to convert sketches on planes other than the face plane to arc (in green) I get sketches on the face plane (in red).
Is it possible to solve the problem?


.
I converted the 2D sketches into a 3D sketch and it worked.
Thank you very much