Select part in drawing and make new view

Select part in drawing and make new view

inventor4578
Advocate Advocate
768 Views
5 Replies
Message 1 of 6

Select part in drawing and make new view

inventor4578
Advocate
Advocate

Hi,

I looking for a way to select a part in drawing view (Drawing view from assembly) and make a new view of this selected part, in the same drawing.

 

I found this code to select occurence, but i have no success with the creation of the new view.

 

Select part in assembly : https://clintbrown.co.uk/2020/10/03/ilogic-occurrence-selection-filter-in-drawings/

Create new view : https://adndevblog.typepad.com/manufacturing/2012/06/creating-a-drawing-from-scratch-with-the-invent...

 

Thank you,

Regards,

 

0 Likes
769 Views
5 Replies
Replies (5)
Message 2 of 6

WCrihfield
Mentor
Mentor

Hi @inventor4578.  Attached is a text file you can try out as an iLogic rule.  It uses similar techniques as the articles you mentioned.  DrawingView creation involves a lot of input variables though, so I will let you customize those options as you see fit.  Also, keep in mind that this is specifically for picking geometry within a DrawingView of an assembly, there are slightly different (or longer) versions for if it is a view of a part (or both).

 

Edit:  I made some edits to the attached text file, to write more diagnostic type feedback to the iLogic Logger, just in case you have problems using it.  There is a lot of potential for things to not work out correctly, and it is nice to know where along the code's path it is encountering issues, when they arise.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 6

inventor4578
Advocate
Advocate

Hi, thank you for reply.

 

I tested the code (Inventor 2022), i can pick a curve of one part in assembly view, but nothing happen after.

 

Regards,

0 Likes
Message 4 of 6

inventor4578
Advocate
Advocate

INFO| 5: >>---------------------------
INFO|TypeName(oBody.Parent) = PartComponentDefinition
INFO|dScale = 0,01
INFO|oVO.ToString = kDefaultViewOrientation
INFO|oDVS.ToString = kHiddenLineRemovedDrawingViewStyle

 

But no new view

0 Likes
Message 5 of 6

WCrihfield
Mentor
Mentor

Hi @inventor4578.  I am sorry to hear that the code I posted is not working as planned for you.  I tested it several times on different assembly drawings, and it worked every time for me.  The new view of the selected part is placed at the lower left corner of the active sheet, and is often pretty small, due to using the same scale as the view of the main assembly.  One of the biggest challenges of this task is that the DrawingCurve.ModelGeometry property just returns a single generic Object type value, and even that could be Nothing, if the model was not available.  When 'something' is actually returned, some code has to be used to figure out what type of object it is first, before it can move forward.  Then there must be an entire block of code just for each potential type of object that it might be, because every type of object has different properties, and the code needs to use those properties to find its way up the Inventor API object model to a Document from that object.  That path of code needs to be different for each type of object.  The most common 2 types of objects that a DrawingCurve.ModelGeometry might return are either an Edge, or an EdgeProxy, so those are the only 2 types of objects that my code example tests for right now.  It could also return things like geometry belonging to model sketches, or model work features, if you have included any of that type of stuff in your view.  If you do, then the code would need to be expanded to include testing for those types of objects, then also be expanded more to include blocks of code which are specific to those individual types of objects which try to get to a parent Document object from them.  Those types of expansions could be added with more time and effort invested into this project.

 

From the Logger entries that you posted, it looks to me like the 'model' document was returned, and it did attempt to make a view so it did find either an Edge or EdgeProxy.  Did it throw an error when it tried to create the view?  One requirement for making a new view in a drawing is that the 'model' that the new view is to reference must be open first (not necessarily visibly open, just open).  And generally, all documents being referenced by the drawing should already be open (automatically, in the background, not necessarily visible).  Maybe of that model was suppressed or something like that, it would not be open, but I don't know how you would be able to select something that was suppressed.  Are you sure it is not actually adding a view, because it might possibly be tiny, depending on the parts size and the scale of the view, and down near the lower left corner of the sheet (may be outside of the border)?

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 6 of 6

inventor4578
Advocate
Advocate

Hi, thank you very much for the reply !

 

I tested again on another assembly, now it work, but on some parts i have to select the "interior" edge of the parts. On some part it work on all edge

 

Have nice day and thank you again.

 

 

 

0 Likes