Message 1 of 3
Creating ProxyPoint and WP in Python
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I´m currently working on a project to automatically configurate different parts in an assembly with constraints. While in iLogic everything works fine, I would like to build the configurator completely in python because I can combine my configuration with my AI-Features and dont need excel as communication for ilogic and python.
My problem:
i = 2 While Not oExcel.Cells.Item(i, 1).Value = "" Dim oOcc As ComponentOccurrence Dim oWP As WorkPoint Dim oWPProxy As WorkPointProxy oOcc = oDoc.ComponentDefinition.Occurrences.ItemByName(oExcel.Cells.Item(i, 1).Value) oWP = oOcc.Definition.WorkPoints(oExcel.Cells.Item(i, 2).Value) Call oOcc.CreateGeometryProxy(oWP, oWPProxy) oExcel.Cells.Item(i, 3).Value = (Round(oWPProxy.Point.X*100)/100).ToString() oExcel.Cells.Item(i, 4).Value = (Round(oWPProxy.Point.Y*100)/100).ToString() oExcel.Cells.Item(i, 5).Value = (Round(oWPProxy.Point.Z*100)/100).ToString() i = i + 1 End While
I have a list with occurence-names and workpoints and want to know where those points are located in the assembly document.
But how can I create a ProxyPoint in python via api? Also is there another option to access the workpoints of an occurrence in python than:
oOcc.Definition.Document.ComponentDefinition.WorkPoint
'oOcc.Definition.WorkPoints' does not work because there is no object 'WorkPoints' in 'Definition' (in ilogic it works fine)
import win32com.client
from win32com.client import gencache, Dispatch, constants, DispatchEx
oApp = win32com.client.Dispatch('Inventor.Application')
oApp.Visible = True
mod = gencache.EnsureModule('{D98A091D-3A0F-4C3E-B36E-61F62068D488}', 0, 1, 0)
oApp = mod.Application(oApp)
# oApp.SilentOperation = True
oDoc = oApp.ActiveDocument
oDoc = mod.AssemblyDocument(oDoc)
oOccs = oDoc.ComponentDefinition.Occurrences
# proxyWP = oDoc.ComponentDefinition.WorkPointProxy does not work
i = 0
for WP in oDoc.ComponentDefinition.WorkPoints:
i += 1
print(f'Name of Workpoint {i}: {WP.Name}')
for oOcc in oOccs:
for oWP in oOcc.Definition.Document.ComponentDefinition.WorkPoints:
print(oWP.Name)
print(oOcc.Name)
# oOcc.CreateGeometryProxy(oWP, proxyWP)
print(oWP.Point.X)