From Drawing select view, Open that item, Add a REP, Pause( do something ), save and close, use the all ready selected view and set REP

From Drawing select view, Open that item, Add a REP, Pause( do something ), save and close, use the all ready selected view and set REP

G.Binl
Advocate Advocate
226 Views
1 Reply
Message 1 of 2

From Drawing select view, Open that item, Add a REP, Pause( do something ), save and close, use the all ready selected view and set REP

G.Binl
Advocate
Advocate

Hello all,

Hope Everyone is well,

 

This may be a bit of a jump got most of this done.

I think it may have to be 2 rules but its worth a try.

 

From Drawing.

1. Select View. (done)

2. Open That Assm. (done)

3. Add a REP Name (done)

4. do something to that open Assm.

5. save that and close it

6 using the Selected View from step 1.

7 set that view to the new REP

 

This is where i am at the moment.

was not sure if i could pause the rule to accomplish step 4 then continue on.

Steps 4 may have to be the stop

and a rule set for 6-7

any help would be great.

V/r,

-G

	Dim oView As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select View")
	Dim oTargetView As String
	If oView Is Nothing Then Exit Sub
	
	Dim oModelDoc As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument

	Dim oViewModelName As String = oModelDoc.DisplayName
	Dim oFullFilePath As String = oModelDoc.FullFileName
	oTargetView = oFullFilePath

'MsgBox(oViewModelName)
'MsgBox(oFullFilePath)
'MsgBox(FullFileName)
	Dim oFolderPath As String = Left(oFullFilePath, (InStrRev(oFullFilePath, "\", -1, vbTextCompare) -1))
	
	'ThisApplication.Documents.Open(oViewModelName, True)
	 ThisApplication.Documents.Open(oTargetView)
	
'''xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx	

'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

'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("Weld Track2")
'Next

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

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

 

0 Likes
Accepted solutions (1)
227 Views
1 Reply
Reply (1)
Message 2 of 2

A.Acheson
Mentor
Mentor
Accepted solution

Hi @G.Binl 

This should be all possible in one rule. You just need to activate the right docume to at the right time. Addressing the assembly first, your using 3 different methods to access the documents.  ActiveDocument,OpenDocument, ThisDoc.Document. The last will actually only target the document you first run the rule from in this case the drawing. It is an ilogicAPI snippet that has only limited scope. 

Orgional:

	'ThisApplication.Documents.Open(oViewModelName, True)
	 ThisApplication.Documents.Open(oTargetView)
	
'''xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx	

'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

 

Condensed: 

'ThisApplication.Documents.Open(oViewModelName, True)
Dim oAssyDoc As AssemblyDocument = ThisApplication.Documents.Open(oTargetView)
	
'set a reference to the assembly component definintion.
'this assumes an assembly document is open.
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = oAssyDoc.ComponentDefinition

 Once you have the definition you can work on anything in the assembly. 

 

For setting the viewrep in the drawingview you just need to activate the drawing again, the easiest is by using the ThisDoc.Document.Activate the  

retrieve the drawingview object you started with and set the view rep with the correct string.

 

Syntax

DrawingView.SetDesignViewRepresentationRepresentation As String, [Associative] As Boolean )

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan