Half Section View by Dimension

Half Section View by Dimension

dusan.naus.trz
Advisor Advisor
289 Views
3 Replies
Message 1 of 4

Half Section View by Dimension

dusan.naus.trz
Advisor
Advisor

What is wrong? Does anyone have an idea how to get this to work? GetPosition of type FaceProxy not found. 

picture.png

 

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
'	MsgBox("Chybně spuštěn dialog! Špatný typ dokumentu." & vbLf & "OK pro Ukončení." & vbLf & "(" & iLogicVb.RuleName & ") ", vbOKOnly + vbCritical, "Funkce Sestavy (iam)")
	MsgBox("Dialog failed to start! Bad document type." & vbLf & "OK to Exit." & vbLf & "(" & iLogicVb.RuleName & ") ", vbOKOnly + vbCritical, "Assembly function (iam)")
	Exit Sub
End If

Dim oInvApp As Inventor.Application = ThisApplication
Dim oDoc As Document = oInvApp.ActiveDocument
Dim oCM As CommandManager = oInvApp.CommandManager
Dim oMT As MeasureTools = oInvApp.MeasureTools
Dim oTG As TransientGeometry = oInvApp.TransientGeometry
Dim oFace1, oFace2 As Face
oFace1 = oCM.Pick(SelectionFilterEnum.kPartFaceFilter, "Select the first face")'Vyber první plochu
If oFace1 Is Nothing Then Exit Sub
oFace2 = oCM.Pick(SelectionFilterEnum.kPartFaceFilter, "Select the second face")
If oFace2 Is Nothing Then Exit Sub
Dim oCyl1, oCyl2 As Cylinder
If oFace1.SurfaceType = SurfaceTypeEnum.kCylinderSurface Then oCyl1 = oFace1.Geometry
If oFace2.SurfaceType = SurfaceTypeEnum.kCylinderSurface Then oCyl2 = oFace2.Geometry
Dim result As Double
If oCyl1 IsNot Nothing And oCyl2 IsNot Nothing Then
	Dim oLine1, oLine2 As Line
	oLine1 = oTG.CreateLine(oCyl1.BasePoint, oCyl1.AxisVector.AsVector())
	oLine2 = oTG.CreateLine(oCyl2.BasePoint, oCyl2.AxisVector.AsVector())
	result = oMT.GetMinimumDistance(oLine1, oLine2)
Else If oCyl1 IsNot Nothing Then
result = oMT.GetMinimumDistance(oCyl1.BasePoint, oFace2)
Else If oCyl2 IsNot Nothing Then
result = oMT.GetMinimumDistance(oFace1, oCyl2.BasePoint)
Else
	result = oMT.GetMinimumDistance(oFace1, oFace2)
End If
'MessageBox.Show(result * 10, "Title")
'moje = result '* 10

Dim asm As AssemblyDocument = ThisDoc.Document
Dim asmDef As AssemblyComponentDefinition = asm.ComponentDefinition
Dim viewRep As DesignViewRepresentation = asmDef.RepresentationsManager.ActiveDesignViewRepresentation

Dim rootPoint As Point
Dim xAxis, yAxis As UnitVector
oFace1.GetPosition(rootPoint, xAxis, yAxis)

Dim offset As Double = -result '5 ' 5cm offset
MessageBox.Show(result, "Title")
Dim planeBasePt As Point = ThisApplication.TransientGeometry.CreatePoint(rootPoint.X + offset, rootPoint.Y, rootPoint.Z)
Dim planeNormal As Vector = ThisApplication.TransientGeometry.CreateVector(-1, 0, 0)

Dim plane1 As Plane = ThisApplication.TransientGeometry.CreatePlane(planeBasePt, planeNormal)
viewRep.SetSectionView(SectionViewTypeEnum.kHalfSectionViewType, plane1)

  

0 Likes
290 Views
3 Replies
Replies (3)
Message 2 of 4

WCrihfield
Mentor
Mentor

Hi @dusan.naus.trz.  Since I am not allowed to download or open ZIP files from forums, due to corporate security policy, the only way I can help is to review the code you posted here.  It mostly looks just fine to me, but I would probably change the two "Else If" instances to "ElseIf", because that works slightly differently.  I might also inject a feedback line just after each line of code that sets the value of the 'result' variable, just to see what it is in that exact scenario.  It is also slightly concerning that you are using two different variables or the document you are focusing on ('oDoc' & 'asm'), and are setting their values in two different ways.  In rare cases, that can result in working with two different documents, but not sure if that is a problem here.  I assume the oFace1.GetPosition is an 'extension' Sub routine defined in a Module somewhere, and that all three parameters are declared using 'ByRef', because I am not familiar with that one, and can only assume it is working as designed, and that all 3 objects are getting valid values assigned to them.  Not sure if some sort of check/debug/feedback line might help right after that line or not.  Everything else looks pretty good.

PS.  Are you getting an error, or does it just not seem to do anything?  If showing an error, then maybe showing the error message and/or where in the code the error is happening might help us narrow the problem down.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 4

dusan.naus.trz
Advisor
Advisor

The error is written in the beginning. = GetPosition of type FaceProxy not found.

The zip file contains what is in the picture. = Assembly with one ipt. The ipt shape is in the picture.

0 Likes
Message 4 of 4

WCrihfield
Mentor
Mentor

Hi @dusan.naus.trz.  As mentioned, I am not sure where you saw that method (FaceProxy.GetPosition) before, or why you are trying to use it here, because neither the Face object, nor the FaceProxy object has any documentation about a method by that name.  That is why I assumed that this code you are showing was only part of the whole code, and that that method was defined elsewhere on your local system, and was being referenced somehow.

 

I am not sure how familiar you are with the idea of using external iLogic rules to store common code routines, then using the AddVbFile in the Header of the rule to reference that external rule, and be able to use its resources, so I will share something with you here that is what I had in mind here.  We can define a 'Module' within an external rule, and within that Module, we can create 'extension' blocks of code.  These can be used to extend the properties of existing object types, or extend the functionality of the existing methods of existing object types.  Below, I will attempt to show an extremely simple example of this that I have on hand.  I have an external rule named "ExtensionsModule", and within that I created a Module block of code, similar to the following:

Public Module ExcensionsModule
	<Extension() >
	Public Function HasBeenSaved(oThisDoc As Autodesk.iLogic.Interfaces.ICadDoc) As Boolean
		If String.IsNullOrEmpty(oThisDoc.PathAndFileName()) Then Return False
		Return True
	End Function
End Module

The first input parameter in the definition line determines the Type of object that this is extending.  In this case it is an ICadDoc type of input.

Now, from another iLogic rule, I put:

AddVbFile "ExtensionsModule.txt"
If ThisDoc.HasBeenSaved Then
	MsgBox("It has been saved.", , "")
Else
	MsgBox("It has Not been saved.", , "")
End If

And it simply works.  I have just added an extra Property that works like a Function that returns a Boolean value to the ICadDoc instance I am working with in this rule (represented by the ThisDoc term), and it functions as designed, but that will not effect its use in other rules, without that line in the header.  This is similar to what I assumed that you did locally on your computer.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes