- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
VBA: insert content center pipe with custom length
He guys and girls.
2 questions in this post.
1)
I have been reading alot but nothing realy helps my problem.
We have in our firm our pipes wich are in the content centre. The pipes are selectable with fixed diameters, and length can be anything.
See screenshot.
I use : family.CreateMember(4, failureReason, failureMessage, kRefreshOutOfDateParts, False)
wich in this case row 4 is Ø80, to insert the pipe later on.
My question is how do I specify the Length parameter?
My goal is to have the parts be standard content centre parts. A coworker has made this macro and inserts the pipe as a custom part, and then changes the custom property to the value measured before.
2)
But I would still like to be able to use the content centre "change size" command afterwards if needed.
Wich is my second question because I can't find anything about that. Once the pipe is placed I would like to be able to measure again and have the pipe change automaticly. Not replace with a new custom part but in the same way the content centre does.
I have no idea what the command is in VBA.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi. Trying to learn to fish for a day, I see!
Here's how you learn to fish for a lifetime:
1. Go/Find the file below on your computer.
"C:\Program Files\Autodesk\Inventor 2016\Local Help\admapi_20_0.chm"
2. Open it, to the index tab.
3. Search for "Content Center"
4. Navigate through the tree until you find your answer.
I found it in all of 10 seconds.
Good luck!
--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization
iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread
Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects
Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help
Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Wow you must be like really smart because I have been looking for the answer for 3 days and couldn't find it.
I'm just a simple Inventor user making his own macro's from tutorials I find online and need some help because I obviously missed something in trying to educate myself.
But what I lack in brains I make up in good manners.
Thank you very much for the push in the correct direction.
Ow, and I don't understand a single thing about the fishing. Must be my low IQ again, sorry.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Nice manners. They go well with that snarky attitude.
Step 2: "What is a NameValueMap?"
SO.
Something like this will be the name value map. (I'm writing this in vb.net, whereas almost all of the samples use vba, and vb.net is what is used in the rule environment)
oSomeCustomLength = "24 in"
Dim oNVM As NameValueMap
oNVM = ThisApplication.TransientObjects.CreateNameValueMap
oNVM.Value("LengthParamColumnNameFromContentCenterEditor") = oSomeCustomLength
To finish off, insert it back into the CreateFamilyMember line as the optional parameter that it is.
--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization
iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread
Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects
Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help
Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
This github library makes it easy to work with content center and assemblies
https://github.com/HYMMA/InventorToolBox
//connect to inventor
var app = App.Start();
//generate file name
var partName = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments), "PartFileName.ipt");
var assyName =System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments), "AssemblyFileName.iam");
PartDocument part;
AssemblyDocument assembly;
//make a new part document or open it if already exists
try
{
part = app.NewPart(partName);
}
catch (Exception)
{
part = app.Open(partName, false) as PartDocument;
}
//make a new assembly document or open it if already exists
try
{
assembly = app.NewAssembly(assyName);
}
catch (Exception)
{
assembly = app.Open(assyName) as AssemblyDocument;
}
//set the part number proprety of the part
part.AsDocument().SetProperty(kDocumnetProperty.PartNumber, "S/S6758");
//add the part that was created to the assembly
var partOccurance = assembly.AddMemeber(part.AsDocument(), new[] { 0d, 0d, 1d }, new[] { 10d, 10d, 0d });
var contentCenterDesc = new ContentCenterItemDescriptor(row: 3, "Structural Shapes", "Angles", "BS 4848"){ CustomValue = new KeyValuePair<string, object>("B_L", 658) };
var contentCenterOccurance = assembly.AddMemeber(contentCenterDesc, new[] { 0d, 0d, 1d }, new[] { 10d, 10d, 0d });