Body orientation

Body orientation

NachoShaw
Advisor Advisor
507 Views
7 Replies
Message 1 of 8

Body orientation

NachoShaw
Advisor
Advisor

Hey

 

Could anyone help me out real quick? I need to do 3 things in a multi part body

 

1. Get the body orientation (whether its landscape or portrait)

2. check which side of the body is outside

3. add a 3D annotation to center of the outside line (i can do this)

 

Cant seem to work out the orientation. For the side, i could check it against the overall rangebox

 

frame.jpg

 

Thanks

 

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
508 Views
7 Replies
Replies (7)
Message 2 of 8

WCrihfield
Mentor
Mentor

For checking orientation, maybe you can check the bodies RangeBox data to see if it is wider (along the X direction) than it is tall (along the Y direction) (if those are the correct 2 out of the 3 directions) , and if so, it is landscape, if not it is portrait.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 8

WCrihfield
Mentor
Mentor

Also maybe you can use the SurfaceBody.FindUsingRay() method (maybe 4 times), and define the ray as starting from a central location (if possible) then towards each of the 4 cardinal directions.  The last object returned in the collection should be the outer wall of the SurfaceBody where you want to attach your 3D annotation.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 8

WCrihfield
Mentor
Mentor

The PartComponentDefinition also has similar methods, like FindUsingRay() and FindUsingVector(), that may be a better choice.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 8

NachoShaw
Advisor
Advisor

Hi @WCrihfield 

 

i had tried that but was getting weird results but it now looks like i had the code typed up wrong...

 

Thanks for the reply 🙂

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
Message 6 of 8

NachoShaw
Advisor
Advisor

Hey

 

Thanks for the replies. It seems the operation isnt going to work anyway, i cannot find a way to code a 3D annotation in a part or assembly so i'll need a plan C now.. I can access, change text, delete 3D annotation but not add..

 

Thanks though, some good methods for other items on my list

 

 

Nacho

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
Message 7 of 8

WCrihfield
Mentor
Mentor

I'm not 100% sure if creating model annotations in assemblies through the API is fully supported yet, like it is for parts.  The 2021 Object Model only had the ModelAnnotations object shown under the PartComponentDefinition, and not under the AssemblyComponentDefinition, but I do see now that there is an online help page for it under the assembly definition.

 

It's definitely a lot more complicated than just adding a general note to a drawing sheet, but it can be done with some practice.  I haven't done a ton of it myself by code yet, but I threw together the basics in an iLogic rule for you, just in case you may still be interested in going that 3D annotations route down the road.  I only went into creating either a leader note or a general note, but there are several others.

Dim oPDoc As PartDocument = ThisDoc.Document
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
Dim oMAs As ModelAnnotations = oPDef.ModelAnnotations
Dim oFText As String 'FormattedText you want the note to show

'for a leader note
'define a plane for the leader note to reside on in 3D space
'oPlane = '(Planar Face or WorkPlane) 
'oXAxisDirection = '(linear edge, work axis, or 2D sketch line) (not required)
Dim oAPlane As AnnotationPlaneDefinition = oMAs.CreateAnnotationPlaneDefinitionUsingPlane(oPlane, oXAxisDirection)
Dim oLeaderPoints As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
'oLeaderPoints.Add() 'add points to the collection for the leader
Dim oMLNDef As ModelLeaderNoteDefinition = oMAs.ModelLeaderNotes.CreateDefinition(oLeaderPoints, oFText, oAPlane)
Dim oMLN As ModelLeaderNote = oMAs.ModelLeaderNotes.Add(oMLNDef)

'for a general note
Dim oMGNDef As ModelGeneralNoteDefinition = oMAs.ModelGeneralNotes.CreateDefinition(oFText, True, ScreenQuadrantEnum.kLowerLeftQuadrant)
Dim oMGN As ModelGeneralNote = oMAs.ModelGeneralNotes.Add(oMGNDef)

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 8 of 8

NachoShaw
Advisor
Advisor

Hey @WCrihfield 

 

very much appreciated. I can get by using this at Part level. My intention for documentation is to have a multi body part with a model state for each variation of parts in the assembly and place them by model state. each body in the multi body will have a 3D annotation showing the name so that it can be pulled into a drawing and retrieved.

 

I originally wanted to pull the part level annotation through an assembly in a drawing document but its not supported, that would have been great for patterned elements to show the callout in a drawing. Then i thought about doing it at assembly level but its not supported yet so as of right now, i would need to loop the bodies in the multi body part and add the annotation there to each body and use that directly in the drawing for identifying its location etc.

 

Until such time as the API gets to support assemblies, this should work for me.

 

 

Much appreciated

 

 

Nacho

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes