Detect when a balloon is covering a drawing curve

Detect when a balloon is covering a drawing curve

MJBusseyMS
Participant Participant
482 Views
1 Reply
Message 1 of 2

Detect when a balloon is covering a drawing curve

MJBusseyMS
Participant
Participant

Is there a way through the Inventor API to detect if a drawing balloon is covering up a drawing curve in a view?  Would like to know when a balloon that I place is covering up any drawing curves in a view so I can move the balloon out of the way of the curves without moving it all of the way outside of the view.

0 Likes
Accepted solutions (1)
483 Views
1 Reply
Reply (1)
Message 2 of 2

JhoelForshav
Mentor
Mentor
Accepted solution

Hi @MJBusseyMS 

I managed to create this iLogic rule to detect all drawingcurves that is covered by the balloon, with a lot of help from here: https://adndevblog.typepad.com/manufacturing/2016/07/get-closest-point-on-drawingcurve.html

 

The code lets you select a balloon and then all curves that are covered by it will turn green.

Note that the code only works if "Scale to text height" is off.

This is because i use the ballon diameter from its style.

BalloonStyle.PNG

 

Dim oBln As Balloon = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingBalloonFilter, "Pick balloon")
Dim oView As DrawingView = oBln.ParentView
Dim oRadius As Double = oBln.Style.BalloonDiameter * 0.5
Dim oPoint As Point2d = oBln.Position
Dim oPickPtX = oPoint.X
Dim oPickPtY = oPoint.Y
Dim oEvaluator As Curve2dEvaluator
For Each oCurve As DrawingCurve In oView.DrawingCurves
	oEvaluator = oCurve.Evaluator2D
	Dim oMinP, oMaxP
	oEvaluator.GetParamExtents(oMinP, oMaxP)
	Dim dLen As Double
	Call oEvaluator.GetLengthAtParam(oMinP, oMaxP, dLen)

	Dim dInc As Double
	dInc = dLen / 100  'consider 100 points         

	Dim dLenInc As Double
	dLenInc = 0

	Dim dparams(0) As Double
	dparams(0) = oMinP

	Dim iCnt As Integer

	For iCnt = 0 To 100
		Dim dParam As Double
		Call oEvaluator.GetParamAtLength(oMinP,
		dInc * iCnt,
		dParam)

		Dim dPts(1) As Double
		dparams(0) = dParam

		Call oEvaluator.GetPointAtParam(dparams, dPts)

		Dim oEachDis = Math.Sqrt(Math.Pow((dPts(0) -oPickPtX), 2) +
		Math.Pow((dPts(1) -oPickPtY), 2))
		If (oEachDis < oRadius) Then
			oCurve.Color = ThisApplication.TransientObjects.CreateColor(0, 255, 0)
			Exit For
		End If

	Next
Next

Hope it helps! 🙂

0 Likes