Drawing Automation - how to deal with multiple curve candidates

Drawing Automation - how to deal with multiple curve candidates

jonas.hoffmeisterFYFHQ
Enthusiast Enthusiast
576 Views
7 Replies
Message 1 of 8

Drawing Automation - how to deal with multiple curve candidates

jonas.hoffmeisterFYFHQ
Enthusiast
Enthusiast

hi guys,

 

I am automating a drawing. In this particular code I am adding a linear dimension to a part in an assembly.

 

I am selecting a face which in the oSideView is only visible as a line:

 

jonashoffmeisterFYFHQ_1-1698132022838.png

 

The green marked part of the face is one of the curve candidates.

 

Here is the code:

 

	oCompOcc1 = oAssDoc.ComponentDefinition.Occurrences.ItemByName("MyPart")

	oPartDoc = oCompOcc1.Definition.Document
	myNamedEntities1 = iLogicVb.Automation.GetNamedEntities(oPartDoc)

	oCompOcc2 = oAssDoc.ComponentDefinition.Occurrences.ItemByName("MyPart")

	oPartDoc = oCompOcc2.Definition.Document
	myNamedEntities2 = iLogicVb.Automation.GetNamedEntities(oPartDoc)

	oFace1 = myNamedEntities1.FindEntity("Vorderseite_rechts")
	oFace2 = myNamedEntities2.FindEntity("Vorderseite_links")

	Call oCompOcc1.CreateGeometryProxy(oFace1, oFace1Proxy)
	Call oCompOcc2.CreateGeometryProxy(oFace2, oFace2Proxy)

	myCurveCandidates = oSideView.DrawingCurves(oFace1Proxy) 
	myCurveCandidates2 = oSideView.DrawingCurves(oFace2Proxy) 
	Logger.Debug("MyCurveCandidates1 " & myCurveCandidates.Count)
	Logger.Debug("MyCurveCandidates2 " & myCurveCandidates2.Count)
	
	ExitFlag = False

	For i = 1 To myCurveCandidates.Count
		
		For j = 1 To myCurveCandidates2.Count
		
			myDrawingCurve1 = myCurveCandidates.Item(i)
			oGeoIntent1 = oSheet.CreateGeometryIntent(myDrawingCurve1)
		
			myDrawingCurve2 = myCurveCandidates2.Item(j)
			oGeoIntent2 = oSheet.CreateGeometryIntent(myDrawingCurve2)	
			
			Logger.Debug("i = " & i & " , X = " & myDrawingCurve1.StartPoint.X)
			Logger.Debug("j = " & j & " , X = " & myDrawingCurve2.StartPoint.X)
		
			myPos2d = oTG.CreatePoint2d(myDrawingCurve1.StartPoint.X / 2 + myDrawingCurve2.StartPoint.X / 2, oSideView.Top + 3.5)

			Try
				
				oSheet.DrawingDimensions.GeneralDimensions.AddLinear(myPos2d, oGeoIntent1, oGeoIntent2)
				ExitFlag = True
				Exit For
				
			Catch
				'nothing		
			End Try
			
		Next
		
		If ExitFlag Then
			
			Exit For
			
		End If
					
	Next

 

Here is my debugger output:

 

DEBUG|MyCurveCandidates1 7
DEBUG|MyCurveCandidates2 7
DEBUG|i = 1 , X = 37,504166666675
DEBUG|j = 1 , X = 18,395833333325
DEBUG|i = 1 , X = 37,504166666675
DEBUG|j = 2 , X = 18,395833333325
DEBUG|i = 1 , X = 37,504166666675
DEBUG|j = 3 , X = 18,395833333325
DEBUG|i = 1 , X = 37,504166666675
DEBUG|j = 4 , X = 18,395833333325
DEBUG|i = 1 , X = 37,504166666675
DEBUG|j = 5 , X = 18,395833333325
DEBUG|i = 1 , X = 37,504166666675
DEBUG|j = 6 , X = 18,395833333325
DEBUG|i = 1 , X = 37,504166666675
DEBUG|j = 7 , X = 18,395833333325
DEBUG|i = 2 , X = 37,504166666675
DEBUG|j = 1 , X = 18,395833333325
DEBUG|i = 2 , X = 37,504166666675
DEBUG|j = 2 , X = 18,395833333325

 

The code above works fine and as you can see once curve candidates 2 and 2 are seleceted the linear dimension is added.

 

Here are my questions:

 

1) Why does this problem exist in the first place? What is wrong with the curce candidate with index 1? In other parts candidates 1 and 2 wont work and I have to select 3, which is why I am doing the loop.

 

2) The Try-Catch is not best practice but just something that works for now. Any idea how I can test the curve candidates for specific properties rather than just trying to add the dimenion and if it fails try with another candidate?

 

Thanks

Jonas

 

 

 

 

0 Likes
Accepted solutions (1)
577 Views
7 Replies
Replies (7)
Message 2 of 8

A.Acheson
Mentor
Mentor

Hi @jonas.hoffmeisterFYFHQ 

It is difficult to see without a sample for testing. Can you check the curvetypeEnum your retrieving as curve 1 it shoupd be linear, if it is circular then you might be returning a fillet edge? If the face is a match then curve 1 should be the edge. Have you any modifications done to the occurrence on the assembly level ? If you have then these faces will no longer be in the context of the part but in context of the assembly. 

 

Here is a code that deals with an  assembly level modification. The assembly level check is just a loop of assembly level features. There is some curve checking method as well in various version. It might help in diagnosing your issues. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 8

jonas.hoffmeisterFYFHQ
Enthusiast
Enthusiast

Thanks @A.Acheson for the swift rply.

 

Here is info on the curve type:

 

DEBUG|i = 1 , curvetypeEnum = 5123, X = 38,3625
DEBUG|j = 1 , curvetypeEnum = 5125, X = 1,6625
DEBUG|i = 1 , curvetypeEnum = 5123, X = 38,3625
DEBUG|j = 2 , curvetypeEnum = 5123, X = 1,6625

 

Looks like your guess is right and the kCircularArcCurve for j=1 is causing the issue. In that case my strategy to eliminate the try would be:

 

if curvetypeEnum = 5123 for curve1(i) and curve2(j)

   -> add linear dimension and exit both loops

else

   -> loop on

 

do you agree?

 

On your questions: I am doing multiple modifications on the part once added to the assembly - e.g. edit length via setting parameter values, adding flushes and mates. Also: the part representation on the sheet is impacted by a break view which was causing trouble before.

 

 

0 Likes
Message 4 of 8

Or actually rather (5122 or 5123) as I assume both would be ok?

0 Likes
Message 5 of 8

A.Acheson
Mentor
Mentor
Accepted solution

Hi @jonas.hoffmeisterFYFHQ 

So the modification to the part are all done in the part so this elimates any assembly level geometry modification. 

The filter you have would work, as all you want to do is to skip over the non linear curves. I like to stick with adding curveTypeEnum names when filtering these as it is a little easier to understand..

kLineCurve5122Curve line type.
kLineSegmentCurve5123Curve line segment type.

 

Also I see earlier when you get the intent you don't specifiy where to place the intent so that can effect where the dimension gets attached.  

 

oGeoIntent2 = oSheet.CreateGeometryIntent(myDrawingCurve2)	
			

 

What would be needed is to filter the curves then apply the PointTypeEnum. If you don't filter the curves then you would get a failure of midpoint on non linear curve.

 

 

oGeoIntent2 = oSheet.CreateGeometryIntent(myDrawingCurve2,PointTypeEnum.kMidPointIntent)	

 

In addition you can probably make this easier by creating a function containing named face entity, proxy creation, document etc. Arguments passed in would be occurrence, named face string and the return would be a Curve. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 6 of 8

jonas.hoffmeisterFYFHQ
Enthusiast
Enthusiast

Awesome. Thanks for the additional comments. Very helpful.

 

 

0 Likes
Message 7 of 8

jonas.hoffmeisterFYFHQ
Enthusiast
Enthusiast

Hi @A.Acheson 

 

Thanks again for the recommendation that I should specify the PointTypeEnum when I use the CreateGeoIntent.

 

However, when I want to dimension the distance of two edges and I specify both with e.g. PointTypeEnum.kEndPointIntent than the linear dimension is no longer measuring the distance of the edges but rather the distance of these two specific points on the edges - which might be very different.

 

Can I fix this?

 

0 Likes
Message 8 of 8

A.Acheson
Mentor
Mentor

When placing a dimesion you will need to find an existing point or create a new point and attach the intent to this point. For simplicity it is easier to dimesion an existing point. So I would change what that  point ntent is to be to match the points being selected. According to the help page on PointIntentEnum here

the pointIntent is the inferred cursor position. 

If you think it is beneficial to leave it out then you might get a more universal code but perhaps get different connection points each time. 

 

See help page for Sheet.CreateGeometryIntent here where intent is an optional argument.

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes