[Tool] Convert Polyline to Spline (2D)

[Tool] Convert Polyline to Spline (2D)

weiser
Advocate Advocate
4,517 Views
21 Replies
Message 1 of 22

[Tool] Convert Polyline to Spline (2D)

weiser
Advocate
Advocate

Hi there,

after asking quite a few questions in the forum I think it is time to give something back 🙂

So here is a little tool for converting "connected" polylines, given wihtin a 2D-sketch to a spline fitting to the points.

It's a user form written in VBA.

Though I'm going to it to redesign CAD-models from STL-Scans by creating cross-sections, I arranged a few options within the form for modifying the given points.

Right now the GUI is in german ...

Hope someone find it useful.

Regards

Image 001.pngImage 002.pngImage 003.png

Accepted solutions (2)
4,518 Views
21 Replies
Replies (21)
Message 2 of 22

johnsonshiue
Community Manager
Community Manager

Hi! This is a very interesting tool! I know it will be very useful for imported dwg files. Have you thought about submitted it to Inventor App store?

Many thanks!

 



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
Message 3 of 22

weiser
Advocate
Advocate

Hi @johnsonshiue ,

thanks for your answer. As I mentioned I'm just trying to get "smoother" cross-sections from STL-models ... So when coding I did not think about other usage at all....

I did not get into contact with the app-store nor know how to build an app.

Therefore I posted the zip-file so that everyone is able to import the code into their VBA-project.

Is there any tutorial / manual how to "convert" a VBA-user form into an Inventor-App?

Regards

0 Likes
Message 4 of 22

johnsonshiue
Community Manager
Community Manager

Hi! I am sorry I am not a developer. Nor am I an App creator. You could send an email to appsubmissions@autodesk.com and see how it goes.

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes
Message 5 of 22

GeorgK
Advisor
Advisor

I tried to convert it to VB.Net. There is an error in the.

 

Private Sub PreviewPoints()
        ' Generierung der Liste der aktuellen Punkte  ' Erstellen der Punkte und Hinzufügen zur Punkteliste
        Dim oSelectSet As SelectSet
        oSelectSet = m_inventorApplication.ActiveDocument.SelectSet
        oSelectSet.Clear()
        Dim oTransGeom As TransientGeometry

        Dim nPointPreview As Object
        'Dim nPoint As Object = Nothing

        oTransGeom = m_inventorApplication.TransientGeometry
        Dim oPreviewPoints As ObjectCollection
        oPreviewPoints = m_inventorApplication.TransientObjects.CreateObjectCollection
        Dim oPoints(nPoint) As Point2d
        For i = 1 To nPoint
            ' Generieren des aktuellen Punkts
            oPoints(i) = oTransGeom.CreatePoint2d(oPointCoordX(i), oPointCoordY(i)) '==>>> Error
            ' Aufnahme des Punkts in die Liste
            oPreviewPoints.Add(oPoints(i))
        Next i
        'oSelect.Select oPreviewPoints
        ' Hinzufügen der Punkte zur aktuellen Ebene
        Dim oSketch As PlanarSketch
        oSketch = m_inventorApplication.ActiveEditObject
        For i = 1 To nPoint
            ' Generieren des aktuellen Punkts als Mittelpunkt (mit Markierung)
            oSketch.SketchPoints.Add(oPoints(i), True)
        Next i

        ' Warten auf die Bestätigung
        MsgBox("Vorschau beenden")

        ' Löschen der aktuellen Punkte
        nPointPreview = oSketch.SketchPoints.Count
        For i = nPointPreview To nPointPreview - nPoint + 1 Step -1
            '  MsgBox "Typ: " & TypeName(obj)
            ' Selektieren des aktuellen Punkts
            oSelectSet.Select(oSketch.SketchPoints(i))
        Next
        oSelectSet.Delete()

    End Sub

Thank you

 

Georg

0 Likes
Message 6 of 22

GeorgK
Advisor
Advisor
0 Likes
Message 7 of 22

weiser
Advocate
Advocate

Maybe someone is interested in another tool too ....

It is for building lines on mesh-surfaces:

https://forums.autodesk.com/t5/inventor-forum/tool-curves-on-mesh/td-p/8830791

Message 8 of 22

S_May
Mentor
Mentor

Hi @weiser 

 

echt sehr coole Tips!!!!

0 Likes
Message 9 of 22

weiser
Advocate
Advocate
Accepted solution

Tanks for the positive feedback!

Though this is just an information and not an unanswered question, I'll close it by accepting this as an answer 😉

0 Likes
Message 10 of 22

Sergio.D.Suárez
Mentor
Mentor

Hi, I'm going to ask you a trivial question for you, where do you place the zip to load the tool? I would like to try it. Some time ago I think I came across a similar thing but the description seems more interesting your tool. Best regards!


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes
Message 11 of 22

weiser
Advocate
Advocate

Hi @Sergio.D.Suárez 

 

the question is not that trivial as you might think .... because I only did the export from the vba-editor ... never tried to import - 'cause the code is mine 😉

 

... but I think that's the way it should work:

Within the zip-file there are two files (*.frm, *-frx) I think that one should be the GUI (frm) and the other (frx) the code behind it .... So I think you have to import both files and hopefully that's it ...

 

To place an icon in Inventor's ribbon bar (group user defined commands) I've placed another Module within the VBA (see attachment / .bas within the zip-file) which is calling the userform.

Hope that helps you out.

 

Would be great to get feedback just to know if my theory is working 😉

 

Regards

 

Message 12 of 22

Sergio.D.Suárez
Mentor
Mentor

Import the form from the VBA editor, the one from the polyline is great, the others I have not tried yet! Congratulations, excellent work!


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

Message 13 of 22

weiser
Advocate
Advocate

Hi, just red the article from below.

Seems to be that you extracted both files into the same directory and Inventor imported both (though you just selected one).

If you have any ideas for improvements, let me know 😉

 

About importing userform in VBAAbout importing userform in VBA

taken from https://www.excelbanter.com/excel-programming/430142-re-export-custom-form-frx-frm-files.html

Message 14 of 22

GeorgK
Advisor
Advisor

Hello@weiser ,

 

realy great tools.

 

Thank you.

Georg

 

Message 15 of 22

Anonymous
Not applicable

Hello Sergio I am in great need of this tool. Solidworks has a stock function equivalent called "Spline Fitting" but I need the same function in inventor and this is it. But, I am not familiar with visual basic or have the program. You seemed to have got it to work, would you please type a short step by step how? I see your reply of importing it from VBA but then i think "How am i going to import a file from another program from another program?" I'm just not familiar with that process of implementing the code or function into inventor. I've never done a custom tool before.

thank you for any thing you can help with.
-Ian

Message 16 of 22

luca_delbarba
Explorer
Explorer
Accepted solution

Translated in English.
Everything seems OK.
Tested in Iventor 2022.

Message 17 of 22

luca_delbarba
Explorer
Explorer

Tested in 2023 and Everything seems OK.spline_2023.png

Message 18 of 22

weiser
Advocate
Advocate

Hi @Sergio.D.Suárez

Thanks for translating and "supporting" the tool. It is always good to see that my effort is going to be usefull for anyone 👍🏼

Message 19 of 22

twagnerEA4R7
Participant
Participant

How do you import the .frx file into Inventor?

0 Likes
Message 20 of 22

twagnerEA4R7
Participant
Participant

How did you import the .frx file into Inventor?

0 Likes