02-07-2019
02:11 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
02-07-2019
02:11 AM
Hi again @Anonymous
Here is the simplest example of a transaction I can provide:
Option Explicit On
Public Sub Main()
If TypeOf ThisApplication.ActiveDocument Is PartDocument Then
Dim pyramidheight As String = InputBox("How high?", "Pyramid height", "10")
GeneratePyramid(pyramidheight)
Else
MessageBox.Show("Suggest you create a new part file and run this rule again!")
End If
End Sub
Public Sub GeneratePyramid(ByVal pyramidHeight As String)
Dim height As Integer = Convert.ToInt32(pyramidheight)
Dim rowCount As Integer = 1
Dim spacing As Double = 10 'units = cm
Dim oPartDocument As PartDocument = ThisApplication.ActiveDocument
Dim oCompDef As PartComponentDefinition = oPartDocument.ComponentDefinition
Dim oTrans As TransientGeometry = ThisApplication.TransientGeometry
Dim trans As Transaction = ThisApplication.TransactionManager.StartTransaction(oPartDocument, "Create pyramid of points")
'i = row
'j = column
Dim XSpacing As Double = 0
Dim YSpacing As Double = 0
Dim ZSpacing As Double = 0
For i As Integer = height To 0 Step -1
'Dim tmpPoint As Point = ThisApplication.TransientGeometry.CreatePoint(0, 0, 0)
For j As Integer = 1 To i
Dim wp As WorkPoint = oCompDef.WorkPoints.AddFixed(oTrans.CreatePoint(XSpacing, YSpacing, ZSpacing))
wp.Name = "WP" & i.ToString() & "." & j.ToString()
'set up X Spacing
XSpacing += spacing
Next
'For j As Integer = 1 To rowCount
YSpacing += spacing
XSpacing = (spacing * rowCount) / 2
'Next
rowCount += 1
Next
trans.End()
End Sub
Sub updatestatusbar(ByVal message As String)
ThisApplication.statusbartext = message
End Sub
Sub updatestatusbar(ByVal percent As Double, ByVal message As String)
ThisApplication.statusbartext = message + " (" & percent.ToString("P1") + ")"
End Sub
This process is explained in more detail on the following page:
http://help.autodesk.com/view/INVNTOR/2019/ENU/?guid=GUID-991ABB26-6113-4E27-83F8-1699F259772E
![]()
----------------------------------------------------------------
Alex Fielder
Inventor Expert
https://github.com/alexfielder/
LinkedIn - Github Inventor Extension Server - Bonkers polygon iLogic thing
Top ten iLogic Tips - API Shortcut In Google Chrome - Assembly Extrusion Example
Alex Fielder
Inventor Expert
https://github.com/alexfielder/
LinkedIn - Github Inventor Extension Server - Bonkers polygon iLogic thing
Top ten iLogic Tips - API Shortcut In Google Chrome - Assembly Extrusion Example