cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

How to lock layer in macro?

FrancisPaille
7-Bedrock

How to lock layer in macro?

HI everybody, i search a way to incorporate in my existing macro, syntax to lock layer. to prevent switching my frame (in Layer 181 Frames) into Standard Layer. On our frame, this layer sould be freeze by our std, but in some case it is not, so this process will imporve the accuracy of this macro. If somebody have some idea, it would be much appreciated!

Thanks!

Macro Clean up + del unuse pen

# recorded with Arbortext IsoDraw 7.0
Select rectangle 204.105 91.621 186.252 39.316
Select rectangle 201.287 89.115 200.973 89.43
Select rectangle 202.853 99.451 185.312 38.375
Text font "Helvetica"
Text size 6
Text face normal
Lock selection
Select rectangle 195.336 253.239 17.431 36.183
Text font "Helvetica"
Text size 10
Select none
Select if Font_face is equal to 'italic'
Select if Font_face is equal to 'italic'
Text face normal
Select if Font_face is equal to 'bolditalic'
Text face bold
Select rectangle 20.271 251.981 194.978 26.198
Lock selection
Select all
Delete selection
Unlock all
Select rectangle (-31.115) 250.733 (-30.489) 251.673
Select all
Set lineoptions 1 1 0 4
Select none
Select all
Activate layer "Standard layer"
Selected Elements to active layer
Select none
Select all
Select if Text_alignment is equal to 'centered'
Text align left
Text align centered
Select none


Select none
Select if Text is equal to 'FWD'
Convert text to paths
Select if Text is equal to 'DOWN'
Convert text to paths
Select if Text is equal to 'UP'
Convert text to paths
Select if Text is equal to 'INBD'
Convert text to paths
Select if Text is equal to 'OUTBD'
Convert text to paths
Select if Text is equal to 'AIRFLOW'
Convert text to paths
Select none

Define E1 as Element
Select if Type is equal to 'text'
Subselect if Color is not equal to 'Black'

E1 = ActiveDoc.FirstSelectedElement

E1.Fill = "{Ref '$ISO_BLACK' 100}"
Select none


Define pen1 as String
Define pen2 as String
Define pen3 as String
Define pen4 as String
Define pen5 as String
Define pen6 as String
Define pen7 as String
Define pen8 as String
Define pen9 as String
Define pen10 as String
Define pen11 as String
Define pen12 as String
Define pen13 as String
Define pen14 as String
Define pen15 as String
Define pen16 as String
Define pen17 as String
Define pen18 as String
Define pen19 as String
Define pen20 as String
Define pen21 as String
Define pen22 as String
Define pen23 as String
Define pen24 as String


pen1 = "Thick"
pen2 = "Medium"
pen3 = "Thin"
pen4 = "Center line"
pen5 = ".004"
pen6 = ".024"
pen7 = "fleche>"
pen8 = "fleche"
pen9 = "flefleche"
pen10 = "pointeur"
pen11 = "pointiller"
pen12 = "frames"
pen13 = "wh004"
pen14 = "wh008"
pen15 = "Fantome"
pen16 = "Center Line 2"
pen17 = "frame"
pen18 = ".015"
pen19 = "arrow flow"
pen21 = "flow arrow"
pen22 = "srm fleche"
pen23 = "pointiller-008"
pen24 = "ligne fantome"


Define pen_count as integer
pen_count = ActiveDoc.PenCount
Define delete_pen as string
Define n as integer
Define i as integer


n = (pen_count + 4)


For i = 1 to n
delete_pen = ActiveDoc.Pens[pen_count].Name

if (delete_pen = pen24) Then
Else
if (delete_pen = pen23) Then
Else
if (delete_pen = pen22) Then
Else
if (delete_pen = pen21) Then
Else
if (delete_pen = pen20) Then
Else
if (delete_pen = pen19) Then
Else
if (delete_pen = pen18) Then
Else
if (delete_pen = pen17) Then
Else
if (delete_pen = pen16) Then
Else
If (delete_pen = pen15) Then
Else
If (delete_pen = pen14) Then
Else
If (delete_pen = pen13) Then
Else
If (delete_pen = pen12) Then
Else
If (delete_pen = pen11) Then
Else
If (delete_pen = pen10) Then
Else
If (delete_pen = pen9) Then
Else
If (delete_pen = pen8) Then
Else
If (delete_pen = pen7) Then
Else
If (delete_pen = pen6) Then
Else
If (delete_pen = pen5) Then
Else
If (delete_pen = pen4) Then
Else
If (delete_pen = pen3) Then
Else
If (delete_pen = pen2) Then
Else
If (delete_pen = pen1) Then
Else

Select if Pen is equal to delete_pen
Set active pen ".004"
Delete pen delete_pen

End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
pen_count = ActiveDoc.PenCount
End For

End Macro

1 ACCEPTED SOLUTION

Accepted Solutions

Try quotes around the layer name and no space after "Layers".

ActiveDoc.Layers["Layer 181 Frames"].Locked = true

View solution in original post

4 REPLIES 4

To lock a layer the verbiage is:

ActiveDoc.Layers[layer number].Locked = True

Just change it to false to unlock.

Hi Trevor, I try this Macro, but doe'nt work???

Did you know why?

Macro layer 181 freeze

ActiveDoc.Layers [Layer 181 Frames].Locked = true

End Macro

Many thanks!

Try quotes around the layer name and no space after "Layers".

ActiveDoc.Layers["Layer 181 Frames"].Locked = true

Thanks Again Trevor, it is worcking perfectly!

Now i would play around to add that to my main macro!

Top Tags