What's new

Alibre Script - script requests

NateLiquidGravity

Alibre Super User
I need a script to create a DXF flat layout for sheet metal parts
Currently impossible. Alibre Script does not work in Sheet Metal Parts and there is are very limited Sheet Metal Part API. However see below.
I would love something like Inventor where you right click the face of a part and select export to dxf
I created an AutoHotkey script a while back for exporting a selected face. It does this by basically projecting the face to a sketch and then copying and pasting it into a drawing and asking you what to save it as.
Post in thread 'Shortcut to Export a DXF File?' https://www.alibreforum.com/forum/index.php?threads/shortcut-to-export-a-dxf-file.21924/post-143928
 

GeraldH

Member
I created an AutoHotkey script a while back for exporting a selected face. It does this by basically projecting the face to a sketch and then copying and pasting it into a drawing and asking you what to save it as.
Post in thread 'Shortcut to Export a DXF File?' https://www.alibreforum.com/forum/index.php?threads/shortcut-to-export-a-dxf-file.21924/post-143928
Thanks for the tip. I will try this out.
If a script can't be made, would it be possible to do this with an add-on that works inside alibre?
 

simonb65

Alibre Super User
If a script can't be made, would it be possible to do this with an add-on that works inside alibre?
The script engine uses the same internal mechanism as the add-on, so if it can be done with one, it can be done with the other.
 

GeraldH

Member
This script isn't working for my application because I am not able to unbend all flanges and select the entire face of the part.

The AutoHotkey is pretty neat though, I've never seen it before.
Would it be powerful enough to select Make a Drawing of this Design from inside the sheetmetal workspace>select the desired new sheet properties>select the right options to project a flat pattern>export the .dxf from the drawing to the desired folder & close the drawing without saving? All in one big swift move.;)
 

NateLiquidGravity

Alibre Super User
This script isn't working for my application because I am not able to unbend all flanges and select the entire face of the part.

The AutoHotkey is pretty neat though, I've never seen it before.
Would it be powerful enough to select Make a Drawing of this Design from inside the sheetmetal workspace>select the desired new sheet properties>select the right options to project a flat pattern>export the .dxf from the drawing to the desired folder & close the drawing without saving? All in one big swift move.;)
AutoHotkey can be programmed to do just about anything a user can do on a pc but not always easily.
 

GIOV

Alibre Super User
have now another script request. I hope this time you give me the solution :)
In Rhino the command are described below:
Command: Divide
Select curves to divide:
Number of segments <4> ( Length MarkEnds=Yes ):"
So is able to divide all curve in equal segment include the spline one adding a node or point .
Is it feasible by Alibre script?
Thanks in advance,
GIOV.
Hi Stefan and Nate,
Maybe you will achieve what I need with this math resource:
 

Old Geeser

Senior Member
How about a script that would generate a DXF file which would contain all the geometry. I wrote my own program that takes a DXF file and allows me to generate G-code to run my cnc mill.
Thanks
Karl
 

mikewilt

Member
I need to create a family of sketches based on airfoil geometry data points. I have the control points. I don't see any information about what to put for knotvectors and weights. I want it to pass through the control points, which is one of the options available through the normal user interface for splines. An example of creating a Bspline from point data would be very much appreciated!
Mike
 

idslk

Alibre Super User
An example of creating a Bspline from point data
Python:
myPart = CurrentPart()
mysketchobj_spline = myPart.AddSketch('Spline',myPart.XYPlane)
myOrder = 4
myKnotVectors = [0.0, 0.0, 0.0, 0.0, 10.0, 20.0, 20.0, 20.0, 20.0]
myControlPoints = [-43, 14, -43, 75, 18, 76, 43, 50, 6, 24]
myWeights = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
mysketchobj_spline.AddBspline(myOrder,myControlPoints,myKnotVectors,myWeights,0)
print mysketchobj_spline
print mysketchobj_spline.Figures[0].KnotVectors
print mysketchobj_spline.Figures[0].ControlPoints
print mysketchobj_spline.Figures[0].Weights

...only a little example

Regards
Stefan
 

mikewilt

Member
Python:
myPart = CurrentPart()
mysketchobj_spline = myPart.AddSketch('Spline',myPart.XYPlane)
myOrder = 4
myKnotVectors = [0.0, 0.0, 0.0, 0.0, 10.0, 20.0, 20.0, 20.0, 20.0]
myControlPoints = [-43, 14, -43, 75, 18, 76, 43, 50, 6, 24]
myWeights = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
mysketchobj_spline.AddBspline(myOrder,myControlPoints,myKnotVectors,myWeights,0)
print mysketchobj_spline
print mysketchobj_spline.Figures[0].KnotVectors
print mysketchobj_spline.Figures[0].ControlPoints
print mysketchobj_spline.Figures[0].Weights

...only a little example

Regards
Stefan
This is fantastic, thank you! Pushing my luck... is there any information available about the role of KnotVectors and Weights?
Mike
 

mikewilt

Member
There are tons of technical information online about B-Splines, Nurbs, Knot Vectors, and Weights.
Ok I did some more research on this and have two questions:
- Why does Alibre require two weight values per point, as if the weight is a vector? The literature I have found shows weight as one number per point.
- How do I request the behavior "interpolation points" rather than "control points" in the script?
Mike
 

mikewilt

Member
Here is the script I am playing with to create an airfoil:
Units.Current = UnitTypes.Inches
myPart=CurrentPart()
mysketchobj_spline=myPart.AddSketch('Airfoil',myPart.XYPlane)
myOrder=4
myKnotVectors=[0.0, 0.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, 31.0, 32.0, 33.0, 34.0, 35.0, 36.0, 37.0, 38.0, 39.0, 40.0, 41.0, 42.0, 43.0, 44.0, 45.0, 46.0, 47.0, 48.0, 49.0, 49.0, 49.0, 49.0]
myControlPoints=[63.7775,0,60.5809717,0.04209315,57.383805625,-0.12117725,54.188552875,-0.383302775,50.99521345,-0.70537915,47.804425125,-1.059344275,44.616825675,-1.42734045,41.43113955,-1.79214775,38.248004525,-2.135908475,34.9806832,-2.449056,31.88875,-2.721385925,28.71135495,-2.939504975,25.53523545,-3.092570975,22.359753725,-3.16974175,19.184272,-3.161450675,16.0081525,-3.0715244,12.83075745,-2.898687375,9.6508113,-2.6301841,6.467676275,-2.244968,4.87387655,-1.986669125,3.276250175,-1.66204165,1.67224605,-1.2194258,0.864185125,-0.8979872,0.537644325,-0.714308,0.34312295,-0.5944063,0,0,0.265952175,0.6581838,0.419018175,0.8035965,0.730252375,1.03447105,1.51662895,1.4566781,3.101499825,2.06511545,4.69274845,2.527502325,6.287823725,2.90442735,9.4824387,3.48862925,12.68024255,3.914025175,15.8805975,4.21314165,19.082228,4.401285275,22.284496275,4.48355825,25.48676455,4.458685025,28.68839505,4.336232225,31.88875,4.128317575,35.0878294,3.84578325,38.284995475,3.502022525,41.47961045,3.10596425,44.671674325,2.66717505,47.861824875,2.200961525,51.04878655,1.72071695,54.233197125,1.241747925,57.415694375,0.7806366,60.5962783,0.36098065,63.7775,0]
myWeights=[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
mysketchobj_spline.AddBspline(myOrder,myControlPoints,myKnotVectors,myWeights,0)

It looks good and the sketch checker is fine with it, but it cannot be used to extrude a solid. It says this:
Object reference not set to an instance of an object.
Mike
 

NateLiquidGravity

Alibre Super User
I found the following described in IAD3DSketchBspline.GetData in the Alibre Design API which may be helpful:
Parameters
pCtlPointsType
: System.Array
Coordinates of the control points for the b-spline curve. Hence its size is equal to three times the number of control points.
pKnotVectorType: System.Array
Array of knot values. These are always in ascending order. It determines the degree of the b-spline curve.
pWeightsType: System.Array
Array of weights at each of the control points.
Remarks
B-Spline data is represented in the form of NURBS representation. The knot vector is a sequence of parameter values that determine the continuity along the NURBS curve. The number of knots is always equal to the number of control points plus the order of the curve. The poles are the coordinates of the control points and weights are the homogeneous coordinates which provide extra blending ability. The higher the weights at a control point the higher the pulling/clamping effect of that control point on the b-spline curve.
To initialize an array of the correct size to pass to this function, use the GetDefinition method to first determine the number of poles, etc.
There are other things in the API if you search for spline.
 

Ex Machina

Senior Member
I recently saw Joseph using the equation drawing tool in the script examples to create a sinusoidal curve. Is it possible to expand that tool to accept function for all 3 axes instead of just one? So, one function for the X coordinate, one for the Y and one for the Z.

It'd make it easier to define an involute curve precisely for example. Although approximation can work well enough and gears are usually made with specially formed tools (gear hobbing, form cutting, gear skiving, etc.). But it would be beneficial for 3D printing, perhaps. As well as creating a toroidal helix and so many other interesting shapes that could be mathematically defined in a relatively easy way.
 
Last edited:

HaroldL

Alibre Super User
It has been suggested by some on the forum to use a Thin Extrude Cut to create a slot feature. It takes a bit of calculation to make the sketch line the correct length, simple math really. However, could one of the script writing gurus create a script that creates a full radius slot using the thin extrude cut? Is that a difficult thing to code?
And would it be restricted to lines only or could it include arcs and splines as the sketch figures?

What the script would do is either create the sketch on the fly or use an existing sketch to calculate the slot width and create a thin extrude cut (to depth, through all or to geometry).
It would also apply a either a full radius or user specified radius on the ends of the slot.

Or maybe it would take less time to just create the sketch, perform the thin extrude cut and apply radii than it would to run the script. It would seem that a slot tool could be added to Alibre that would include all the options.
 

Cator

Senior Member
It has been suggested by some on the forum to use a Thin Extrude Cut to create a slot feature. It takes a bit of calculation to make the sketch line the correct length, simple math really. However, could one of the script writing gurus create a script that creates a full radius slot using the thin extrude cut? Is that a difficult thing to code?
And would it be restricted to lines only or could it include arcs and splines as the sketch figures?

What the script would do is either create the sketch on the fly or use an existing sketch to calculate the slot width and create a thin extrude cut (to depth, through all or to geometry).
It would also apply a either a full radius or user specified radius on the ends of the slot.

Or maybe it would take less time to just create the sketch, perform the thin extrude cut and apply radii than it would to run the script. It would seem that a slot tool could be added to Alibre that would include all the options.
Harold, last time I tried scripting the thin extrude features were not available in Alibre script. It might be possible to implement this in the function catalog or through the use of a boolean with the method he showed in the video for rules. But I don't know how this would be reflected in the 2D tablature. This is my thought!
 

NateLiquidGravity

Alibre Super User
I believe it is true that thin wall features can't be created by script or API. However I think their properties can be queried - faces and such. Maybe @idslk can make a version of his Autofillet to let users select the thin wall cut feature and grab the info from that to fillet.
On the other hand the end/corner treatment of thin wall features would be a handy thing Alibre could implement right in the thin wall dialog.
 
Top