Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic & Excel integration to draw splines

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
dleesuk
1188 Views, 4 Replies

iLogic & Excel integration to draw splines

Hi All,

 

I have a quite interesting 'problem'.

 

I have an Excel dataset which contains POLAR co-ordinates (55 per 360 deg).

There are 281 lines of this data and each line of data advances along the z-axis by 3.333mm.

 

The data forms the profile of the inside of a pipe over a given length.

 

I've been trying to figure out how to traverse this data and generate sets of points joined by a spline for each line of data.

Subsequently, this would then be used to generate a surface model, thicken it and 3d-print it.

 

 

 

Example of data:

Cells A1-A55 contain the Z co-ordinate; 0, 3.333, 6.666, 10, 13.333, etc.

 

Cell B1 contains 300.27

Cell C1 contains 300.59

Cell D1 contains 299.55

...

Cell BD1 contains 301.22

(this will generate one SLICE with a closed spline)

 

Cell B2 contains 300.59

Cell C2 contains 301.33

Cell D2 contains 302.11

...

Cell BD2 contains 300.50

(this will generate one SLICE with a closed spline advanced 3.33mm along the z-axis)

...and so on.

 

I'm in no way an expert in iLogic and wondered if anyone could help in traversing the dataset confidently.

This should enable me to generate a set of CARTESIAN co-ordinates and thus points and/or splines.

(unless the POLAR co-ordinates can be used in their native form)

 

I've looked at the Inventor/iLogic help files, though it's still not terribly clear.

 

 

It sounds like a big ask, but a very decent nudge in the right direction would be greatly appreciated.

 

 

Let me know if any of this appears confusing and I'll try to elaborate a little further.

 

 

Thank you


Regards

Darren
4 REPLIES 4
Message 2 of 5
xiaodong_liang
in reply to: dleesuk

Hi,

 

If it is just from POLAR coordinate to Euler coordinate, I think it will be a pure math conversion, i.e. 

 

x coordinate = distance * cos(angle)

y coordinate = distance * sin (angle)

 

ADNTest.jpg

 

Is my understanding correct on your question?

Message 3 of 5
dleesuk
in reply to: xiaodong_liang

Thank you xiaodong.liang.

 

Yes, you are correct and I have managed to convert all of my data points to XY coordinates since I posted this.

 

I have, with a little data manipulation/formatting, also managed to generate new workplanes based on the Z value.

 

The issue I now have is that I need to know how to place a spline on each of these workplanes, using the previously converted XY coordinates.

 

I have looked through the API Object Model, but can't figure out which collection/object I need to be looking in to achieve this.

 

 

Could you help with this??

 

 

Any help in greatly appreciated.


Regards

Darren
Message 4 of 5
xiaodong_liang
in reply to: dleesuk

Hi Darren,

 

Thank you for confirming my understanding on your question.

 

iLogic has not direct wrapped functions to create Spline, however you can use Inventor API to achieve the requirement. There are samples on how to create Spline in Inventor API help document (e.g. C:\Program Files\Autodesk\Inventor 2016\Local Help\admapi_20_0.chm). inputting the keyword ‘Sketch Spline’, you can find them.

 

They are written in VBA, but it is not a big difficulty to tune them to iLogic. For your convenience, I converted one of them as below. It assumes a planar sketch is available. What you need to do is to replace those lines of points creations with the points you got from the spread sheet of Excel.

 

Please check API help to get more information on the relevant properties of Spline.

 

' Check to make sure a sketch is open.
If Not TypeOf ThisApplication.ActiveEditObject Is PlanarSketch Then
    MessageBox.Show("A sketch must be active.")
Else
	' Set a reference to the active sketch.
	Dim oSketch As PlanarSketch
	 oSketch = ThisApplication.ActiveEditObject
	
	' Set a reference to the transient geometry collection.
	Dim oTransGeom As TransientGeometry
	  oTransGeom = ThisApplication.TransientGeometry
	
	' Create the collection that will contain the fit points for the spline.
	Dim oFitPoints As ObjectCollection
	  oFitPoints = ThisApplication.TransientObjects.CreateObjectCollection
	
	' Define the points to fit the spline through.  In this example, transient
	' points are used.  They could also be sketch points and then the spline
	' will automatically be constrained to fit through the sketch point.  The
	' points are at (0,0), (2,2), (4,0), (6,4), (7,-1).
	Dim oPoints(0 To 5) As Point2d
	oPoints(0) = oTransGeom.CreatePoint2d(0, 0)
	oFitPoints.Add( oPoints(0))
	
	  oPoints(1) = oTransGeom.CreatePoint2d(2, 2)
	oFitPoints.Add( oPoints(1))
	
	  oPoints(2) = oTransGeom.CreatePoint2d(4, 0)
	oFitPoints.Add (oPoints(2))
	
	  oPoints(3) = oTransGeom.CreatePoint2d(6, 4)
	oFitPoints.Add (oPoints(3))
	
	  oPoints(4) = oTransGeom.CreatePoint2d(7, -1)
	oFitPoints.Add (oPoints(4))
	
	' Create the spline.
	Dim oSpline As SketchSpline
	  oSpline = oSketch.SketchSplines.Add(oFitPoints)
	
	' Change the curve to be closed.
	oSpline.Closed = True
	 
End If




 

ADNTest.jpg

 

Message 5 of 5
dleesuk
in reply to: xiaodong_liang

Thank you xiaodong.liang,

 

I have been hunting for the API Help Doc for quite some time, as I knew something on Splines would be in there somewhere.

 

I'll try your code sample later, but it looks great so far.

 

You may have just saved me from tearing my hair out.

 

 

I'll accept this as a solution as I'm sure I can complete my 'project' from here.

 

 

Thanks again


Regards

Darren

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report