I'm attempting to create a new pviewport, draw a circle in paper space, and then move the circle to model space with the CHSPACE command. All goes well until I execute the CHSPACE command. It's not recognized and the message "bad argument type: lentityp nil" is displayed in the AutoCAD command line. Below is the code.
Another clue - When I stop execution of code and try to manually execute the CHSPACE command I get the same message, "bad argument type: lentityp nil".
Any suggestions would be appreciated.
'NOTE: AcadDoc is a previously opened AcadDocument. Paper space is active when the following steps are executed.
'Create a new viewport for 24 x 36 title blocks
Dim PVPort As AcadPViewport, VPP(0 To 2) As Double
Dim Plot_BL(0 To 2) As Double, Plot_TR(0 To 2) As Double
Dim PV_Margin As Double, Wdth As Double, Hgt As Double
'// Bottom Left Corner of paper space plot area
Plot_BL(0) = -1.5: Plot_BL(1) = 0: Plot_BL(2) = 0
'// Top Right Corner of paper space plot area
Plot_TR(0) = 34: Plot_TR(1) = 23: Plot_TR(2) = 0
'// Paper space plot area margin
PV_Margin = 0.03
'// Define the paper space viewport
VPP(0) = (Plot_BL(0) + Plot_TR(0)) / 2 'X Coordinate
VPP(1) = (Plot_BL(1) + Plot_TR(1)) / 2 'Y Coordinate
VPP(2) = 0 'Z Coordinate
Wdth = Plot_TR(0) - Plot_BL(0) + 2 * PV_Margin
Hgt = Plot_TR(1) - Plot_BL(1) + 2 * PV_Margin
'// Create the paper space viewport
Set PVPort = AcadDoc.PaperSpace.AddPViewport(VPP, Wdth, Hgt)
'// Make the Viewport visible
PVPort.Visible = True
'// Turn the Viewport On
'// Create a circle at 0,0,0 in paperspace.
Dim circleObj As AcadCircle
Dim centerPoint(0 To 2) As Double
Dim radius As Double
' Define the circle
centerPoint(0) = 0#: centerPoint(1) = 0#: centerPoint(2) = 0#
radius = 1#
' Create the Circle object in paper space
Set circleObj = AcadDoc.PaperSpace.AddCircle(centerPoint, radius)
'// Move the circle to model space
AcadDoc.SendCommand "CHSPACE LAST" & vbCr & vbCr
your code is running at my AutoCAD 2014, what version (and servicepack) do you have?
- alfred -
>> I'm running Autodesk Map Series 2004
Ooops, release 2004 does not know the command _CHSPACE, this command was introduced with releaase 2007
- alfred -
Alfred - Thanks again for the feedback. I've been using CHSPACE in AutoCAD 2004 for some time. In the code I'm currently working on, prior to creating the new pviewport, the code below is executed without a problem.
'Move All Paper Space Objects to Model Space
AcadDoc.SendCommand "CHSPACE ALL" & vbCr & vbCr
then you have some additional tool including a function CHSPACE.
You can look to >>>that list<<< to see that CHSPACE started with 2007.
- alfred -
Alfred - You're right - In 2004, CSPACE is an Express Tools command (which I have installed) and in 2007 it must be a standard command. I'm going to abandon this routine for now and go to a plan B that I've used in the past. It's not as clean or versatile as what I want, but it's time to move forward. Thanks for all your help.
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register
Start with some of our most frequented solutions to get help installing your software.