iLogic Checking on which plane sketch is defined.

iLogic Checking on which plane sketch is defined.

Anonymous
Not applicable
1,117 Views
2 Replies
Message 1 of 3

iLogic Checking on which plane sketch is defined.

Anonymous
Not applicable

Hi Guys, 

 

I'm looking for the solution of following problem:

 

I'd like to use iLogic rule to check if a sketch (There will be only one used for part creation) was definied on XY plane or not. 

 

I need this information for further part area calculation (with Measure.ExtentsWidth  and Measure.ExtentsLength

function).

 

Right now I have a piece of code which dosen't work: 

 

SyntaxEditor Code Snippet

On Error Resume Next

Dim oDoc As PartDocument
oDoc = ThisDoc.Document

Dim oDef As PartComponentDefinition
oDef = oDoc.ComponentDefinition

Dim oSketch As PlanarSketch
oSketch = oDef.Sketches.Item(1)
 
Dim xyPlane As Inventor.WorkPlane 
xyPlane = oDef.WorkPlanes.Item(3)

If oSketch.WorkPlanes <> xyPlane Then

MessageBox.Show("Sketch needs to be definied on XY plane!", "iLogic")
Exit Sub
End If

 

Thanks in advance for any help.

 

Best Regards

Tomek 

0 Likes
Accepted solutions (1)
1,118 Views
2 Replies
Replies (2)
Message 2 of 3

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @Anonymous

 

Try something like this example.

 

Also just as a tip, you can search and ask programming questions of this type on the Inventor Customization forum too:
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

 

 

Dim oDoc As PartDocument
oDoc = ThisDoc.Document

Dim oDef As PartComponentDefinition
oDef = oDoc.ComponentDefinition

Dim oSketch As PlanarSketch
Try 
	oSketch = oDef.Sketches.Item(1)	
	If oSketch.PlanarEntity.Name <> "XY Plane" Then
		MessageBox.Show _
		("Sketch needs to be definied on XY plane!", "iLogic")
	End If
Catch
	'catch error when no sketch is found
End Try

 

EESignature

Message 3 of 3

Anonymous
Not applicable

Hi Curtis, 

 

It looks like the rule works fine right now. 

 

Thanks a lot for help.

 

Best Regards

Tomek