Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Representation View

16 REPLIES 16
Reply
Message 1 of 17
cjackson9613
1904 Views, 16 Replies

Representation View

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

16 REPLIES 16
Message 2 of 17
mcgyvr
in reply to: cjackson9613

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.



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
Message 3 of 17
cjackson9613
in reply to: mcgyvr

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.

Message 4 of 17

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 Gasso
Fusion 360 – Simulation/Generative Design Adoption Specialist
Autodesk, Inc.
Message 5 of 17
Anonymous
in reply to: alessandro.gasso

Alessandro,

I have Inv. 2010 and do not have iLogic.

How I would do this in VBA?

 

Mike

Message 6 of 17
Anonymous
in reply to: Anonymous


@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


 

Message 7 of 17
alessandro.gasso
in reply to: Anonymous

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.

 

trigger.png

 

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



Alessandro Gasso
Fusion 360 – Simulation/Generative Design Adoption Specialist
Autodesk, Inc.
Message 8 of 17
Anonymous
in reply to: alessandro.gasso

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

 

 

Message 9 of 17
MjDeck
in reply to: cjackson9613

 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.

 


Mike Deck
Software Developer
Autodesk, Inc.

Message 10 of 17
mcgyvr
in reply to: MjDeck


@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"



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
Message 11 of 17
Anonymous
in reply to: mcgyvr


@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

Message 12 of 17
MjDeck
in reply to: Anonymous

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.


Mike Deck
Software Developer
Autodesk, Inc.

Message 13 of 17
bobvdd
in reply to: MjDeck

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




Bob Van der Donck


Principal UX designer DMG group
Message 14 of 17
Anonymous
in reply to: bobvdd

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.

 

 

Message 15 of 17
LukeDavenport
in reply to: Anonymous

 

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

 

http://youtu.be/qem8o-R2mqQ

 

Luke

 

 

Message 16 of 17

@alessandro.gasso 

 

Where would I put this code within Inventor 2024 for the BeforeSave event trigger?

iLogic.png

Message 17 of 17
WCrihfield
in reply to: WP_Australind

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

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report