iLogic Get Model Sketches to Drawing View

iLogic Get Model Sketches to Drawing View

jkorson
Enthusiast Enthusiast
4,337 Views
32 Replies
Message 1 of 33

iLogic Get Model Sketches to Drawing View

jkorson
Enthusiast
Enthusiast

My goal is to get a iLogic rule to "Get Model Sketches" from my drawing view and to "Include" it in my view. I'm not quite sure how to do this.

 

I have looked at similar forums but I cannot manipulate the code enough for it to work. Here are the forums that I tried:

Get Model Sketches - Autodesk Community - Inventor

Include/Exclude or Visibility on/off : Model sketches in drawing views. - Autodesk Community - Inven...

 

I'm working in Inventor 2021. 

 

0 Likes
Accepted solutions (1)
4,338 Views
32 Replies
Replies (32)
Message 2 of 33

dutt.thakar
Collaborator
Collaborator

@jkorson 

 

Can you upload your file, I can try to create/modify the existing code for you to make it work for your application. I can create an example for the test, but I am not sure whether that will be the same thing you are looking for or not. If you can upload some files with the similar requirements that you are trying to achieve I could help you by creating an iLogic that will serve your purpose.

 

Hope this will help you.

If this answer has solved your problem please ACCEPT SOLUTION and hit like if you found it helpful..!


Regards,
Dutt Thakar
LinkedIn
0 Likes
Message 3 of 33

jkorson
Enthusiast
Enthusiast

I attached the documents. My rule lives in the "FAB-DRAWING.dwg" called "get model sketch".  I'm trying to show the "CUT PROFILE" sketch on my view in FAB-DRAWING.dwg file. 

 

0 Likes
Message 4 of 33

dutt.thakar
Collaborator
Collaborator
Accepted solution

@jkorson 

Can you try the below code and see if this works? Please note that the proxy is only applicable when you work with assemblies, whenever you work with part files, there is no need of proxies.

 

Dim oDrawingDoc As DrawingDocument
oDrawingDoc = ThisDoc.Document

oView = oDrawingDoc.ActiveSheet.DrawingViews(1)


Dim oPart As PartDocument
oPart = oView.ReferencedDocumentDescriptor.ReferencedDocument

Dim oPartDef As PartComponentDefinition
oPartDef = oPart.ComponentDefinition

Dim oSketch As PlanarSketch

For Each oSketch In oPartDef.Sketches
	
	If oSketch.Name = "CUT PROFILE"                ' I have explicitly added the name of sketch here
	oView.SetIncludeStatus(oSketch,True)
	oView.SetVisibility(oSketch, True)
	
	End If

Next

 

If this answer has solved your problem please ACCEPT SOLUTION and hit like if you found it helpful..!


Regards,
Dutt Thakar
LinkedIn
Message 5 of 33

jkorson
Enthusiast
Enthusiast

Thank you  @dutt.thakar for helping. I greatly appreciate it! The code preformed as expected.

0 Likes
Message 6 of 33

m.den.ouden
Advocate
Advocate

even better code

 

Public Sub IncludeSketch(oView As DrawingView, SketchName As String, Optional Include As Boolean = True, Optional Visible As Boolean = True) 
	Dim oPartDocument As PartDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument
	Dim oPartComponentDefinition As PartComponentDefinition = oPartDocument.ComponentDefinition
	Try	
		Dim oSketch As PlanarSketch = oPartComponentDefinition.Sketches.Item(SketchName)
		oView.SetIncludeStatus(oSketch, Include)
		oView.SetVisibility(oSketch, Visible)
	Catch
		MsgBox(SketchName + "Doesn't Exist")
	End Try
End Sub 

 

0 Likes
Message 7 of 33

froschhaeuserkonstruktion
Enthusiast
Enthusiast

Hello all,

 

this codes works even fine for me. But now i have the special case that i want to show a sketch from a flat pattern in the drawing view. Is that even possible?

 

With your code i get the sketch from the folded model but not from the flat pattern

 

thanks in advance

0 Likes
Message 8 of 33

m.den.ouden
Advocate
Advocate

What is it you want to achieve? And maybe you can send a file of printscreen with some notes

0 Likes
Message 9 of 33

froschhaeuserkonstruktion
Enthusiast
Enthusiast

I have to add some marks and text on the flat pattern for our manufacturer.

This marks varies from part to part.

 

For now i have some code that automatically generates a drawing view for flat pattern and exports it to dxf. So adding this sketches manualy in the drawing is not an option

0 Likes
Message 10 of 33

m.den.ouden
Advocate
Advocate

what do you want to use the marks for? do you want to create dimensions?

0 Likes
Message 11 of 33

m.den.ouden
Advocate
Advocate

You could send me the file with notes and I can program it for you.

0 Likes
Message 12 of 33

froschhaeuserkonstruktion
Enthusiast
Enthusiast

Here are the files, created in Inventor 2022

0 Likes
Message 13 of 33

froschhaeuserkonstruktion
Enthusiast
Enthusiast

thanks a lot in advance

0 Likes
Message 14 of 33

m.den.ouden
Advocate
Advocate

okay thanks. I install 2022 then upfront cause I use 2023

0 Likes
Message 15 of 33

froschhaeuserkonstruktion
Enthusiast
Enthusiast

2023 is fine for me. I got both installed so I can copy the code out of 23 to 22

0 Likes
Message 16 of 33

m.den.ouden
Advocate
Advocate

can you maybe provide me a formula to calculate the unfolded width?

mdenouden_1-1681326504717.png

 

 

0 Likes
Message 17 of 33

jkorson
Enthusiast
Enthusiast

@m.den.ouden You can go into your iLogic snippets and retrieve your flat extents width and length.  It's under the Sheet Metal folder.

0 Likes
Message 18 of 33

m.den.ouden
Advocate
Advocate

Oh that means I can retrieve it in the API it self. I'll look for it myself.

0 Likes
Message 19 of 33

m.den.ouden
Advocate
Advocate

all right that did the trick

mdenouden_0-1681327558008.png

 

0 Likes
Message 20 of 33

m.den.ouden
Advocate
Advocate

There is one big problem with the flatpattern to create dimensions a great steady simple way. In the flatpattern you can not create named geometry. I can acces the faces and edges through the API with iLogic in SheetMetalComponentDefinition.FlatPattern.Body and then assign a name. but the pop up in the unfolded section in a weird place and now I can't retrieve them in the unfolded view with this line of code.

Dim oNamedEntities = iLogicAuto.GetNamedEntities(oDoc)

So now I had to work with workpoints (or planes and axis)

 

0 Likes