Preview of placement from content center

Preview of placement from content center

JhoelForshav
Mentor Mentor
743 Views
7 Replies
Message 1 of 8

Preview of placement from content center

JhoelForshav
Mentor
Mentor

Hi,

I'm trying to achieve the same type of preview of a placed structural shape as the frame generator. In order to do this I'm trying to figure out how this is accomplished by the frame generator. I'm thinking it must be done with InteractionGraphics but I have no clue how the profile is obtained.

Does anybody here know?

 

I dont believe it's done with ComponentGraphics but i might be wrong? It seems as if I have to create the component from content center and save it to some temporary location before ComponentGraphics can be used.

Therefore my best guess is that this is build up with LineGraphics. In order to do this however I'll have to get the structural shapes profile somehow from content center via API. Please let me know if you know how to do this 🙂

 

CC preview.PNG

Thanks in advance!

0 Likes
Accepted solutions (1)
744 Views
7 Replies
Replies (7)
Message 2 of 8

YuhanZhang
Autodesk
Autodesk

Can you tell where is your structural shape data stored in? On local or a library?



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 3 of 8

JhoelForshav
Mentor
Mentor

Hi @YuhanZhang,

Isn't the content center always a library?

 

I've been able to get the Component Definition of the family template like this:

Function GetProfile() As PartComponentDefinition
        Dim oContentCenter As ContentCenter
        oContentCenter = ThisApplication.ContentCenter
        Dim oContentNode As ContentTreeViewNode
        oContentNode = oContentCenter.TreeViewTopNode.ChildNodes.Item("Structural Shapes")
        Dim oChannelsNode As ContentTreeViewNode = oContentNode.ChildNodes.Item("Channels")
        Dim oFamily As ContentFamily
        oFamily = GetFamily(oChannelsNode, "UPE-balk")
        Dim ProfileDoc As PartDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kPartDocumentObject, oFamily.TemplateFileName, False)
        Dim ProfileDefinition As PartComponentDefinition
        ProfileDefinition = ProfileDoc.ComponentDefinition
        Return ProfileDefinition
        ProfileDoc.Close(True)
    End Function
    Function GetFamily(oNode As ContentTreeViewNode, oName As String) As ContentFamily
        For Each oFam As ContentFamily In oNode.Families
            If oFam.DisplayName = oName Then
                Return oFam
                Exit Function
            End If
        Next
        Return Nothing
    End Function

This ComponentDefinition can then be used to create a ComponentGraphics object. However i would like to be able to get the profile of a specific row in the content family and then be able to use that profile to create a preview of the frame member with a length of my choosing. Im thinking it might be done by getting the lines and curves of the profile sketch and then add lines with my desired length from all start/end points of these ,normal to the sketchplane. Then finally add the profile to the end of these lines aswell.

I feel like it should be doable by adding LineGraphics etc to a GraphicsNode even though it'll most certainly be a bit difficult.

 

I'm basically trying to copy the preview behavior of frame generator and this is my best guess of how it's done. If you know how to retrieve the sketch geometry of a specific row from content center, or if you have a better idea of how to create this preview alltogether it would be very much appreciated 🙂

Message 4 of 8

YuhanZhang
Autodesk
Autodesk
Accepted solution

Hi Jhoel,

 

So what you now need is to get a document for a specified table row in the content family, and then you can create your own ComponentGraphics with it. Below is VBA code sample telling how to get the document for a row:

 

Sub GetProfile()
        Dim oContentCenter As ContentCenter
        Set oContentCenter = ThisApplication.ContentCenter
        
        Dim oContentNode As ContentTreeViewNode
        Set oContentNode = oContentCenter.TreeViewTopNode.ChildNodes.Item("Structural Shapes")
        
        Dim oChannelsNode As ContentTreeViewNode
        Set oChannelsNode = oContentNode.ChildNodes.Item("Channels")
        
        Dim oFamily As ContentFamily
        Set oFamily = GetFamily(oChannelsNode, "ANSI MC/C")
        
        Dim oRow As ContentTableRow
        Set oRow = oFamily.TableRows(1)
        Debug.Print oRow.InternalName
        
        Dim lVal As MemberManagerErrorsEnum
        Dim sErrorMessage As String, sFile As String
        sFile = oFamily.CreateMember(oRow, lVal, sErrorMessage)
        
        Dim ProfileDoc As PartDocument
        Set ProfileDoc = ThisApplication.Documents.Open(sFile, False)
        
        Dim ProfileDefinition As PartComponentDefinition
        Set ProfileDefinition = ProfileDoc.ComponentDefinition
        
        ' You can create your ComponentGraphics bases on the document from here.
        ' TODO...
        
        ProfileDoc.Close (True)
End Sub
    

    Function GetFamily(oNode As ContentTreeViewNode, oName As String) As ContentFamily
        Dim oFam As ContentFamily
        For Each oFam In oNode.Families
            If oFam.DisplayName = oName Then
                 Set GetFamily = oFam
                Exit Function
            End If
        Next
    End Function

Hope this helps.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 5 of 8

JhoelForshav
Mentor
Mentor

Hi @YuhanZhang 

 

I've attached a screencast to give some context to my problem.

 

I've actually tried this way out before more or less. My problem is that i would like to be able to dynamically change the length of the preview so i thought that i must build it up with line/curve graphics instead. What i want to do is calculate the length to intersection with another frame member and use that to set the length of the preview (of course if no intersection is found the preview shouldn't be visible or maybe show a fixed length...)

It seems as if i do it this way i cant change the length once the interactiongraphics is defined.

 

I think I'll just make the preview of position and rotation into an arrow instead and then add a "preview button" that shows a static preciew of the frame member, as componentgraphics, when clicked.

 

Since your reply answears my question to some extent i will accept it as solution because it probably will be helpful to others who end up in this thread while searching for information about simular problems.

 

If you have any idea of how to create a preview of the frame member with dynamic length I would of course appreciate it. If not I'll just carry on as described above.

 

Thank you for your time! 🙂

 

 

Message 6 of 8

YuhanZhang
Autodesk
Autodesk

Seems you want to get a profile from the CC(content center) library, and then create a extrusion preview from the profile and transform it, is that right? This should be doable, as you already get the template from library, and you can get its profile and then you can calculate(bases on the profile and length) what the shape should be looking like, and then create the graphics for it. You can allow users to specify the length and you re-define the shape and update it in your interaction events.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 7 of 8

JhoelForshav
Mentor
Mentor

Yes, that's exactly what I want to do 🙂

Should i get the Profile object of the ExtrudeFeature with name "Body" in the templatefile or is it the sketch i should use (Profile.Parent)?

 

Then i must somehow manage to identify and edit parameters for the profile according to a specific row in the family. Do you know how to do this?

 

Also do you have any sample code or something like that for creating an extrudepreview that you can share?

 

Thank you for all your help!

Message 8 of 8

Stakin
Collaborator
Collaborator

Hi,JhoelForshav:

I want to Know how to automatically chamfer both ends of content center parts?

I want to make the frame of component center part,but be stuck here.

Please give me some advice,thank you very mach.

regards.

0 Likes