Problem creating a radius for a spherical surface in IDW with iLogic.

Problem creating a radius for a spherical surface in IDW with iLogic.

heliston_guimaraes
Participant Participant
847 Views
13 Replies
Message 1 of 14

Problem creating a radius for a spherical surface in IDW with iLogic.

heliston_guimaraes
Participant
Participant

Hello everyone. I have a solid with a spherical face created from a revolution. This face is identified as Face1. I haven't been able to create the radius in the IDW with the following code: Dim COTA4_FE = COTAS_FE.AddRadius("raioelectrodo2", REF1_FE, Face1_VIEW01_FE). This is just a fragment of the final code that should generate the radius. I think the problem is that this type of spherical face does not accept the definition of Radius. But I also don't know what other syntax besides radius I could use. Has anyone experienced something similar? When running the code, the following error appears: System.Runtime.InteropServices.COMException (0x80004005): Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at Inventor.GeneralDimensions.AddRadius(Point2d TextOrigin, GeometryIntent Intent, Boolean ArrowheadsInside, Boolean LeaderFromCenter, Boolean Jogged, Object DimensionStyle, Object Layer)
at Autodesk.iLogic.Core.ManagedDrawing.ManagedGeneralDimensions.AddRadius(String name, RadiusDimensionTextPositionSpec textOrigin, GeometryIntent intent, Boolean arrowHeadsInside, Boolean leaderFromCenter, Boolean jogged, DimensionStyle dimensionStyle, Layer layer)
at ThisRule.Main() in rule: REGRA MASTER IDW, in document DESENHOS.idw:line 1608
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

 

heliston_guimaraes_0-1715761699074.png

heliston_guimaraes_1-1715761765797.png

heliston_guimaraes_2-1715761807227.png

 

 

 

0 Likes
848 Views
13 Replies
Replies (13)
Message 2 of 14

Curtis_Waguespack
Consultant
Consultant

@heliston_guimaraes, I can confirm that I am seeing the same or similar results.

 

The green edge shown is a revolved edge, but works, but the red non-tangent revolved edge does not.

 

@MjDeck, if you have some time would you be able to tell us what is going on here?

 

See attached 2023 data set

 

The last line errors trying to place filletDim1 on the revolved surface face, but places dims on the other named faces

 

Dim Sheet_1 = ThisDrawing.Sheets.ItemByName("Sheet:1")
Dim VIEW1 = Sheet_1.DrawingViews.ItemByName("VIEW1")
Dim Face1 = VIEW1.GetIntent("Face1")
Dim Face2 = VIEW1.GetIntent("Face2")
Dim Face3 = VIEW1.GetIntent("Face3")
Dim Point1 = VIEW1.SheetPoint(1.1, 1.1)
Dim Point2 = VIEW1.SheetPoint(-0.1, -0.1)
Dim Point3 = VIEW1.SheetPoint(1.1, -0.1)

Dim genDims = Sheet_1.DrawingDimensions.GeneralDimensions

Dim filletDim3 = genDims.AddRadius("Fillet Radius3", Point3, Face3)
Dim filletDim2 = genDims.AddRadius("Fillet Radius2", Point2, Face2)
Dim filletDim1 = genDims.AddRadius("Fillet Radius1", Point1, Face1)

 

Curtis_Waguespack_2-1715781574793.png

 

 

EESignature

Message 3 of 14

MjDeck
Autodesk
Autodesk
Accepted solution

Hi @Curtis_Waguespack and @heliston_guimaraes , the trimmed spherical face on the left is rendered with two curves in the drawing. The first curve is the flat top of the cylinder. The second is the circle above it. iLogic will choose the first one by default. A radius dimension will fail on it because it's flat. To get the correct curve, use something like this:

 

Dim Face1 = VIEW1.GetIntent("Face1", nearPoint := VIEW1.SheetPoint(0.5, 1.1))

 

That tells the system: if you find more than one curve, choose the one whose bounding box center is closest to this point. In this case, that would be a point right above the view, in the center in the X direction. It should generally be possible to specify a point like this so as to get the curve you want.


Mike Deck
Software Developer
Autodesk, Inc.

Message 4 of 14

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Thanks @MjDeck !

 

That explanation helps a lot.

 

Working example for the previously attached example, in case it helps someone in the future:

 

Dim Sheet_1 = ThisDrawing.Sheets.ItemByName("Sheet:1")
Dim VIEW1 = Sheet_1.DrawingViews.ItemByName("VIEW1")

Dim Point1 = VIEW1.SheetPoint(0.3, 1.1)
Dim Point2 = VIEW1.SheetPoint(-0.1, -0.1)
Dim Point3 = VIEW1.SheetPoint(1.1, 1.1)

Dim Face1 = VIEW1.GetIntent("Face1", nearPoint := Point1)
Dim Face2 = VIEW1.GetIntent("Face2")
Dim Face3 = VIEW1.GetIntent("Face3")

Dim genDims = Sheet_1.DrawingDimensions.GeneralDimensions

Dim filletDim1 = genDims.AddRadius("Fillet Radius1", Point1, Face1)
Dim filletDim2 = genDims.AddRadius("Fillet Radius2", Point2, Face2)
Dim filletDim3 = genDims.AddRadius("Fillet Radius3", Point3, Face3)

 

 

EESignature

Message 5 of 14

heliston_guimaraes
Participant
Participant

@MjDeck and @Curtis_Waguespack, thank you so much for the time you dedicated to responding. It worked perfectly here as well.

Message 6 of 14

est_david_bermudez
Contributor
Contributor

Hi @Curtis_Waguespack and @MjDeck 

I'm trying to do that for an assembly, but I get an error (Cannot convert an object of type 'Autodesk.iLogic.Types.DocumentUnitsPoint2d' to type 'Inventor.Point2d'.) with the following code:

        oView = ActiveSheet.View("PRIMERA").View
		
		Dim Sheet_1 = ThisDrawing.Sheets.ItemByName("Hoja:1")
		Dim oView1 = Sheet_1.DrawingViews.ItemByName("PRIMERA")
		Dim Point1 = oView1.SheetPoint(0.3, 1.1)
		
		
		Dim Face1 As Face 
		oObjs = oPartDoc.AttributeManager.FindObjects("DIM", "CaraTapa", "1")
		Face1 = oObjs.Item(1)
		
		Dim oDrawCurves1 As DrawingCurve
		oDrawViewCurves = oView.DrawingCurves(Face1)
		oDrawCurves1 = oDrawViewCurves.Item(1)
		
		Dim genDims = oSheet.DrawingDimensions.GeneralDimensions
		
		Dim filletDim1 = genDims.AddRadius(Point1, oSheet.CreateGeometryIntent(oDrawCurves1))

Could you help me understand and fix this issue?

0 Likes
Message 7 of 14

MjDeck
Autodesk
Autodesk
Accepted solution

Hi @est_david_bermudez - you're mixing iLogic-specific drawing automation objects and functions with Inventor API in a way I haven't seen before.

To resolve the "cannot convert" error, replace this line:

Dim filletDim1 = genDims.AddRadius(Point1, oSheet.CreateGeometryIntent(oDrawCurves1))

with this:

Dim filletDim1 = genDims.AddRadius(Point1.InDatabaseUnits, oSheet.CreateGeometryIntent(oDrawCurves1))

 
Here's documentation for the DocumentUnitsPoint2d class.


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 8 of 14

est_david_bermudez
Contributor
Contributor

@MjDeckThanks for taking the time to reply! I have another error (Line 39, Unespecific error (Exception of HRESULT: 0x80004005 (E_FAIL)). Here is my full code and I'm working with iLogic

 

Class VistaElevacion
	Public oDrawDoc As DrawingDocument
	Public oSheet As Sheet
	Public oView As DrawingView
	Public oViews As DrawingViews
	Public oPartDoc As AssemblyDocument
	Public oTG As TransientGeometry
	Public Punto1 As String
	Sub main()
		oDrawDoc = ThisDoc.Document
		oSheet = oDrawDoc.ActiveSheet
		oView = ActiveSheet.View("PRIMERA").View
		oViews = oSheet.DrawingViews
		oPartDoc = ActiveSheet.View("PRIMERA").ModelDocument
		oTG = ThisApplication.TransientGeometry
		Punto1 = "CaraTapa"
		dimensionRadial(Punto1)
	End Sub	
	
	Sub dimensionRadial(nombreCara As String)	
		
		oView = ActiveSheet.View("PRIMERA").View
		
		Dim Sheet_1 = ThisDrawing.Sheets.ItemByName("Hoja:1")
		Dim oView1 = Sheet_1.DrawingViews.ItemByName("PRIMERA")
		Dim Point1 = oView1.SheetPoint(0.3, 1.1)
		
		
		Dim Face1 As Face 
		oObjs = oPartDoc.AttributeManager.FindObjects("DIM", nombreCara, "1")
		Face1 = oObjs.Item(1)
		
		Dim oDrawCurves1 As DrawingCurve
		oDrawViewCurves = oView.DrawingCurves(Face1)
		oDrawCurves1 = oDrawViewCurves.Item(1)
		
		Dim genDims = oSheet.DrawingDimensions.GeneralDimensions
		
		Dim filletDim1 = genDims.AddRadius(Point1.InDatabaseUnits, oSheet.CreateGeometryIntent(oDrawCurves1))
	End Sub

End Class

 

0 Likes
Message 9 of 14

MjDeck
Autodesk
Autodesk

Hi @est_david_bermudez , I think it depends on the dataset. I tested your rule in Inventor 2023 and 2025 and it works for me. Can you post a sample dataset that shows the error? Which version of Inventor are you running?


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 10 of 14

est_david_bermudez
Contributor
Contributor

Hi @MjDeck, I'm working with Inventor 2024. This is my assembly, and here’s the face I’m trying to dimension.

 

est_david_bermudez_0-1739391601500.png

I thought the issue was due to the hole I have, but I tried it on the part mentioned in this post, and it worked fine. The problem is that since it's a part and not an assembly, I don't run into any issues.

 

est_david_bermudez_1-1739391870282.png

 

Message 11 of 14

MjDeck
Autodesk
Autodesk
Accepted solution

I think the problem is in selecting the appropriate drawing curve. Please try changing this line:

oDrawCurves1 = oDrawViewCurves.Item(1)

to this:

oDrawCurves1 = oDrawViewCurves.Item(2)


If that doesn't work and you want me to look at it in more detail, I need the subassemblies and parts. And it would probably help if I had the drawing file as well. Can you put everything in a zip file, maybe with the Pack and Go command?


Mike Deck
Software Developer
Autodesk, Inc.

Message 12 of 14

est_david_bermudez
Contributor
Contributor

Thank you very much for your help, that was indeed the issue. Do you know how to change the dimension type to a bent leader using code?
Like this

est_david_bermudez_0-1739393326765.png

 

0 Likes
Message 13 of 14

MjDeck
Autodesk
Autodesk
Accepted solution

Yes, it can be done.
If necessary, change the dimension point so the Y coordinate is lower down in the view. In my case I used:

Dim Point1 = oView1.SheetPoint(0.3, 0.7)


Add an option to the AddRadius statement:

Dim filletDim1 = genDims.AddRadius(Point1.InDatabaseUnits, oSheet.CreateGeometryIntent(oDrawCurves1), Jogged := True)




Mike Deck
Software Developer
Autodesk, Inc.

Message 14 of 14

est_david_bermudez
Contributor
Contributor

@MjDeck Thank you for all your answers, they have been extremely helpful to me.