Place all design views on an idw

Place all design views on an idw

dan_inv09
Advisor Advisor
2,493 Views
13 Replies
Message 1 of 14

Place all design views on an idw

dan_inv09
Advisor
Advisor

I need to find a good book or a class or something to learn iLogic. I really don't even know how to start something. I've copied and pasted from other peoples stuff, but it's mostly blind luck if it works.

 

I have an assembly, it has a design view for each part which only shows that part. I want to place a view in my idw of each design view.

 

I don't need then spaced out or anything, I can position them myself later - they can all be stacked one on top of the other in the bottom corner or wherever. While I don't need the master view and maybe one or two other views that may have been created in the assembly getting rid of them manually is not a problem.

 

I've found things for doing stuff to drawing views, but I can't seem to find how to create one.

 

(And then I've got to figure out how to find all the assembly views and go through them one by one.)

 

Could anybody here help get me going in the right direction?

0 Likes
2,494 Views
13 Replies
Replies (13)
Message 2 of 14

mcgyvr
Consultant
Consultant

Out of curiosity..

How many times do you need to make drawings like this and how long would it take you to simply manually place each view?

 

And what are you doing? I'm so wondering what you are doing to have a need for an assembly with a view rep of each and every individual part and then need to put them all on a drawing

 



-------------------------------------------------------------------------------------------
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
0 Likes
Message 3 of 14

dan_inv09
Advisor
Advisor

For each big weldment we do, so maybe once every two to five weeks or so.

 

The average weldment has 20-30 pieces.

And time is only part of the concern, "Did I do the the upper outboard gusset already? Why do I have two of the left wall?!?" etc.

 

Because each piece is placed on the drawing from the assembly the balloons match up to the assembly drawing.

 

I'm not converting it to a Weldment - if you think this would be easier to do with preparations, I'm listening, but it's a basically cut list so if I had any preparation features I wouldn't want to show them anyway.

0 Likes
Message 4 of 14

Curtis_Waguespack
Consultant
Consultant

Hi dan_inv09,

 

This might get you started:

http://forums.autodesk.com/t5/inventor-customization/ilogic-opening-drawing-and-adding-view/m-p/5693...

 

You might search or post on the Inventor Customization forum too, I almost think I've seem someone ask this question over there in the past (but I could be making that up Smiley Frustrated 😞
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120

 

Also look here: 

(get to the AIP help by clicking the Inventor Help button > Help flyout menu )

 

Autodesk Inventor API - iLogic Create View With Represetnation.PNG

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

EESignature

0 Likes
Message 5 of 14

mcgyvr
Consultant
Consultant

Thanks for the info Dan..

I guess you do one off stuff and don't have an ERP system either...

Makes sense.. I guess.. 

 

I'm always just curious as to why some users have such specific (far out of the norm to me) requests...

 

I'm just a one part = its own drawing (or each assembly = its own drawing) guy and our ERP system throws out job orders for each part with required quantities,etc...

And nothing is here today and never make it again

 

 



-------------------------------------------------------------------------------------------
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
0 Likes
Message 6 of 14

dan_inv09
Advisor
Advisor

Let's go in reverse order.

 

It's nice that they make that help so obvious to find.

I may try and pick through that code sample in a little bit.

 

As far as the Customization Forum, the search and I don't seem to get along (unless you are talking about my post from yesterday that no one looked at) all it seems to want me to see are ways to manipulate existing views or stuff to work with positional reps not on drawings.

 

Now that post you linked, the code in the Solution ...

I never understand what all the Dim stuff is - how do you figure out how many of what do you need? And some of them seem to set values and some don't get values until later - do some need values right away, how do you know? is it essential that some be assigned later, how do you know that? And now I found one Dim buried in the code - why isn't that one at the top with the others?

I'd like to have a drawing and an assembly open and have it work with them, this contains a specific path and filename and to me it looks like it's creating new drawing sheets (and I definitely don't want to be using some sheet Format the one base sheet left in the template is the only one I've ever used all these years).

Okay, then we set the view scale to 1 (1 : 1 or full scale, I guess) then we Dim oViewLoc to tell it some point - 9,13 is some arbitrary point for the center of the view? [Does TransientGeometry in that statement have anything to do with the Dim up above for oTG? Is oTG used somewhere and I just don't see it, or was that supposed to go here?] and the there's a couple of lines to set the view scale and keep changing it as long as the view is too big. (What units is the 70?)

 

 

Now, going back to the Help.

I'll have to keep looking but I have not yet seen anything that doesn't deal with specific named view reps or levels of detail etc.

 

 

I have no idea of the syntax and looking at the examples it's hard to tell as variables are always mixed in for what in many cases seems to be no good reason but I want to try and lay out what it might look like.

 

oDrawing = Current.Drawing
oAssembly = Current.Assembly
oView = Assembly.DesignView
oSheet = oDrawing.Current.Sheet

dim oBaseView as DrawingView

for each oView in oAssembly

Call oBaseViewOptions.Add("DesignViewRepresentation", oView)
Call oBaseViewOptions.Add("DesignViewAssociative", True)

oBaseView = oSheet.DrawingViews.AddBaseView(oAssembly, (0,0), 1/8, FrontViewOrientation, kHiddenLineRemovedDrawingViewStyle, oBaseViewOptions)

Next

 or something like that

 

0 Likes
Message 7 of 14

Curtis_Waguespack
Consultant
Consultant

I meant to mention this app earlier.

 

We kicked the tires for this app recently, and were pretty impressed, but I don't have any real experince with it ( or any affiliation with it 😞 

https://apps.autodesk.com/INVNTOR/en/Detail/Index?id=appstore.exchange.autodesk.com%3aquickviews%3ae...

 

 

Correction it was this one that we looked at and liked (I have nothing against the other one, just not familiar with it):

https://apps.autodesk.com/INVNTOR/fr/Detail/Index?id=appstore.exchange.autodesk.com:autodraw_windows...

 

EESignature

0 Likes
Message 8 of 14

dan_inv09
Advisor
Advisor

This is what I'm doing

deatils.png

I really just need to know how to get iLogic to look at everything in the "View" window in the Representation area of the Component tab of the Drawing View Dialog and go through and place one view for each.

So somehow I've got to extract those view names ...

 

From here

http://forums.autodesk.com/t5/inventor-customization/ilogic-view-reps-on-dwg/m-p/3740433/highlight/t...

I got this (ooooo marks the stuff I'm trying to do - I do not know the proper syntax etc. so this is where I need help)

' Set a reference to the drawing document. 
' This assumes a drawing document is active. 
Dim oDrawDoc As DrawingDocument 
oDrawDoc = ThisApplication.ActiveDocument 

'Set a reference to the active sheet. 
Dim oSheet As Sheet 
oSheet = oDrawDoc.ActiveSheet 

'ooooo my stuff
Dim oViewRepName 'something has to go here doesn't it? But I do not know what.
For Each oViewRepName
'ooooo back to their stuff

' Create a new NameValueMap object 
Dim oBaseViewOptions As NameValueMap 
oBaseViewOptions = ThisApplication.TransientObjects.CreateNameValueMap 

' Set the representations to use when creating the base view. 
'Call oBaseViewOptions.Add("PositionalRepresentation", "MyPositionalRep") 
'ooooo I'm changing this next line - oViewRepName was 'Default"
Call oBaseViewOptions.Add("DesignViewRepresentation", oViewRepName) 
'ooooo and this next line was commented out but I think I'd like them Associative
Call oBaseViewOptions.Add("DesignViewAssociative", True)
'ooooo And I want to change this stuff to grab the assembly I have open so I don't have edit every time ' Open the model document (corresponding to the "MyLODRep" representation). Dim strFullDocumentName As String strFullDocumentName = ThisApplication.FileManager.GetFullDocumentName("c:\temp\reps.iam", "Master") 'ooooo (or would it be easier to work with the assembly as the active document and create a drawing?
Dim oModel As Document oModel = ThisApplication.Documents.Open(strFullDocumentName, False) ' Create the placement point object. Dim oPoint As Point2d oPoint = ThisApplication.TransientGeometry.CreatePoint2d(25, 25) ' Create a base view. Dim oBaseView As DrawingView 'ooooo next line changed kIsoTopLeftViewOrientation to kFrontViewOrientation oBaseView = oSheet.DrawingViews.AddBaseView(oModel, oPoint, 2, _ kFrontViewOrientation, kHiddenLineRemovedDrawingViewStyle, _ , , oBaseViewOptions) 'ooooo and loop with the For Each Next

 

 

0 Likes
Message 9 of 14

Curtis_Waguespack
Consultant
Consultant

Hi dan_inv09,

 

I might find time to look into this a bit, I'm not sure. But here is a start. This looks at aassembly file (in this case the active assembly file), and then looks at each view represetnation with in it.

 

Note too often when I find a piece of code that is similar to what I'm looking for I'll just search the Customization Forum for that term.

example: RepresentationsManager.DesignViewRepresentations

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

' set a reference to the assembly component definintion.
' This assumes an assembly document is open.
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
Dim oViewRep As DesignViewRepresentation

'Look for an existing View Reps
For Each oViewRep In oAsmCompDef.RepresentationsManager.DesignViewRepresentations 
	MessageBox.Show(oViewRep.Name, "iLogic")
Next

 

EESignature

0 Likes
Message 10 of 14

Curtis_Waguespack
Consultant
Consultant

 

 

EESignature

0 Likes
Message 11 of 14

dan_inv09
Advisor
Advisor

Sorry, I had a couple of days off.

And thanks for making me click through 60-something message boxes.

 

So, that has to run in the assembly, right?

Can it have an active drawing and an active assembly at the same time and recognize them both?

 

So I'm going to need to, from within the assembly:

1. Create a new drawing

2. use that loop, but

3. stick in something to create views on that drawing in place of the message box line

Right?


This is going to take me a while (especially since I have some other work that needs to get done - and the earliest I could justify this as being important to what I'm actually working on, or make time in the schedule so this is exactly what I'm working on, is a week or so away).

 

Would it make more sense to roll it into the iLogic I use that makes the view reps?

(I've been struggling to find where I got it so I can give credit to whoever wrote it before I post it ... it might even have been you.)

0 Likes
Message 12 of 14

Anonymous
Not applicable

Hi Dan

Did you find a solution for this topic?

I was also suffering the same problem with you.

Could you please help to share the code to me if you found out it?

Many appreciates.

0 Likes
Message 13 of 14

dan_inv09
Advisor
Advisor

This is the iLogic I've used to create a view for each part

'create a design view representation for each unique part in the assembly 

'define current document
Dim openDoc As Document
openDoc = ThisDoc.Document

'set a reference to the assembly component definintion.
'this assumes an assembly document is open.
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

'look at all of the components in the assembly
Dim oCompDef As Inventor.ComponentDefinition = openDoc.ComponentDefinition

'define the first level components collection
Dim oCompOcc As Inventor.ComponentOccurrence 

'define view rep 
Dim oViewRep As DesignViewRepresentation

'define an arraylist to hold the list of  view rep names
Dim NameList As New ArrayList()

'Look at the view reps in the assembly
For Each oViewRep In oAsmCompDef.RepresentationsManager.DesignViewRepresentations
'set the list of names to the array list
NameList.add(oViewRep.Name)
Next

'check for a Default view rep and create it if not found
If Not NameList.Contains("Default") Then
	'create Default view rep 
	oViewRep = oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Add("Default") 
	oViewRep.ShowAll
	oViewRep.Activate
End If

'zoom all
ThisApplication.CommandManager.ControlDefinitions.Item("AppIsometricViewCmd").Execute

'look at all of the unique parts in the assembly
For Each docFile In openDoc.AllReferencedDocuments
	If docFile.DocumentType = 12290 Then '12290 is the part document enumurator
	'locate the last backslash position in the full file name
	Dim FNamePos As Long
	FNamePos = InStrRev(docFile.FullFileName, "\", -1) 
	'remove path from part file name 	
	Dim docFName As String
	docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos)         
	'remove extension from part file name 
	ShortName = Left(docFName,  Len(docFName) - 4)   
		'check to see if the arraylist contains the desired view rep
		If Not NameList.Contains(ShortName) Then
		'create new View Rep 
		oViewRep = oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Add(ShortName)
		oViewRep.Activate
		oViewRep.Locked = False	
		Else If NameList.Contains(ShortName) Then
		'reference existing View Rep 
		oViewRep = oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Item(ShortName) 
		oViewRep.Activate
		oViewRep.Locked = False
		End If
		'look at all of the occurences
		For Each oCompOcc in oCompDef.Occurrences
		'locate the colon position in the occurence name
		oCompOccPos = InStrRev(oCompOcc.Name, ":") 
		'set occurence name to everything left of the colon
		oOccName = Left(oCompOcc.Name, oCompOccPos -1) 
			'set visible if name matches first occurence
	      	If oCompOcc.Name = ShortName & ":1"  Then
			oCompOcc.Visible = True
			ThisApplication.ActiveView.Update()
			Else
			oCompOcc.Visible = False
			ThisApplication.ActiveView.Update()
			End If
		Next
	End If
	'lock view rep
	oViewRep.Locked = True	
Next

'set Default View Rep active
oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Item("Default").activate

and then I start a drawing and place one view (usually an isometric of the whole assembly) and run this VBA (I wish I knew enough about what was going on to convert one or the other - it's hard enough for me to remember how to get iLogic OR VBA to run)

Public Sub CreateViewForEachRep()
    ' Set a reference to the drawing document.
    ' This assumes a drawing document is active.
    Dim oDrawDoc As DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument
    
    'Set a reference to the active sheet.
    Dim oSheet As sheet
    Set oSheet = oDrawDoc.ActiveSheet
    
    Dim viewScale As Double
    Let viwScale = 0.1875
    
    Dim ptx As Long
    Let ptx = 0
    
    
    'this assumes that view1 is of the full assembly - a view must have been placed in a drawing before running this
    Dim assyDocName As String
    Let assyDocName = oSheet.DrawingViews.Item(1).ReferencedDocumentDescriptor.FullDocumentName
        
    Dim assyDoc As AssemblyDocument
    'open assembly doc invisibly
    Set assyDoc = ThisApplication.Documents.Open(assyDocName, False)
        
    Dim oAssyCompDef As AssemblyComponentDefinition
    Set oAssyCompDef = assyDoc.ComponentDefinition
    
    Dim oRepMgr As RepresentationsManager
    Set oRepMgr = oAssyCompDef.RepresentationsManager
    
    Dim oDesView As DesignViewRepresentation
    
    For Each oDesView In oRepMgr.DesignViewRepresentations
        If oDesView.Name <> "Default" And oDesView.Name <> "Master" Then
            
            Dim oPoint1 As Point2d
            Set oPoint1 = ThisApplication.TransientGeometry.CreatePoint2d(ptx, 11)
            
            Call PlaceBaseView(oSheet, assyDoc, oPoint1, oDesView.Name)
                        
        End If
        ptx = ptx + 2
    Next
      
      'close assembly doc
      assyDoc.Close (False)
      
End Sub

Public Sub PlaceBaseView(ByRef sheet As Inventor.sheet, _
                        ByRef assyDoc As AssemblyDocument, _
                        ByRef ctrpoint As Point2d, _
                        ByRef viewName As String)

    'define view orientation
    Dim vieworient1 As ViewOrientationTypeEnum
    Let vieworient1 = ViewOrientationTypeEnum.kFrontViewOrientation

    'define view style
    Dim viewstyle1 As DrawingViewStyleEnum
    Let viewstyle1 = DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle
    
    Dim oFaceView As DrawingView
    Set oFaceView = sheet.DrawingViews.AddBaseView(assyDoc, ctrpoint, 0.5, vieworient1, viewstyle1, viewName)

End Sub

 

(I've gotten a bunch of jobs recently for new parts in old units, and before that had a run of units that were fairly close to other old ones - which means I haven't made one of my weldment drawings from scratch for a while, so I'm only pretty sure these weren't failed attempts. I take absolutely no credit for any of the code - whenever I try even to just add or remove anything, or convert iLogic commands to VBA or vise-versa, it fails miserably - this is all other peoples work.)

0 Likes
Message 14 of 14

dan_inv09
Advisor
Advisor

This whole "Access Denied" stuff make me worry that older posts like this that I may need to look back at will not be accessible someday.

I clicked on a link in an older post on another topic that seemed like it might have some answers for another question and got:

dan_inv09_0-1757952810588.png

So hopefully this little "bump" will stave off deletion for a little while longer and I might be needing this information soon.

0 Likes