iLogic that activates a style standard

iLogic that activates a style standard

Anonymous
Not applicable
4,000 Views
13 Replies
Message 1 of 14

iLogic that activates a style standard

Anonymous
Not applicable

Hello all,

 

I am building an idw template that launches a defined drawing size (Size A, Size B, Size D) and so on, into a single idw template. Everything thus far works fine. I have a dialog box that appears upon launch of our idw template, which prompts sheet size, cutomer, sheet type and drawing title. Again everything behaves properly. Within the template I have standard styles (Size A, Size B, Size D) and so on. The problem is........ having the correct style activated for the appropriate sheet size. Is this something that is acheviable with ilogic? I have attached my template for review. Any help is greatly appreciated.

 

Thanks gang!

Shawn

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

HermJan.Otterman
Advisor
Advisor

Hello Soggys3,

 

try this code in iLogic:

just put in the right "standard name"

 

        Dim oDrawingDoc As DrawingDocument = ThisDoc.Document

        'the styles collection
        Dim oStandardDesignStyles As DrawingStandardStylesEnumerator = oDrawingDoc.StylesManager.StandardStyles

        'the current active style
        Dim oActiveStandardStyle As DrawingStandardStyle = oDrawingDoc.StylesManager.ActiveStandardStyle
        'MsgBox(oActiveStandardStyle.Name)

        'find the right style and set it then exit
        Dim oStandardStyle As DrawingStandardStyle
        For Each oStandardStyle In oStandardDesignStyles
            If oStandardStyle.Name = "SIZE D (MTSI)" Then
                oDrawingDoc.StylesManager.ActiveStandardStyle = oStandardStyle
                Exit Sub
            End If
        Next

 

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Message 3 of 14

Anonymous
Not applicable

HJWO-

I'm working with Soggy3 to try and get this nailed down, but ultimately I'm still struggling.. The chunk of code doesn't seem to behave as I'd expect, however I may not be 'integrating' it properly..

 

Ideally, whatever iLogic we develop would not only set the active dimension style for a given sheet size, but it would also update and/or change any current dimensions and text (items controlled by the dimension style) to the desired dimension style - 

 

The 'director' of the template file is the form that directs the code to set sheet size, borders, title blocks, client entries and drawing type... 

The workhorse is our Sheet Size/Format rule - 

 

''If selection "MTSI A" is selected, what options will be activated?
kLandscapePageOrientation = 10242
kPortraitPageOrientation = 10243

If Drawing_Sheet_Size = "MTSI A" Then 
ActiveSheet.ChangeSize("A", MoveBorderItems := True)
ThisApplication.ActiveDocument.ActiveSheet.Orientation  = kPortraitPageOrientation
ActiveSheet.Border = "8 1/2 X 11"
'ActiveSheet.TitleBlock = "MTSI A"
ActiveSheet.SetTitleBlock("MTSI A", Dwg_Type)
ThisApplication.ActiveView.Fit

''If selection "MTSI A, [IPB]" is selected, what options will be activated?
ElseIf Drawing_Sheet_Size = "MTSI A - IPB" Then 
ActiveSheet.ChangeSize("A", MoveBorderItems := True)
ThisApplication.ActiveDocument.ActiveSheet.Orientation  = kPortraitPageOrientation
ActiveSheet.Border = "A SIZE - IPB"
ActiveSheet.TitleBlock = "MTSI A - IPB"
ThisApplication.ActiveView.Fit

''If selection "MTSI B" is selected, what options will be activated?
ElseIf Drawing_Sheet_Size = "MTSI B" Then 
ActiveSheet.ChangeSize("B", MoveBorderItems := True)
ThisApplication.ActiveDocument.ActiveSheet.Orientation  = kLandscapePageOrientation
ActiveSheet.Border = "11 X 17"
'ActiveSheet.TitleBlock = "MTSI B"
ActiveSheet.SetTitleBlock("MTSI B", Dwg_Type)
ThisApplication.ActiveView.Fit

''If selection "MTSI D" is selected, what options will be activated?
ElseIf Drawing_Sheet_Size = "MTSI D" Then 
ActiveSheet.ChangeSize("D", MoveBorderItems := True)
ThisApplication.ActiveDocument.ActiveSheet.Orientation  = kLandscapePageOrientation
ActiveSheet.Border = "22 X 34"
'ActiveSheet.TitleBlock = "MTSI D"
ActiveSheet.SetTitleBlock("MTSI D", Dwg_Type)
ThisApplication.ActiveView.Fit

End If

Am I correct in assuming that your chunk of code would be added to the lines under each If/Elseif segments?

 

Cheers!

0 Likes
Message 4 of 14

HermJan.Otterman
Advisor
Advisor

you could add it as an other sub:

 

make you own sub the "Main" sub, and then in every "If" you can call the other sub.

just fill in the correct names of the standardstyles

 

 

Sub Main
''If selection "MTSI A" is selected, what options will be activated? 
kLandscapePageOrientation = 10242 
kPortraitPageOrientation = 10243 
If Drawing_Sheet_Size = "MTSI A" Then 
     StandardStyle("SIZE D (MTSI)")
    ActiveSheet.ChangeSize("A", MoveBorderItems := True) 
    ThisApplication.ActiveDocument.ActiveSheet.Orientation = kPortraitPageOrientation 
    ActiveSheet.Border = "8 1/2 X 11" 
    'ActiveSheet.TitleBlock = "MTSI A" ActiveSheet.SetTitleBlock("MTSI A", Dwg_Type) 
    ThisApplication.ActiveView.Fit 
''If selection "MTSI A, [IPB]" is selected, what options will be activated? 
ElseIf Drawing_Sheet_Size = "MTSI A - IPB" Then 
     StandardStyle("SIZE D (MTSI)")
    ActiveSheet.ChangeSize("A", MoveBorderItems := True) 
    ThisApplication.ActiveDocument.ActiveSheet.Orientation = kPortraitPageOrientation 
    ActiveSheet.Border = "A SIZE - IPB" 
    ActiveSheet.TitleBlock = "MTSI A - IPB" 
    ThisApplication.ActiveView.Fit 
''If selection "MTSI B" is selected, what options will be activated? 
ElseIf Drawing_Sheet_Size = "MTSI B" Then 
     StandardStyle("SIZE D (MTSI)")
    ActiveSheet.ChangeSize("B", MoveBorderItems := True) 
    ThisApplication.ActiveDocument.ActiveSheet.Orientation = kLandscapePageOrientation 
    ActiveSheet.Border = "11 X 17" 
    'ActiveSheet.TitleBlock = "MTSI B" ActiveSheet.SetTitleBlock("MTSI B", Dwg_Type) 
    ThisApplication.ActiveView.Fit 
''If selection "MTSI D" is selected, what options will be activated? 
ElseIf Drawing_Sheet_Size = "MTSI D" Then 
    StandardStyle("SIZE D (MTSI)")
    ActiveSheet.ChangeSize("D", MoveBorderItems := True) 
     ThisApplication.ActiveDocument.ActiveSheet.Orientation = kLandscapePageOrientation 
    ActiveSheet.Border = "22 X 34" 
    'ActiveSheet.TitleBlock = "MTSI D" ActiveSheet.SetTitleBlock("MTSI D", Dwg_Type) 
    ThisApplication.ActiveView.Fit 
End If
 End Sub
 
 Private Sub StandardStyle(ByVal StyleName As String)
     Dim oDrawingDoc As DrawingDocument = ThisDoc.Document
        'the styles collection
        Dim oStandardDesignStyles As DrawingStandardStylesEnumerator = oDrawingDoc.StylesManager.StandardStyles
        'the current active style
        Dim oActiveStandardStyle As DrawingStandardStyle = oDrawingDoc.StylesManager.ActiveStandardStyle
        'MsgBox(oActiveStandardStyle.Name)

        'find the right style and set it then exit
        Dim oStandardStyle As DrawingStandardStyle
        For Each oStandardStyle In oStandardDesignStyles
            If oStandardStyle.Name = StyleName Then
                oDrawingDoc.StylesManager.ActiveStandardStyle = oStandardStyle
                Exit Sub
            End If
        Next
 End Sub
If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes
Message 5 of 14

HermJan.Otterman
Advisor
Advisor

here is the drawing, I put in a test rule and suppressed sheet size/format

 

 

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Message 6 of 14

HermJan.Otterman
Advisor
Advisor

was that what you where looking for?

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes
Message 7 of 14

Anonymous
Not applicable

HJWO-

So far, the code isn't playing well with our work-flow, though we have been slowly devoting some time to finishing the rule-set (and will continue to do so)..

 

We'll appropriately report back when we either get stuck again, or succeed!

0 Likes
Message 8 of 14

AlexFielder
Advisor
Advisor

@Anonymous @HermJan.Otterman @Anonymous: my $0.02: To avoid potential errors in this iLogic Rule you might to want to amend your lines that look like this:

 

ThisApplication.ActiveDocument.ActiveSheet.Orientation  = kPortraitPageOrientation

to include the correct enumerator like this:

 

ThisApplication.ActiveDocument.ActiveSheet.Orientation  = PageOrientationTypeEnum.kPortraitPageOrientation

It would in turn do away with these two lines:

 

kLandscapePageOrientation = 10242
kPortraitPageOrientation = 10243

 

This post explains the reasons behind this minor change.

Message 9 of 14

Anonymous
Not applicable

AlexFielder and HWJO -

 

Spent some time making sure bugs were out of the code and things are working BEAUTIFULLY.  Much appreciated for the assistance!


One last little note - 

 

We are using a prompted entry for our "drawing type" in the title block; As we add sheets to a drawing, the user is immediately prompted to complete the prompted entry field(s) for the sheet that have yet to be defined.  Is there any way that anyone knows of to suppress this dialogue box on new sheet creation?

0 Likes
Message 10 of 14

AlexFielder
Advisor
Advisor

Hi @Anonymous AFAIK this "prompt on new sheet" function is by design, there maybe a way to suppress this action but I'm not aware of it off the top of my head.

 

The following post from 2013 might indicate a way forward:

 

https://forums.autodesk.com/t5/inventor-general-discussion/turn-off-prompted-entries-at-new-sheet-cr...

 

I realise however that creating a form for a document is something that can become quite involved.

 

I myself have been subjected to this exact problem in the past and my solution then was to create a form that allowed the user to fill out normally (Prompted) information upon creating a new drawing.

 

IIRC: My solution also inserted the drawing borders instead of having them present in the Sheet template; this meant a little extra work for the user but you could see it as an opportunity to set up the drawing views/dimensions/tables etc. and then add the drawing border afterwards.

 

Perhaps someone from Autodesk might know of a better answer.

 

Cheers,

 

Alex.

0 Likes
Message 11 of 14

HermJan.Otterman
Advisor
Advisor

Hello Gordonm, great that it works.

from the PDM point of view you should consider using only one sheet per drawing.....

but aside from that I agree with Alex, no prompted entries, and create your own form to set the properties.

set an event trigger on open document.

 

HJWO

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes
Message 12 of 14

adam.nagy
Autodesk Support
Autodesk Support

Not sure if I understand correctly what you need but if you just want to avoid the Prompted Entry dialog when inserting a block / border / sheet programmatically, then this should help: http://adndevblog.typepad.com/manufacturing/2016/03/prompted-entry-prompted-texts-promptstrings.html



Adam Nagy
Autodesk Platform Services
0 Likes
Message 13 of 14

RoyWickrama_RWEI
Advisor
Advisor

Thanks for the posting.

 

I am using it in my rule: but need to filter out the local styles only.

Could you help. Thanks again.

 

Dim oDrawingDoc As DrawingDocument = ThisDoc.Document

'the styles collection
Dim oStandardDesignStyles As DrawingStandardStylesEnumerator = oDrawingDoc.StylesManager.StandardStyles

'the current active style
Dim oActiveStandardStyle As DrawingStandardStyle = oDrawingDoc.StylesManager.ActiveStandardStyle
'MsgBox(oActiveStandardStyle.Name)

Dim oStandardStyle As DrawingStandardStyle
Dim oStyles As New ArrayList
For Each oStandardStyle In oStandardDesignStyles
	oStyles.Add(oStandardStyle.Name)
Next oStandardStyle

oStyles_Selected = InputListBox("Prompt", oStyles, oStyles(0), Title := "Title", ListName := "LIST OF STYLES")
	
'MessageBox.Show("Message: " & oStandardDesignStyles.Count, "Title")
'oDrawingDoc.StylesManager.ActiveStandardStyle = oStyles_Selected
'find the right style and set it then exit

For Each oStandardStyle In oStandardDesignStyles
'	MessageBox.Show("Message: " & oStandardStyle.Name, "Title")
    If oStandardStyle.Name = oStyles_Selected Then
        oDrawingDoc.StylesManager.ActiveStandardStyle = oStandardStyle
        Exit Sub
    End If
Next

 

 

0 Likes
Message 14 of 14

HermJan.Otterman
Advisor
Advisor

Hello,

 

When you go to The inventor help, than Programming/API help, look for: DrawingStandardStyle

this has a property StyleLocation that can be Local (kLocalStyleLocation), Library or Both

with this you can check where the style is located

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes