Access part "Origin" folder via iLogic

Access part "Origin" folder via iLogic

DRoam
Mentor Mentor
992 Views
5 Replies
Message 1 of 6

Access part "Origin" folder via iLogic

DRoam
Mentor
Mentor

I'm trying to write some code that will get the current names of the Origin work features. In order to do that, I need to access the origin folder. I'm close, but the code I have isn't working -- I think because it's meant to access Assembly folders, and the Origin folder is a special folder that isn't contained in this "set" (plus I'm in a Part which can't have folders).

 

Below is what I have. I need help with the lines in red: The one that accesses the Origin folder, which isn't working, as well as the lines that check if the node being checked is a Work Plane, Work Axis, or Work Point, since Inventor doesn't seem to like those either.

 

Dim oPlaneNames(3) As String
Dim oAxisNames(3) As String
Dim oCenterPointName As String

oPane = ThisApplication.ActiveDocument.BrowserPanes.Item("Model")
oOriginFolder = oPane.TopNode.BrowserFolders.Item("Origin")
oOriginFolderNodes = oOriginFolder.BrowserNode.BrowserNodes
Dim PlaneCount As Integer = 0
Dim AxisCount As Integer = 0
For Each oNode As BrowserNode In oOriginFolderNodes
	oObject = oNode.NativeObject
	If oObject = WorkPlane Then
		PlaneCount = PlaneCount + 1
		oPlaneNames(PlaneCount) = oObject.Name
	End If
	If oObject = WorkAxis Then
		AxisCount = AxisCount + 1
		oAxisNames(AxisCount) = oObject.Name
	End If
	If oObject = WorkPoint Then
		oCenterPointName = oObject.Name
	End If
Next

 Thanks in advance!

0 Likes
Accepted solutions (1)
993 Views
5 Replies
Replies (5)
Message 2 of 6

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi DRoam,

 

I think you're trying to "bend the spoon", without realizing there is no spoon. Smiley Wink

 

Let's assume there is no folder. (edit: I should point out that I'm not saying that the there really isn't a folder that the API can grab, just that it's sometimes better when doing these things to assume that interface objects don't really exist)

 

Instead we can look at the workplanes collection, and then use the IsCoordinateSystemElement property to determine which ones are "origin" planes. Rinse and repeat for axes and points.

 

Now we can bend the spoon. Smiley Tongue

 

 

oDoc = ThisDoc.Document

'look at all planes
For Each oWorkPlane In oDoc.ComponentDefinition.WorkPlanes
	'check if this is an origin plane
	If oWorkPlane.IsCoordinateSystemElement = True Then
	oMsg = oWorkPlane.Name
	MessageBox.Show(oMsg, "iLogic")
	End If
Next

 

 

Post back if this doesn't work (maybe you were trying to bend a spork?)

 

Also just a reminder, Inventor Customization forum:
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

EESignature

Message 3 of 6

DRoam
Mentor
Mentor

*gazes in amazement* no, no, you speak the truth.... there is no spoon! Smiley Surprised seriously, that code negates my whole reason for needing to do this. I had no idea I could just check if a plane was one of the origin planes. That makes this job so much easier. Thank you!

 

New conspiracy theory: @Curtis_Waguespack is the Oracle.

 

Message 4 of 6

Curtis_Waguespack
Consultant
Consultant

@DRoam wrote:

 

New conspiracy theory: @Curtis_Waguespack is the Oracle.

 


Smiley Happy

 

nope, that would be someone else, I'm just that bald kid that pulled his hair out in the past trying to bend a lot of spoons the hard way. Smiley Tongue

 

Assuming there is no "spoon" to begin with is just a concept that helps us as users ( who know interface items, better than the API ), get back behind the "curtain" more easily.

 

Also in case you're trying to get a specific origin plane you can just use the collection item numbers to get them directly.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

oWPlanes = ThisDoc.Document.ComponentDefinition.WorkPlanes

oplane = oWPlanes.Item(1).Name 'YZ
MessageBox.Show(oplane, "iLogic")

oplane = oWPlanes.Item(2).Name 'XZ
MessageBox.Show(oplane, "iLogic")

oplane = oWPlanes.Item(3).Name 'XY
MessageBox.Show(oplane, "iLogic")

 

EESignature

Message 5 of 6

DRoam
Mentor
Mentor

@Curtis_Waguespack wrote:

nope, that would be someone else, I'm just that bald kid that pulled his hair out in the past trying to bend a lot of spoons the hard way. Smiley Tongue


 Lol, that adds a whole new dimension to that scene...

 


@Curtis_Waguespack wrote:

Also in case you're trying to get a specific origin plane you can just use the collection item numbers to get them directly.

 

....


Perfect. Thank you. Once again, you da man 😉

 

I have to ask.... so when you look at iLogic, do you even see the code? Or do you just see blonde view rep, brunette view rep, redhead view rep......

0 Likes
Message 6 of 6

Curtis_Waguespack
Consultant
Consultant

DRoam wrote:

 

I have to ask.... so when you look at iLogic, do you even see the code? Or do you just see blonde view rep, brunette view rep, redhead view rep......


lol, most of the time I just see "riddles" to be solved, occasionally where there's a really elegant solution, I see bugs bunny in a dress. Smiley Surprised

EESignature

0 Likes