VBA with frame generator

VBA with frame generator

Anonymous
Not applicable
1,083 Views
1 Reply
Message 1 of 2

VBA with frame generator

Anonymous
Not applicable

Is there anyone who can advise me or give me a sample about this?

I'm trying to build a code to model some structure like truss with VBA also frame generator...

Please tell me where I should start...

Please...

 

0 Likes
1,084 Views
1 Reply
Reply (1)
Message 2 of 2

Vladimir.Ananyev
Alumni
Alumni

Thanks to my colleague Xiaodong for the following detailed answer:

 

Unfortunately, no API for Frame Generator (FG). FG is also developed with Inventor API. If you want to manage the whole process and every detail, you will have to write your own process of FG.   But, looking at further on the behaviors of FG, you would find actually you could implement yourself, though not exact as Inventor does.

E.g.

1)  Insert. The component of FG is actually part of Content Center (CC). Inventor API can place CC part. In the API help reference, there is one sample PlaceContentCenterPart. And API also allows you to browser the CC and get which one you need to use.  In addition, you will need to provide the geometries for placement (e.g. we would select one edge of the model and align the FG part with the edge). This is also doable by creating an appropriate matrix when you place the CC part.

The only issue is: if you place the part from CC, the browser pane will not indicate it is a FG like Inventor does.

2)  Replace: This is very straightforward by ComponentOccurrence.Replace.  there is one sample  ReplaceContentCenterPart in the API help reference. 

3)  Extend/Trim. I do not think of a good way. you may need to create the SplitFeature. 

4)  to draw the skeleton curves, you could use Client Graphics. 

5)  Perhaps, you also want to rename the FG part while inserting.

The following is a code snippet which may help you.

Class1 code: 

Option Explicit 

Private WithEvents fileUIEvts As FileUIEvents 

Private Sub Class_Initialize() 
   Set fileUIEvts = ThisApplication.FileUIEvents 
End Sub 

Private Sub Class_Terminate() 
   Set fileUIEvts = Nothing 
End Sub 

Private Sub fileUIEvts_OnPopulateFileMetadata( _
ByVal FileMetadataObjects As ObjectsEnumerator, _
ByVal Formulae As String, _
ByVal Context As NameValueMap, _
HandlingCode As HandlingCodeEnum) 
   Dim oMetaData As FileMetadata 
   If FileMetadataObjects.Count > 0 Then 
     For Each oMetaData In FileMetadataObjects 
       oMetaData.FileName = "xxx_" & oMetaData.FileName 
       oMetaData.FileNameOverridden = True 
     Next oMetaData 
     HandlingCode = kEventHandled 
   End If 
End Sub 


Module code: 

Private cls As Class1 

Sub startcmd() 
  Set cls = New Class1 
End Sub 

Sub Endcmd() 
  Set cls = Nothing 
End Sub 

 Best Regards,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network