Hi guys,
Short post today.
I have been really busy lately, trying to get together a list of best practices for tube and pipe along with Chris Benner (the guru instructor). Check his blog here.
There has been also tests on the latest version of mExtension which I hope to present shortly. It's been working on all versions but further tests need doing. like 32 and 64 bit, winxp or 7 as many inventor versions possible.
I have had long days helping out Inventor forum and especially a lengthy post on frame generator which I also hope to bring to you soon.
Meanwhile I have updated a bit the code that changes the browser name (occurrence name) which I use to tag my valves and instrumentation.
In this version, while you select parts in the graphical window you will get a prompted entry with the existing occurrence name and the new one you want in.
Here it is:
'-----------start code
Dim comp As Object
Try
While True
comp = ThisApplication.CommandManager.Pick(
SelectionFilterEnum.kAssemblyLeafOccurrenceFilter,
"Select a component")
oTagOcc = InputBox("Enter Tag No: ", "Tag Prompt", comp.Name)
comp.Name = oTagOcc
End While
Catch ' do nothing if error
End Try
' ------------ end code
Have a great day
Adrian.
Showing posts with label occurrence. Show all posts
Showing posts with label occurrence. Show all posts
Wednesday, 5 November 2014
Thursday, 23 October 2014
Browser name prompted entry
I just realized that my previous post on Part Tagging might not mean anything to you. I use the browser name as component tags but it might interest you that the code will actually rename the browser name of the parts.
So if you need to rename the occurrence name (browser name) of the parts in the assembly and you to be asked for the name of each one then use the code from here.
ADS.
So if you need to rename the occurrence name (browser name) of the parts in the assembly and you to be asked for the name of each one then use the code from here.
ADS.
Monday, 20 October 2014
Part tagging
If you have read my previous post on tagging components in the drawing you will like this one. The following code lets you select parts in the assembly and prompt for occurrence name (used as tags for our equipment).
You can select as many parts as you want and it will prompt for a new value and change it for all of them in the order you have selected them.
The dialog shows the current occurrence value and if you click cancel even after the value was changed it reverts the occurrence name to default with the first available index number.
No you can use the Component Tags Post to show them in the drawing.
Here is the code, you need to have part selection filter in the assembly first active.
' Declare current assembly
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument
' Set a reference to the assembly
component definintion.
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = oAsmDoc.ComponentDefinition
'Get the selection set
Dim selSet As SelectSet
selSet = oAsmDoc.SelectSet
'loop trough each selected part
For Each obj In selSet
oTagOcc = InputBox("Enter Tag No: ", "Tag Prompt", obj.Name)
obj.Name = oTagOcc
Next
EDIT:
I have updated the code, here's the new code:
ADS.
You can select as many parts as you want and it will prompt for a new value and change it for all of them in the order you have selected them.
The dialog shows the current occurrence value and if you click cancel even after the value was changed it reverts the occurrence name to default with the first available index number.
No you can use the Component Tags Post to show them in the drawing.
Here is the code, you need to have part selection filter in the assembly first active.
EDIT:
I have updated the code, here's the new code:
Dim comp As Object Try While True comp = ThisApplication.CommandManager.Pick( SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Select a component") oTagOcc = InputBox("Enter Tag No: ", "Tag Prompt", comp.Name) comp.Name = oTagOcc End While Catch ' do nothing if error MessageBox.Show("Tag exists or user canceled", "iLogic") End Try
END EDIT:
ADS.
Labels:
components,
drawing,
iproperties,
label,
occurrence,
tags
Thursday, 14 August 2014
Component Tags in Inventor
As you are aware if you have done
any routed systems there is no way of labeling same valve (or components for
that matter) with different names / tags / id_numbers and call it on the
drawing. You can create leader notes in the drawing but if they need changing
you need to manually do it and it’s time consuming if you have large assemblies
and multiple sheets and views. I have seen the same problem for people doing assemblies
of electric components.
A 2” ball valve can have
different identification tags in the P&ID but be a reused library component
in Inventor.
I've been searching for a
solution to this problem for the last 8 years or so and I couldn't find
anything on autodesk forums or other discussion groups.
I instinctively knew that we
would need to use the assembly browser name (occurrence name) but didn't see how
to get it to show up in the drawing.
I have got together bits of
iLogic codes from the internet that can get the assembly occurrence name and
link it to the override value of my custom style balloons.
For this I have created a new balloon
style called “Tags” and made it of type “Hexagon” with just the “Item” info in
it.
The code processes just balloons
of style “Tags” for we don’t want to change parts list balloons as well.
Because changing the occurrence
name in the assembly involves a lot of steps (find component in browser / edit
parent subassembly / change name of component / activate top level again) it is
better to do it from the drawing.
You need to use “balloon”
command, because “auto-balloon” cannot label same component on different views
more than once.
Place balloons as you would
normally do using “balloon” command and override the field with your text. You
only need to do it once per component then run the code
When running the code it will
prompt you if you want to set names from the balloons or from the browser.
Choose balloon to send the override value to the model browser (occurrence
name).
Continue placing balloons on all
views and then run the code again. Choose to set the value from the browser to
get the value on all new balloons.
This way I can balloon same component multiple times on same view if wanted.
As you can see the Occurrence name in browser and iproperties changed but the part number, stock number and other properties didn't changed.
Here's the code with explanatory comments:
' Set a reference to the drawing document.
Best of luck
ADS.
This way I can balloon same component multiple times on same view if wanted.
As you can see the Occurrence name in browser and iproperties changed but the part number, stock number and other properties didn't changed.
' Set a reference to the drawing document.
' This assumes a drawing document is
active.
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
' Set Reference to Active Sheet
Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet
'get the name and path of the first
model in the drawing
oAsmName = ThisDrawing.ModelDocument.FullFileName
' Set Reference to the Assembly and Open
Silently
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.Documents.Open(oAsmName, False)
' Set a reference to the assembly
component definintion.
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = oAsmDoc.ComponentDefinition
Dim oBalloon As Balloon
'Ask the user if he wants to set the
component name from browser
'or if he wants to set the browser name
from overwritten balloon value
booleanParam = InputRadioBox("Set name from?: ", "Browser", "Balloon", True, Title :="Read/Write")
'Start a counter for sheets to process
Dim SheetCount As Long
SheetCount = 1
Dim oSheets As Sheet
'step through each drawing sheet
For Each oSheets In oDrawDoc.Sheets
'
Iterate over each balloon on the sheet.
For Each oBalloon In oSheet.Balloons
Dim leader As Leader
Leader = oBalloon.Leader
'assuming
the leader is a single line segment
Dim leaderNode As LeaderNode = leader.AllNodes(2)
Dim intent As GeometryIntent
intent = leaderNode.AttachedEntity
Dim curve As DrawingCurve
curve = intent.Geometry
Dim edgePx As EdgeProxy
edgePx= curve.ModelGeometry
Dim occurrencedrg As ComponentOccurrence
occurrencedrg = edgePx.ContainingOccurrence
Dim oBalloonValueSet As BalloonValueSet
'
Iterate over each value set (attached balloons) in a balloon.
For Each oBalloonValueSet In oBalloon.BalloonValueSets
'only process if balloon of style of type "Tags"
If oBalloon.Style.Name = "Tags" Then
'if user wants to get name from browser
If booleanParam = True Then
' Set balloon value from browser.
oBalloonValueSet.OverrideValue = occurrencedrg.Name
'if user wants to set browser name from
balloon
ElseIf booleanParam = False Then
' Set browser name from balloon override
value.
occurrencedrg.Name = oBalloonValueSet.OverrideValue
End If
End If
Next
Next
'Increase sheet counter
SheetCount = SheetCount +1
Next
Subscribe to:
Posts (Atom)
















