Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Helix equation and API

9 REPLIES 9
Reply
Message 1 of 10
bogiedreamer
553 Views, 9 Replies

Helix equation and API

Hi,
I am new to inventor. I wonder if I can use equations in API to define a spring path.
For example, putting these equation in a loop where t = 0 to 31
x = cos(t)
y = sin(t)
z = t

and the profile of the spring can be round or rectangular.

thank you,
9 REPLIES 9
Message 2 of 10
Anonymous
in reply to: bogiedreamer

You might find that you get a better response from the Inventor Customization (VBA and VB) n/g http://discussion.autodesk.com/forum.jspa?forumID=120 news://discussion.autodesk.com/autodesk.inventor.customization There's also a API help on the main menu under Help --> Programming Help From my limited knowledge of VB(A) you can use all trigonometric equations. HTH Duncan -- "Humour ... is one man shouting gibberish in the face of authority, and proving by fabricated insanity that nothing could be as mad as what passes for ordinary living." (Terence 'Spike' Milligan K.B.E., 1918-2002) "bogiedreamer" wrote in message news:11395271.1096606783353.JavaMail.jive@jiveforum1.autodesk.com... > Hi, > I am new to inventor. I wonder if I can use equations in API to define a > spring path. > For example, putting these equation in a loop where t = 0 to 31 > x = cos(t) > y = sin(t) > z = t > > and the profile of the spring can be round or rectangular. > > thank you,
Message 3 of 10
Anonymous
in reply to: bogiedreamer

Dreamer ;-) As Duncan said, we are glad to help you in the Customisation forum. This code will generate the 3D Spline (copy paste this code into your Default.ivb and run the macro) Cheers, Teun Public Sub Create3DSplineUsingFormulas() Const NumberOfPoints = 31 Dim oPartDoc As PartDocument Dim oCompDef As PartComponentDefinition Dim oTransGeom As TransientGeometry Dim oWPs(0 To NumberOfPoints) As WorkPoint Dim oFitPoints As ObjectCollection Dim o3DSketch1 As Sketch3D Dim o3DSpline As SketchSpline3D Dim oCamera As Camera Dim n As Double Set oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject) Set oCompDef = oPartDoc.ComponentDefinition Set oTransGeom = ThisApplication.TransientGeometry For n = 0 To NumberOfPoints Set oWPs(n) = oCompDef.WorkPoints.AddFixed(oTransGeom.CreatePoint(Cos(n), Sin(n), n)) Next n Set oFitPoints = ThisApplication.TransientObjects.CreateObjectCollection For n = 0 To NumberOfPoints Call oFitPoints.Add(oWPs(n)) Next n Set o3DSketch1 = oCompDef.Sketches3D.Add o3DSketch1.SketchSplines3D.Add oFitPoints Set oCamera = ThisApplication.ActiveView.Camera oCamera.ViewOrientationType = kIsoTopRightViewOrientation oCamera.Fit oCamera.Apply MsgBox "3DSpline has been created!" End Sub
Message 4 of 10
Anonymous
in reply to: bogiedreamer

Here's an update... Try changing "(Cos(n), Sin(n), n)" to "(Cos(n), Sin(n) / 2, n)" or "2 * (Cos(n), Sin(n), n)" and see the results (wicked!!!) Formulas are fun :-) Cheers, Teun Public Sub Create3DSplineUsingFormulas() Const NumberOfPoints = 31 Dim oPartDoc As PartDocument Dim oCompDef As PartComponentDefinition Dim oTransGeom As TransientGeometry Dim oWPs(0 To NumberOfPoints) As WorkPoint Dim oFitPoints As ObjectCollection Dim o3DSketch1 As Sketch3D Dim o3DSpline As SketchSpline3D Dim oCamera As Camera Dim n As Double Set oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject) Set oCompDef = oPartDoc.ComponentDefinition Set oTransGeom = ThisApplication.TransientGeometry For n = 0 To NumberOfPoints Set oWPs(n) = oCompDef.WorkPoints.AddFixed(oTransGeom.CreatePoint(Cos(n), Sin(n), n)) Next n Set oFitPoints = ThisApplication.TransientObjects.CreateObjectCollection For n = 0 To NumberOfPoints Call oFitPoints.Add(oWPs(n)) Next n Set o3DSketch1 = oCompDef.Sketches3D.Add Set o3DSpline = o3DSketch1.SketchSplines3D.Add(oFitPoints) Dim oWorkPlane As WorkPlane Set oWorkPlane = oCompDef.WorkPlanes.AddByNormalToCurve(o3DSpline, oWPs(0)) Dim oSketch2D As PlanarSketch Set oSketch2D = oCompDef.Sketches.Add(oWorkPlane) Dim oSketchPoint As SketchPoint Set oSketchPoint = oSketch2D.AddByProjectingEntity(oWPs(0)) Dim oSketchCircle As SketchCircle Set oSketchCircle = oSketch2D.SketchCircles.AddByCenterRadius(oSketchPoint, 0.1) Dim oPath As Path Set oPath = oCompDef.Features.SweepFeatures.CreatePath(o3DSpline) Dim oProfile As Profile Set oProfile = oSketch2D.Profiles.AddForSolid Dim oSweep As SweepFeature Set oSweep = oCompDef.Features.SweepFeatures.Add(oProfile, oPath, kJoinOperation) Set oCamera = ThisApplication.ActiveView.Camera oCamera.ViewOrientationType = kIsoTopRightViewOrientation oCamera.Fit oCamera.Apply MsgBox "Done" End Sub
Message 5 of 10
bogiedreamer
in reply to: bogiedreamer

Hi,
thank you for helping, when I run I get this error message at:
Set oWPs(n) =

"Compile error: Syntax error"
Message 6 of 10
bogiedreamer
in reply to: bogiedreamer

Teun Ham,
If you don't mind could you please create a file with that Macro embeded in? I am taking Inventor lessons, 4 more sessions to go. So I am a little weak.
Thanks,
Kha
Message 7 of 10
gnrnr
in reply to: bogiedreamer

Bogiedreamer,

You need to watch the word wrapping in the posted file if you are looking at the newsgroups from the web. The line underneath should be on the same line:
eg.
Set oWPs(n) = oCompDef.WorkPoints.AddFixedoTransGeom.CreatePoint(Cos(n), Sin(n), n))

again, watch the word wrap

Regards


Steve
Message was edited by: sstrik
Message 8 of 10
Anonymous
in reply to: bogiedreamer

Exactly, watch out for word-wrapping. "sstrik" wrote in message news:666302.1096867703692.JavaMail.jive@jiveforum1.autodesk.com... > Bogiedreamer, > > You need to watch the word wrapping in the posted file if you are looking at the newsgroups from the web. The line underneath should be on the same lined as: > eg. > Set oWPs(n) = something should be here > > Regards > > > Steve
Message 9 of 10
bogiedreamer
in reply to: bogiedreamer

Hi sstrik and Teun Ham,
I got it, thank you so much. I love Inventor. I am going to my 3rd session (out of 5) right now and learning so much.
Message 10 of 10
bogiedreamer
in reply to: bogiedreamer

Hi again,
could I modify the code if I want the profile to be rectangular.
please see the attached file.
thanks again,

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

Post to forums  

Autodesk Design & Make Report