View Full Version : Ask for PlotstyleName of Layer???
vndesperados
08-05-2005, 04:07 AM
HI Eddie
I've a trouble.
I've a LayerDatabase.mdb {LayerName as String, Color as Integer, LineType as String, Plotstyle as String...}
I can create a layer from LayerDatabase with properties Name, Color, LineType... but I can't assign PlotStyleName for this layer.
I use AC2004 and VBA for Acad.
Can you help me?
Best regards
Thanks
Eddie
08-05-2005, 10:06 PM
8) Try something like
layer.plotstylename = "plotstylename"
vndesperados
09-05-2005, 04:02 AM
Hi Eddie!
This is my code
Function LayerCreate(layername As String, Color As Integer, LnType As String, pltstname As String) As Boolean
Dim la As AutoCAD.AcadLayer
LayerCreate=false
If layername <> "" Then
Set la = ThisDrawing.Layers.Add(layername)
la.color = Color
ThisDrawing.Database.Linetypes.Add duongnet
la.Linetype = LnType
la.PlotStyleName = pltstname
LayerCreate=true
End If
End Function
I've rec. a msg. from Autocad
Run-time error'-2145386171 (80200145)':
The drawing is in color dependent plot style mode
How must I do to attach a plot style table to my darwing by VBA Code
Thanks
Eddie
09-05-2005, 05:22 AM
The error message you are getting is because the drawing is color dependant (IE.. it's using CTB files for plotting) in order to attach a plotstyle to layers the drawing must be plotstyle dependant ..
Do this go to the Autocad options and in the PLOTTING tab change the plotstyle behaviour to Use named plot style, then start a new drawing and try your macro..
vndesperados
09-05-2005, 08:49 AM
Thanks Eddie
Do this go to the Autocad options and in the PLOTTING tab change the plotstyle behaviour to Use named plot style, then start a new drawing and try your macro..
I know that but I wana do that by VBA Code
Can you help me?
Thanks
Eddie
09-05-2005, 12:16 PM
8) you would have use the convertpstyles which converts a drawing plotstyle status from CTB to STB or vise versa.
You would have to do a sendcommand in your code but it will not be transparent, you will have to interact with autocad...when prompted
try something like..
ThisDrawing.SendCommand "convertpstyles"
vndesperados
10-05-2005, 01:55 AM
Thank Eddie!
vndesperados
10-05-2005, 02:23 AM
Hi Eddie
I've some trouble and hope you can help me.
I've a Layer Database {Layername as string, Color as Integer, LineType as String, PlotStyle as String...}
1. I wana create a new layer from this Layer Database but I can't assign Plotstyle properties for layer.
2. With any layer is exist in drawing, I can't change PlotstyleName
Ex: The layer's PlotstyleName is "Color_7" rename is "90% screen"
I can do that with Acad Tools but I wana do that with AutoCad VBA
Question:
How must I do to attach a PlotStyleTable (defined) to drawing by VBA Code?
How is the VBA Code to do:
- Rename the Layer's PlotstyleName
Thanks.
Anyfedback is helpful.
Best regards.
Eddie
10-05-2005, 03:08 AM
Firstly...have you converted the CTB file to STB ??? if you have then use CONVERTCTB to do so as you will need this file the CONVERTPSTYLES process..
If a layer already has a plotstyle assigned use
la.PlotStyleName = pltstname to re-assign the new plotstyle to the layer.
Here is some sample code...
For Each iLayer In Layrs
If LCase$(iLayer.Name) Like "*p*" Then
iLayer.Color = acGreen
iLayer.PlotStyleName = Pltstname
End If
vndesperados
11-05-2005, 02:21 PM
Hi Eddie!
How are you?
I've idea to fix my trouble and the macro is OK
1 - Check my current dwawing is using STB or CTB - Boolean
2 - If STB then attach a PlotstyleSheet (*.TSB) to activelayout
Else (CTB=true) then using the ConvertPstyle to use STB and attach PlotstyleSheet (*.TSB) to active layout
3 - Using SendCommand "Layer " to change plotstylename
Thank Eddie.
I hope you can help me in the next time.
Best regards
Eddie
11-05-2005, 08:55 PM
8) You are close ... but you don't need to use the sendcommand to change the layer plotstylename
change the layers like this
Layrs = thisdrawing.layers
For Each iLayer In Layrs
If LCase$(iLayer.Name) Like "*p*" Then
iLayer.Color = acGreen
iLayer.PlotStyleName = Pltstname
End If
vBulletin® v3.7.3, Copyright ©2000-2009, Jelsoft Enterprises Ltd.