shirazbj Posted January 26, 2012 Posted January 26, 2012 Hi, There is a demo code in the help file to place a bolt from the contemt center with vb.net. But I am interested in place a structural steel and can not figure out how should I specify the length. Any sample code? Thanks Cean Quote
shirazbj Posted February 1, 2012 Author Posted February 1, 2012 I was wondering how to set the length of a steel? This sample demonstrates how to place an instance of a Content Center part into an assembly. [b][color=#871f78]Sub[/color][/b] PlaceContentCenterPart() [color=#0000ff]' Set a reference to the active assembly document.[/color] [b][color=#871f78]Dim[/color][/b] oDoc [b][color=#871f78]As[/color][/b] [url="http://www.cadtutor.net/forum/Inventor__AssemblyDocument.html"]AssemblyDocument[/url] [b][color=#871f78]Set[/color][/b] oDoc = ThisApplication.ActiveDocument [color=#0000ff]' Set a reference to the ContentCenter object.[/color] [b][color=#871f78]Dim[/color][/b] oContentCenter [b][color=#871f78]As[/color][/b] [url="http://www.cadtutor.net/forum/Inventor__ContentCenter.html"]ContentCenter[/url] [b][color=#871f78]Set[/color][/b] oContentCenter = ThisApplication.[url="http://www.cadtutor.net/forum/Inventor__ContentCenter.html"]ContentCenter[/url] [color=#0000ff]' Get the content node (category) "Fasteners:Bolts:Hex Head"[/color] [b][color=#871f78]Dim[/color][/b] oContentNode [b][color=#871f78]As[/color][/b] [url="http://www.cadtutor.net/forum/Inventor__ContentTreeViewNode.html"]ContentTreeViewNode[/url] [b][color=#871f78]Set[/color][/b] oContentNode = oContentCenter.TreeViewTopNode.[url="http://www.cadtutor.net/forum/Inventor__ContentTreeViewNode__ChildNodes@[out,_retval]_ContentTreeViewNodesEnumerator__.html"]ChildNodes[/url].Item("Fasteners").[url="http://www.cadtutor.net/forum/Inventor__ContentTreeViewNode__ChildNodes@[out,_retval]_ContentTreeViewNodesEnumerator__.html"]ChildNodes[/url].Item("Bolts").[url="http://www.cadtutor.net/forum/Inventor__ContentTreeViewNode__ChildNodes@[out,_retval]_ContentTreeViewNodesEnumerator__.html"]ChildNodes[/url].Item("Hex Head") [color=#0000ff]' Get the "ISO 4015" Family object.[/color] [b][color=#871f78]Dim[/color][/b] oFamily [b][color=#871f78]As[/color][/b] [url="http://www.cadtutor.net/forum/Inventor__ContentFamily.html"]ContentFamily[/url] [b][color=#871f78]For[/color][/b] [b][color=#871f78]Each[/color][/b] oFamily [b][color=#871f78]In[/color][/b] oContentNode.Families [b][color=#871f78]If[/color][/b] oFamily.[url="http://www.cadtutor.net/forum/Inventor__ContentTreeViewNode__DisplayName@[out,_retval]_BSTR_.html"]DisplayName[/url] = "ISO 4015" [b][color=#871f78]Then[/color][/b] [b][color=#871f78]Exit[/color][/b] [b][color=#871f78]For[/color][/b] [b][color=#871f78]End[/color][/b] [b][color=#871f78]If[/color][/b] [b][color=#871f78]Next[/color][/b] [color=#0000ff]' Create a member based on the first row of the family.[/color] [b][color=#871f78]Dim[/color][/b] [b][color=#871f78]error[/color][/b] [b][color=#871f78]As[/color][/b] [url="http://www.cadtutor.net/forum/Inventor__MemberManagerErrorsEnum.html"]MemberManagerErrorsEnum[/url] [b][color=#871f78]Dim[/color][/b] strContentPartFileName [b][color=#871f78]As[/color][/b] [b][color=#871f78]String[/color][/b] [b][color=#871f78]Dim[/color][/b] strErrorMessage [b][color=#871f78]As[/color][/b] [b][color=#871f78]String[/color][/b] strContentPartFileName = oFamily.CreateMember(1, [b][color=#871f78]error[/color][/b], strErrorMessage) [b][color=#871f78]Dim[/color][/b] oMat [b][color=#871f78]As[/color][/b] [url="http://www.cadtutor.net/forum/Inventor__Matrix.html"]Matrix[/url] [b][color=#871f78]Set[/color][/b] oMat = ThisApplication.[url="http://www.cadtutor.net/forum/Inventor__TransientGeometry.html"]TransientGeometry[/url].CreateMatrix [color=#0000ff]' Insert an instance of the content center member in the assembly.[/color] [b][color=#871f78]Call[/color][/b] oDoc.[url="http://www.cadtutor.net/forum/Inventor__ComponentDefinition.html"]ComponentDefinition[/url].Occurrences.Add(strContentPartFileName, oMat) [b][color=#871F78]End Sub[/color][/b] Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.