Grenco Posted January 27, 2009 Share Posted January 27, 2009 Hello all I created a layout, inserted a drawingborder and a viewport. I also changed the view in the viewport. There is one thing left i want to do with de viewports; Set shade plot to "Hidden". This is the vba; Dim newPViewport As AcadPViewport Dim center0(0 To 2) As Double Dim center1(0 To 2) As Double Dim center2(0 To 2) As Double Dim center3(0 To 2) As Double Dim width As Double Dim height As Double center0(0) = -110: center0(1) = 115.25: center0(2) = 0 center1(0) = -110: center1(1) = 229.75: center1(2) = 0 center2(0) = -310: center2(1) = 115.25: center2(2) = 0 center3(0) = -310: center3(1) = 229.75: center3(2) = 0 width = 200 height = 114.5 DWG_NameFull = ThisDrawing.Name DWG_Name = Replace(DWG_NameFull, ".dwg", "") ThisDrawing.ActiveSpace = acPaperSpace ThisDrawing.SendCommand ("layout" & vbCr & "r" & vbCr & vbCr & DWG_Name & vbCr) Dim Logo As AcadBlockReference Dim Kader As AcadBlockReference Dim DynProps As Variant Dim Variabelen As AcadDynamicBlockReferenceProperty Dim I As Integer Dim insertionPnt(0 To 2) As Double insertionPnt(0) = 0#: insertionPnt(1) = 0#: insertionPnt(2) = 0# Set Logo = ThisDrawing.PaperSpace.InsertBlock(insertionPnt, "GEALOGO", 1#, 1#, 1#, 0#) Set Kader = ThisDrawing.PaperSpace.InsertBlock(insertionPnt, "KADER", 1#, 1#, 1#, 0#) If Kader.IsDynamicBlock Then DynProps = Kader.GetDynamicBlockProperties For I = 0 To UBound(DynProps) Set Variabelen = DynProps(I) If Variabelen.Value = "A3" Then Variabelen.Value = Formaat Exit For End If Next End If ThisDrawing.ActiveLayout.RefreshPlotDeviceInfo ThisDrawing.ActiveLayout.ConfigName = "DWFx ePlot.pc3" ThisDrawing.ActiveLayout.StyleSheet = "GEA-kleur-diktes.ctb" ThisDrawing.ActiveLayout.PlotType = acExtents ThisDrawing.ActiveLayout.CenterPlot = True ThisDrawing.ActiveLayout.StandardScale = acScaleToFit AutoCAD.Update curpapersizes = ThisDrawing.PaperSpace.Layout.GetCanonicalMediaNames() ThisDrawing.Regen (acActiveViewport) Dim G_sht_frm As String G_sht_frm = "UserDefinedMetric (420.00 x 297.00MM)" ThisDrawing.ActiveLayout.CanonicalMediaName = G_sht_frm ThisDrawing.ActiveLayout.PlotRotation = plotrot ThisDrawing.Regen (acAllViewports) AutoCAD.ZoomAll Dim Layer As AcadLayer Set Layer = ThisDrawing.Layers.Add("Viewport") Layer.color = acMagenta Layer.Plottable = False ThisDrawing.ActiveLayer = ThisDrawing.Layers.Item("Viewport") Set newPViewport = ThisDrawing.PaperSpace.AddPViewport(center0, width, height) newPViewport.Display (True) [color=red]newPViewport.VisualStyle = 3[/color] ThisDrawing.MSpace = True ThisDrawing.ActivePViewport = newPViewport ThisDrawing.SendCommand ("-view" & vbCr & "Right" & vbCr) ThisDrawing.SendCommand ("pspace" & vbCr) ThisDrawing.Regen acAllViewports Call VBA.Unload(Me) As you can see I've setted the added viewport visual style to 3 (Hidden?). Standard value is 1 (As displayed?). In vba the local is changed to 3. But in autoCAD the shade plot is stil "As displayed". In the VBA-help of autoCAD I can't understand the meaning of a Helix and apply it to my problem. Can anyone tell me why the Shade Plot isn't changed and how to do it? thnx a lot Quote Link to comment Share on other sites More sharing options...
Grenco Posted February 6, 2009 Author Share Posted February 6, 2009 Now I got the following code: Dim Layer As AcadLayer Set Layer = ThisDrawing.Layers.Add("Viewport") Layer.color = acMagenta Layer.Plottable = False ThisDrawing.ActiveLayer = ThisDrawing.Layers.Item("Viewport") Set newPViewport = ThisDrawing.PaperSpace.AddPViewport(center0, width, height) newPViewport.Display (True) newPViewport.VisualStyle = 3 ThisDrawing.MSpace = True ThisDrawing.ActivePViewport = newPViewport ThisDrawing.SendCommand ("-view" & vbCr & "Right" & vbCr) VBA.DoEvents 'ThisDrawing.ActiveSpace = acPaperSpace Set newPViewport = ThisDrawing.PaperSpace.AddPViewport(center1, width, height) newPViewport.Display (True) newPViewport.VisualStyle = 3 ThisDrawing.MSpace = True ThisDrawing.ActivePViewport = newPViewport ThisDrawing.SendCommand ("-view" & vbCr & "SW" & vbCr) VBA.DoEvents 'ThisDrawing.ActiveSpace = acPaperSpace Set newPViewport = ThisDrawing.PaperSpace.AddPViewport(center2, width, height) newPViewport.Display (True) newPViewport.VisualStyle = 3 ThisDrawing.MSpace = True ThisDrawing.ActivePViewport = newPViewport ThisDrawing.SendCommand ("-view" & vbCr & "Front" & vbCr) VBA.DoEvents 'ThisDrawing.ActiveSpace = acPaperSpace Set newPViewport = ThisDrawing.PaperSpace.AddPViewport(center3, width, height) newPViewport.Display (True) newPViewport.VisualStyle = 3 ThisDrawing.MSpace = True ThisDrawing.ActivePViewport = newPViewport ThisDrawing.SendCommand ("-view" & vbCr & "Top" & vbCr) VBA.DoEvents 'ThisDrawing.ActiveSpace = acPaperSpace ThisDrawing.SendCommand ("pspace" & vbCr) If I start the code with F8. It works perfect. If i use F5. It skips all the: "ThisDrawing.SendCommand ("-view" & vbCr & "xxx" & vbCr)" and when he is finished it performs them. So I see the last viewport changing to "Right" "SW" "Front" and "TOP" How come?? How can I fix it? And I still got the other question unanswered thnx! Quote Link to comment Share on other sites More sharing options...
SEANT Posted February 6, 2009 Share Posted February 6, 2009 VBA's "SendCommand" tends to be problematic - it may be better to set up the routines thusly: Sub GenViews() Dim center0(0 To 2) As Double Dim center1(0 To 2) As Double Dim center2(0 To 2) As Double Dim center3(0 To 2) As Double Dim width As Double Dim height As Double Dim Layer As AcadLayer Dim vDirection(0 To 2) As Double Dim newPViewport As AcadPViewport center0(0) = 110: center0(1) = 115.25: center0(2) = 0 center1(0) = 110: center1(1) = 229.75: center1(2) = 0 center2(0) = 310: center2(1) = 115.25: center2(2) = 0 center3(0) = 310: center3(1) = 229.75: center3(2) = 0 width = 200 height = 114.5 Set Layer = ThisDrawing.Layers.Add("Viewport") Layer.color = acMagenta Layer.Plottable = False ThisDrawing.ActiveLayer = ThisDrawing.Layers.Item("Viewport") Set newPViewport = ThisDrawing.PaperSpace.AddPViewport(center0, width, height) newPViewport.ShadePlot = acShadePlotRendered vDirection(0) = 1# vDirection(1) = 0# vDirection(2) = 0# newPViewport.Direction = vDirection newPViewport.Display True ThisDrawing.MSpace = True ZoomExtents Set newPViewport = ThisDrawing.PaperSpace.AddPViewport(center1, width, height) newPViewport.ShadePlot = acShadePlotRendered vDirection(0) = -1# vDirection(1) = -1# vDirection(2) = 1# newPViewport.Direction = vDirection newPViewport.Display True ThisDrawing.MSpace = True ZoomExtents Set newPViewport = ThisDrawing.PaperSpace.AddPViewport(center2, width, height) newPViewport.ShadePlot = acShadePlotRendered vDirection(0) = 0# vDirection(1) = -1# vDirection(2) = 0# newPViewport.Direction = vDirection newPViewport.Display True ThisDrawing.MSpace = True ZoomExtents Set newPViewport = ThisDrawing.PaperSpace.AddPViewport(center3, width, height) newPViewport.ShadePlot = acShadePlotRendered vDirection(0) = 0# vDirection(1) = 0# vDirection(2) = 1# newPViewport.Direction = vDirection newPViewport.Display True ThisDrawing.MSpace = True ZoomExtents ThisDrawing.MSpace = False End Sub Quote Link to comment Share on other sites More sharing options...
Grenco Posted February 9, 2009 Author Share Posted February 9, 2009 Hmm... I'll check this out when I got a few minutes. Thanks!! Little question, the vDirection(0), (1) and (2) is for setting the view to TOP, SW, FRONT etc? How does that work in numbers? Quote Link to comment Share on other sites More sharing options...
SEANT Posted February 9, 2009 Share Posted February 9, 2009 The numbers work in the same fashion as AutoCAD’s VPOINT command. Which is to say the numbers vDirection(0), (1), and (2) correspond to WCS x, y, and z respectively. So, for instance, the TOP view can be described as looking at the model from a view aligned to the vector 0,0,1 to 0,0,0 Quote Link to comment Share on other sites More sharing options...
rocheey Posted February 9, 2009 Share Posted February 9, 2009 I dont have the time to go over this code right now, but this seems similar to a problem I was having - just setting the shademode in Modelspace - (Im using sendcommand) you think this will work with modelspace as the current viewport? Quote Link to comment Share on other sites More sharing options...
Grenco Posted February 9, 2009 Author Share Posted February 9, 2009 I think it works the same way ps. I used "newPViewport.ShadePlot = acShadePlotHidden" to set it to Hidden and not 3D Hidden (acShadePlotRendered) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.