Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Maxim-CADman77
1125 Views, 9 Replies

Smart face zoom (LookAt & ZoomToSelected)

I'm now working on app that is supposed to zoom some face-of-interest (mainly spheric) smartly (rotate and zoom part body so that the face was clearly distinguished).

Initially my intent was to calculate coordinates of two RangeBox Center-Points (Part's and Face Evaluator's) and  use them as Target and Eye for setting Camera also doing FindInWindow and ZoomTo commands.

I did this succsessfully just to find out that this behaviour is faulty for internal faces of shell-like parts - the Face is shown from the wrong (inner) side.

I now understand that what I need is closer to combination of LookAt & ZoomToSelected commands while the Perspective mode is on. Yet, LookAt command can be applied to plain faces only.

I believe that to achieve my goal I need to get just one more stuff - positive direction of the Face at a given point (its Center). I then should somehow be able to transform that Vector to new Eye-Point.

I thought I need to use FaceProxy but I see this object relates to Assemblies.

So I don't know where to look at now.

Could, please somebody hint me a bit?

Thanks in advance.

PS: I've attached a sample IPT with the only spheric Face marked red

My current code (iLogic)

If ThisDoc.Document.DocumentType=DocumentTypeEnum.kPartDocumentObject then
	Dim oTG As TransientGeometry=ThisApplication.TransientGeometry
	Dim oCam As Camera=ThisApplication.ActiveView.Camera
	Dim oIPT As PartDocument=ThisDoc.Document
	Dim oCD As ComponentDefinition=oIPT.ComponentDefinition
	Dim oSB As SurfaceBody=oCD.SurfaceBodies(1) ' usage of a smarter way of choosing "Body-of-Interest" is supposed !!!
	Dim oBMP As Point= oTG.CreatePoint((oSB.RangeBox.MinPoint.X+(oSB.RangeBox.MaxPoint.X-oSB.RangeBox.MinPoint.X)/2),(oSB.RangeBox.MinPoint.Y+(oSB.RangeBox.MaxPoint.Y-oSB.RangeBox.MinPoint.Y)/2),(oSB.RangeBox.MinPoint.Z+(oSB.RangeBox.MaxPoint.Z-oSB.RangeBox.MinPoint.Z)/2)) ' Body Mid-Point
	Dim oFRB as Box ' Face-of-Interest RangeBox
	Dim oFMP As Point ' Face Mid-Point
	oCAM.Target=oBMP
	For Each oFace As Face in oSB.Faces
		If oFace.SurfaceType=SurfaceTypeEnum.kSphereSurface then
			oIPT.SelectSet.Select(oFace)
			oFRB=oFace.Evaluator.RangeBox
			oFMP=oTG.CreatePoint((oFRB.MinPoint.X+(oFRB.MaxPoint.X-oFRB.MinPoint.X)/2),(oFRB.MinPoint.Y+(oFRB.MaxPoint.Y-oFRB.MinPoint.Y)/2),(oFRB.MinPoint.Z+(oFRB.MaxPoint.Z-oFRB.MinPoint.Z)/2))
			oCam.Eye = oFMP
			oCam.Perspective=True
			oCam.ApplyWithoutTransition
			ThisApplication.CommandManager.ControlDefinitions("AppZoomSelectCmd").Execute
			' oIPT.SelectSet.Clear
	Exit For
		End if 
	Next
Else
	MsgBox ("IPT should be active")
End if

Please vote for Inventor-Idea Text Search within Option Names