- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
When using the 'CreateGeometryProxy' function of the inventor API in VB.Net,
Visual studio gives you this warning:
Any idea on how i avoid this?
Code example:
oOcc.CreateGeometryProxy(oOccXZPlane, oOccXZPlane)
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @K.clement. It would be difficult to diagnose without seeing more of the code, but based on the error link, it seems to be trying to convert one object type to another, and that won't work. I know that specific function is designed to set the value of the second input variable (a pre-existing variable that is supposed to be defined as one of the 'proxy' type objects). It looks to me like you are supplying the same variable for both input variables of the function, which it was not designed for. The first variable is for the source object that it is to get/create a proxy for, and the second variable is to hold the new proxy object that was retrieved/created from the first variable. If dealing with WorkPlane object, the first input variable can be either a WorkPlane or a WorkPlaneProxy, but the second input variable should be pre-defined as a WorkPlaneProxy Type object. Technically, the WorkPlaneProxy Class is derived from the WorkPlane Class, so it may not normally throw an error when directly converting between the two within the iLogic environment, but I'm not sure about within the Visual Studio / VB.NET environment.
Wesley Crihfield
(Not an Autodesk Employee)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
a bigger example:
Dim oADef As ComponentDefinition = g_inventorApplication.ActiveDocument.ComponentDefinition
Dim oAsmXYPlane As WorkPlane = oADef.WorkPlanes.Item(3) 'Assembly XY Plane
Dim oAsmZAxis As WorkAxis = oADef.WorkAxes.Item(3) 'Assembly Z Axis
Dim oODef As ComponentDefinition = oOcc.Definition
Dim oOccXYPlane As WorkPlane = oODef.WorkPlanes.Item(3) 'Occurrence XY Plane
Dim oOccZAxis As WorkAxis = oODef.WorkAxes.Item(3) 'Occurrence Z Axis
oOcc.CreateGeometryProxy(oOccXYPlane, oOccXYPlane)
oOcc.CreateGeometryProxy(oOccZAxis, oOccZAxis)
This is a bigger example, do note that :
- This Code works, (it only gives a annoying warning)
- Defining: Dim x as workplaneproxy / oOcc.CreateGeometryProxy(oOccXYPlane, x) gives the same warning:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Looking at the code I expect this is not an iLogic rule. (But an addin?) Anyway, I guess that your function looks something like this:
Public Sub YourFunction(oOcc As ComponentOccurrence)
Dim oADef As ComponentDefinition = g_inventorApplication.ActiveDocument.ComponentDefinition
Dim oAsmXYPlane As WorkPlane = oADef.WorkPlanes.Item(3) 'Assembly XY Plane
Dim oAsmZAxis As WorkAxis = oADef.WorkAxes.Item(3) 'Assembly Z Axis
Dim oODef As ComponentDefinition = oOcc.Definition
Dim oOccXYPlane As WorkPlane = oODef.WorkPlanes.Item(3) 'Occurrence XY Plane
Dim oOccZAxis As WorkAxis = oODef.WorkAxes.Item(3) 'Occurrence Z Axis
oOcc.CreateGeometryProxy(oOccXYPlane, oOccXYPlane)
oOcc.CreateGeometryProxy(oOccZAxis, oOccZAxis)
End Sub
What I understand from the Microsoft link that you send is that your function is not defined correctly.
Did you try using the keywords ByVal or ByRef? Something like this:
Public Sub YourFunction(ByVal oOcc As ComponentOccurrence)
or
Public Sub YourFunction(ByRef oOcc As ComponentOccurrence)
Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Blog: hjalte.nl - github.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
You are correct, this is a addin, and this is indeed the function I made ![]()
I did not use 'byref or byval oOcc as ComponentOccurrence', but adding this to the sub argument does not fix the warning.
this might help:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
i figured it out, there is no mistake here, but this gets rid of the warning
Dim objWorkPlane As Object
firstCompOcc.CreateGeometryProxy(nativeWorkPlane, objWorkPlane)
If TypeOf (objWorkPlane) Is WorkPlaneProxy Then
Dim proxyWorkPlane As WorkPlaneProxy
proxyWorkPlane = CType(objWorkPlane, WorkPlaneProxy)
End If