iLogic Get Model Sketches to Drawing View

iLogic Get Model Sketches to Drawing View

jkorson
Enthusiast Enthusiast
4,341 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,342 Views
32 Replies
Replies (32)
Message 21 of 33

m.den.ouden
Advocate
Advocate

@froschhaeuserkonstruktion I'm done, what is your email so I can explain the code. Cause there are 1000s of lines of code. everything goes automatic in my company so most functions I've already written. This was a new challenge  though so I've written some new functions. Let me know 

0 Likes
Message 22 of 33

jkorson
Enthusiast
Enthusiast

You can use attribute helper to label faces, edges, and points of a part in a flat pattern environment. The attribute helper is installed when you install usertool.msi under this file path. C:\Users\Public\Documents\Autodesk\Inventor 2023\SDK\UserTools\

 

Once the MSI is installed the Attribute helper is under the tools tab in Inventor.

This two videos below will help you get started with using the attribute helper.

Autodesk Inventor iLogic Drawing Dimension Automation - YouTube

Automating Dimensions on Drawings | Autodesk Virtual Academy - YouTube

0 Likes
Message 23 of 33

m.den.ouden
Advocate
Advocate

Oh that is true. I totally forgot about attributes. I'll write some new extra code. 

0 Likes
Message 24 of 33

froschhaeuserkonstruktion
Enthusiast
Enthusiast
Please sent it to kontakt(at)froschhaeuser-kinstruktion.de
0 Likes
Message 25 of 33

WCrihfield
Mentor
Mentor

FYI:  The 'FlatPattern' object in a sheet metal part is actually its own different ComponentDefinition, and is actually derived from the ComponentDefinition Class, but with some of its own unique methods/properties, with its own set of Parameters, Features, Sketches, Body, etc.  Those Parameters that you create within the FlatPattern.Parameters are not accessible from the parent PartDocument.ComponentDefinition.Parameters, and some of the other properties of the FlatPattern are a similar situation.

 

If you need to assign a name to pretty much any type of object within Inventor, so you can find it again later, all you need to do is use that object's 'AttributeSets' property, because almost everything has that property.  That is what the built-in iLogic 'NamedEntities' Interface system uses, but that system only works in the normal or sheet metal Part environment right now, not in an assembly, and not in FlatPattern editing mode.  You can somewhat easily create your own very similar system of identifying things using different names for the AttributeSet and/or Attribute that you place on the objects, without using that iLogic NamedEntities Interface.  But if you do go the non-standard way, you would generally have to do some things the harder/longer way on the drawing side, because some of those popular iLogic shortcut snippets may not automatically recognize the entity names.  You would have to use the alternative API code process instead (Document.AttributeManager and its tools) for finding the named objects according to your own naming conventions.  That type of identification system dates back at least a decade, long before the iLogic NamedEntities system or its associated user interface tools were introduced (back around 2019 version).  As you mentioned though, you would have to apply those names to the entities retrieved from the FlatPattern.Body and its associated geometries to be able to identify those in the flat pattern view in a drawing by code.  There is almost always more than one way to do things in Inventor.

 

As for including that sketch from within the FlatPattern into the DrawingView of the flat pattern.  That is a tough one.  You can definately get a reference to that sketch by code, but the DrawingView.SetIncludeStatus method seems to throw an error when you try to use that for this purpose.  I had originally attempted to do this by using the actual command for it, but that was not working as planned either.  The command name is "DrawingGetModelSketchesCtxCmd".  I attempted to get the BrowserNode of either the view or the model or the flat pattern under the view in the Document.SelectSet, then execute that command, but that was not working for me either, interestingly enough.  Good luck with that.

 

Edit:  Sorry, I did not see page 2 of this forum post before posting this response.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 26 of 33

m.den.ouden
Advocate
Advocate

mdenouden_0-1681422533914.png

@froschhaeuserkonstruktion email address is unreachable. Other email maybe?

0 Likes
Message 27 of 33

m.den.ouden
Advocate
Advocate

@WCrihfield Getting the sketch is not hard at all. 

Public Sub IncludeSketchFlatPattern(oView As DrawingView, SketchName As String, Optional Include As Boolean = True, Optional Visible As Boolean = True) 
		Dim oPartDocument As PartDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument
		Dim oComponentDefinition As Inventor.SheetMetalComponentDefinition = oPartDocument.ComponentDefinition
		Try	
			Dim oSketch As PlanarSketch = oComponentDefinition.FlatPattern.Sketches.Item(SketchName)
			oView.SetIncludeStatus(oSketch, Include)
			oView.SetVisibility(oSketch, Visible)
		Catch
		End Try
	End Sub 

There you go

 

I already modified my functions for adding dimensions. its all very smooth and it can be applied through workfeatures, NamedGeometry or Attributes. In the part area I wrote all the different functions to apply a dimension in a certain way. And in the drawing function  it is just oneFunction that handles all the dimensions on each view.

 

0 Likes
Message 28 of 33

froschhaeuserkonstruktion
Enthusiast
Enthusiast
Sorry, I forgot a "-"
It is Kontakt@froschhaeuser-konstruktion.de
0 Likes
Message 29 of 33

m.den.ouden
Advocate
Advocate

@froschhaeuserkonstruktion I can not send the email for some reason. Maybe you have a different mail address?

0 Likes
Message 30 of 33

WCrihfield
Mentor
Mentor

OK, good to hear you got it all worked out.  After downloading and opening those files from message 12, I got the Sketch from the view's referenced part's FlatPattern just fine, but for some reason when I tried using the DrawingView.SetIncludeStatus method to include it in the view, it caused an error, stopping the rule.  I was not trying to use the SetVisibility method after that either.  Maybe it was just a version related issue (using 2022.4.1), or an unnoticed variable name typo at the time, due to typing to quickly.  I only quickly tried a couple times due to lots of other stuff going on at the time.  🙄

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 31 of 33

m.den.ouden
Advocate
Advocate

@froschhaeuserkonstruktion maybe you can send me an email m.den.ouden@twentebelt.com

drawing is done totally with code. It builds itself up from scratch. 

 

mdenouden_0-1681488412874.png

mdenouden_1-1681488448837.png

 

 

0 Likes
Message 32 of 33

vishnuteja_srikanti
Participant
Participant

HI 

I am in need of get model sketch option so i used this code it includes the model sketch but not at the part location 

 

acutally i am taking base view of assembly in which i want to get model sketches of individual components at there respective location is there any idea how to do it 

0 Likes
Message 33 of 33

WCrihfield
Mentor
Mentor

Hi @vishnuteja_srikanti.  What you are asking for is pretty complicated to make happen by code, and very complicated to explain how to do it, and all the steps involved.  Drawings were designed to document one model document, and that one model document is the one being directly referenced through its views.  When folks include views of multiple different model documents in different view within the same drawing things start getting much more complicated.  Pretty much all the tools in the drawing environment are designed to either work directly with things in the drawing, or the one model document that is being directly referenced within its views.  So, when the views are of an assembly, but you want to include stuff that was 'defined' down within sub components of the assembly, you must dig down into the definitions of the sub components to find the original objects/geometry, then get the 'Proxy's' of those objects/geometry that exists in the context (definition & 3D coordinate space) of the next higher level of the assembly, until the proxy's are in the context of the assembly that is being directly referenced in the views.  Then you can provide those proxy objects to those methods of the views, to make those proxies visible in those views.  If the original geometry was created/defined within the definition of a part, and that part was placed into a sub assembly, then that sub assembly was placed into the main assembly, then a view of that main assembly was placed in the drawing...then there will be multiple levels of proxies involved.  Proxies of the part will exist in the context of the sub assembly, then proxies of those proxies will be in the context of the main assembly.  In order to get a reference to those top level proxies, you have to start from the original geometry, within the definition of the part, then get the proxy in the sub assembly, then get the proxy of that proxy that exists in the main assembly, then supply that to the method of the drawing view to get it included in the drawing view.  That can potentially take a lot of complex code to accomplish...and without having the original file set to test with, may be nearly impossible for someone else to remotely write the code for.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes