Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using face appearances to place sketch symbols

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
sbulowPFMJG
229 Views, 5 Replies

Using face appearances to place sketch symbols

I am trying to automate the placement of sketch symbols in my drawings which I use for labeling images and .dxf export. 

My issue at the moment is that placing the sketch symbols is rather long and tedious. see circled E's

sbulowPFMJG_0-1661871939868.png

What I would like to do is something along these lines:

Change the appearance of the faces which need the 'E' symbols.

Use some sort of ilogic code to auto place the symbols on/near the edges of the corresponding face. 

sbulowPFMJG_1-1661872197973.png

Is this a realistic project to undertake? Is there already some sort of feature could be using which would work for this application?

Thanks,

 

5 REPLIES 5
Message 2 of 6
WCrihfield
in reply to: sbulowPFMJG

Hi @sbulowPFMJG.  It sounds possible to automate, but if you have Inventor 2019 or newer, it would most likely be more efficient to assign names to the faces or edges that you want to focus on.  In the part modeling environment (not in the assembly envoronment), you can select a Face, Edge, or Vertex, then right-click and choose 'Assign Name', to assign a name to the geometry.  When you do that, you can find that named geometry within your iLogic rule code, by accessing the NamedEntities (Link) interface object, and its methods.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 6
sbulowPFMJG
in reply to: WCrihfield

k, I just gave it a try on one of my models. I'm not so sure I'll be saving time in the end. i have models with 50+ faces to ID. Its kind of long going and selecting each face individually and assigning unique names to them. I'm leaning towards the 'appearance' because I can group select faces and it can be done very fast in the 3D environment. 

Message 4 of 6
WCrihfield
in reply to: sbulowPFMJG

OK.  So are you are planning on assigning a single appearance to several faces, all at one time, then you will want to find all of those faces by code, by which appearance they are set to, right?  If so, I totally understand that.  There are often multiple ways of doing things in Autodesk software.  So, are you exporting the drawing document directly as a DXF then?  When you find a face, you can supply that Face as input to the DrawingView.DrawingCurves property to get a DrawingCurvesEnumerator containing the geometry within the view that represents that face.  It will contain DrawingCurve objects, but you may also want to loop through the DrawingCurveSegments of each DrawingCurve to get the line to place the symbol on.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 6
sbulowPFMJG
in reply to: WCrihfield

Yes, This is what I was looking for. Thanks!!! This will be a great starting point for me. 

Message 6 of 6
WCrihfield
in reply to: sbulowPFMJG

Hi @sbulowPFMJG.  Glad to know I was on the right track.  In the mean time, I threw a little something together for you, as somewhat of a kick starter for your code.  Within it, I am simply attempting to find an appearance named "Red" within the document's local appearances, so if that doesn't match your scenario, you will have to edit that part a bit.  I am only going as far as the geometry intent part though.  The rest is up to you for now.

If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
	MsgBox("A Drawing document must be active for this code to work. Exiting.", vbCritical, "")
	Exit Sub
End If
Dim oDDoc As DrawingDocument = ThisDoc.Document
Dim oSheet As Sheet = oDDoc.ActiveSheet
Dim oView As DrawingView = oSheet.DrawingViews.Item(1)
Dim oModel As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
If oModel.DocumentType <> DocumentTypeEnum.kPartDocumentObject Then Exit Sub
Dim oPDoc As PartDocument = oModel
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
Dim oBody As SurfaceBody = oPDef.SurfaceBodies.Item(1)
Dim oRedFaces As New List(Of Face)
Dim oRed As Asset = oPDoc.AppearanceAssets.Item("Red")
For Each oFace As Face In oBody.Faces
	If oFace.Appearance Is oRed Then
		oRedFaces.Add(oFace)
	End If
Next
If oRedFaces.Count = 0 Then Exit Sub
Dim oGeomIntents As New List(Of GeometryIntent)
For Each oRedFace In oRedFaces
	Try
		Dim oCurves As DrawingCurvesEnumerator = oView.DrawingCurves(oRedFace)
		If IsNothing(oCurves) OrElse oCurves.Count = 0 Then Continue For
		For Each oCurve As DrawingCurve In oCurves
				oGeomIntents.Add(oSheet.CreateGeometryIntent(oCurve))
		Next
	Catch
		
	End Try
Next

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report