I've created several representation views within an assembly. I was wanting to know when I create an .idw, is there a way to change the View Identifier to automatically bring in the names of the representations, instead of the view number. I've searched throught the Edit View Label and wasn't able to find anything within the property/type. I would like to make this change within a template, so I won't have to change this everytime.
Thanks, CJ
No there isn't an easy way..
But I'm sure someone could write you some ilogic code to edit those view labels as needed.
I went through trying to add a rule within iLogic and Representations are not even available. I guess the hard way it is, but I'll keep looking for solutions.
I hope you can find this useful, even if it is not exactly what you are looking for, because the rule finds the view rep used on the assembly in the first view on the first sheet of the drawing, and it doesn’t work with the View Label anyway.
The rule creates an iProperty called "ActiveViewrep" in the IDW (not in the assembly).
You need to add that iProperty to any drawing text, or, for instance to the titleblock.
You will see the correct result ONLY when you run the rule MANUALLY or when you save the drawing after you have added this rule to the Event trigger called "Before Save document".
Here is the rule that needs to be placed in the drawing template file.
Dim odrawdoc As DrawingDocument
odrawdoc = ThisApplication.ActiveDocument
customPropertySet = odrawdoc.PropertySets.Item("Inventor User Defined Properties")
Try
prop = customPropertySet.Item("ActiveViewrep")
Catch
customPropertySet.Add("", "ActiveViewrep")
End Try
Try
iProperties.Value("Custom", "ActiveViewrep") = odrawdoc.Sheets.Item(1).DrawingViews.Item(1).ActiveDesignViewRepresentation
Catch
End Try
InventorVb.DocumentUpdate()
Kind regards,
Alessandro
Alessandro,
I have Inv. 2010 and do not have iLogic.
How I would do this in VBA?
Mike
@Anonymous wrote:Alessandro,
I have Inv. 2010 and do not have iLogic.
How I would do this in VBA?
Mike
To be more specific, I would just want to run a VBA macro once on a sheet and not have it in a template.
I have attached the code what I have so far, but it gets stuck when trying to read the value for the ActiveDesignViewRepresentation.
Thanks!
Mike
Hi Mike,
The reason for using iLogic is that you can easily set an event trigger in order to avoid running the macro manually every time you need to create or update the custom property.
Even if you are using Inventor 2010, iLogic for this version, can be downloaded and installed from the Subscription Center, for the customers under Subscription, of course.
By the way, if you want to use the VBA macro, you can copy the text below in the Application project (default.ivb).
Sub add_viewrep_as_customprop()
On Error GoTo errorhandler
Dim odrawdoc As DrawingDocument
Set odrawdoc = ThisApplication.ActiveDocument
Call Create_prop("ActiveViewrep", odrawdoc.Sheets.Item(1).DrawingViews.Item(1).ActiveDesignViewRepresentation)
MsgBox ("Custom property called 'ActiveViewrep' has been created or updated")
Exit Sub
errorhandler:
MsgBox ("Make sure you have a drawing open and use a viewrep in the first view of the first sheet")
End Sub
Private Sub Create_prop(prop As String, prop_value As String)
Dim opropsets As PropertySets
Dim opropset As PropertySet
Dim oUserPropertySet As PropertySet
Set opropsets = ThisApplication.ActiveDocument.PropertySets
For Each opropset In opropsets
If opropset.Name = "Inventor User Defined Properties" Then Set oUserPropertySet = opropset
Next opropset
' If Property does not exist then add the new Property
On Error Resume Next
Call oUserPropertySet.Add(prop_value, prop)
' Try to set the Property value if it already exists
For i = 1 To oUserPropertySet.Count
If oUserPropertySet.Item(i).Name = prop Then oUserPropertySet.Item(i).Value = prop_value
Next i
End Sub
I hope you can find it useful.
Kind regards,
Alessandro
Hi Alessandro,
We are not on Subscription anymore, so, unfortunately I can't download iLogic.
Thanks for you assistance with VBA, I will give it a try. I don't need this consistly, so I would prefer to run this ma nually as needed.
Thanks!
Mike
Here's a rule (in the attached text file) that should set the label for all views on all sheets. But it only works on views that show a design view representation and are associative. If your drawing views are not associative, the rule can't get the design view representation name.
@MjDeck wrote:Here's a rule (in the attached text file) that should set the label for all views on all sheets. But it only works on views that show a design view representation and are associative. If your drawing views are not associative, the rule can't get the design view representation name.
Didn't work for me..?? My assembly was an iassembly.. Not sure if that matters. I placed a base view, view rep was "assy op 10". View label was turned on and associative check box is selected..view came in as "View1". Hit the add rule button, pasted all your code into it and hit ok. Set a trigger to fire that rule before save event. Nothing happened.. View is still labeled "View1"
@mcgyvr wrote:
@MjDeck wrote:Here's a rule (in the attached text file) that should set the label for all views on all sheets. But it only works on views that show a design view representation and are associative. If your drawing views are not associative, the rule can't get the design view representation name.
Didn't work for me..?? My assembly was an iassembly.. Not sure if that matters. I placed a base view, view rep was "assy op 10". View label was turned on and associative check box is selected..view came in as "View1". Hit the add rule button, pasted all your code into it and hit ok. Set a trigger to fire that rule before save event. Nothing happened.. View is still labeled "View1"
I revised my macro (with some assistance from Brian Ekins).
Paste the code into your Default.ivb and run it while in an IDW. Same requirements as above, the view must be associative.
This only changes the currently selected view.
I tried it in an iAssembly and it worked.
Mike
Here's a new version (with a bugfix) of my rule (in the attached text file) that should set the label for all views on all sheets. As before, it only works on views that show a design view representation and are associative. If your drawing views are not associative, the rule can't get the design view representation name.
I tested it on a drawing of an iAssembly in 2011, and it worked.
The VBA macro changes the view name. This rule just changes the label. It could be modified to change the view name.
For completeness sake : the fact that you only can use associative vewreps to obtain the name of the active viewrep is a know API defect and has been logged with defect number 1412877.
Thanks
bob
Hello PPL...
Why WHy Why did Autodesk MAde it so difficult to handle this DesignViewRepresention thing??????
Is there any legitimate excuse to do so???
AD.
Hi ADNPati,
While you're waiting for Autodesk to make additions to view rep functionality, give this quick video a watch, its for a new app just released on the app store to help with managing view reps. You might be interested in the last example 4m 35sec onwards
Luke
Where would I put this code within Inventor 2024 for the BeforeSave event trigger?
Hi @WP_Australind. I am not sure I understand the question...what do you mean by "when"? Do you mean how? If you meant how, then go to the Manage tab, then to the iLogic panel, and there should be a button named "Event Triggers". When you click that a dialog will pop-up with 5 tabs across the top, two areas on the left, and one large area on the right. You usually want to be on the tab named "This Document", because stuff on that tab will only effect that one document, and no others. The top area on the left has internal rules listed (rules that are saved within that document, if any), and the lower left area will contain your external iLogic rules, if any. You can drag one of those rules from the left to the right, and put it under the event named "Before Save Document". Then click the OK button. Then whenever you save that one document, it will automatically run that rule just before it saves each time.
Wesley Crihfield