Вы находитесь на странице: 1из 107

;

; --------------------------------------------------------------------------;<_DWG_> - Functions to query or manipulate drawings


|
; --------------------------------------------------------------------------|
; <DSV_<DWGSTABLE>> - Return the vla object for the drawings collection. |
; <DSV_<DWGSLIST>> - Return the vla object and name for each drawing open. |
; <DSV_<DWGACTV>> - Return the vla object for the active drawing.
|
; <DSV_<UTIL>> - Return the vla utility object for the current drawing.
|
; <DSV_<PSPCTBL>> - Return the vla object for the paper space collection. |
; <DSV_<MSPCTBL>> - Return the vla object for the model space collection. |
; <DSV_<BLKTBL>> - Return the vla object for the blocks collection.
|
; <DSV_<BLKSLIST>> - Return a list of name and vla object for each block. |
; <DSV_<BLKNAM>> - Return the vla object for a named block.
|
; <DSV_DWGWIDTH> - Gets width of current drawing in drawing units.
|
; <DSV_DWGHEIGHT> - Gets height of current drawing in drawing units.
|
; <DSV_DWGDEPTH> - Gets depth of current drawing in drawing units.
|
; <DSV_DWGSIZE> - Gets size of current drawing in drawing units.
|
; <DSV_DWGMAX> - Returns largest of width or height of current drawing.
|
; <DSV_DWGCENTER> - Gets center point of current drawing in UCS.
|
; <DSV_DWGSCRSIZ> - Gets size of current display in drawing units.
|
; <DSV_DWGSAVE> - Renames and saves the drawing the specified path & name. |
; <DSV_DWGCLEAR> - Erases all objects in the drawing.
|
; <DSV_DWGEMPTY> - Checks if drawing is empty.
|
; <DSV_DWGLOAD> - Opens OR begins a drawing of the specified name.
|
; --------------------------------------------------------------------------;
; --------------------------------------------------------------------------;<_IMPORT_> - Functions to clear or import drawings
|
; --------------------------------------------------------------------------|
; <DSV_DWGPSPCLR> - Remove a paperspace block from model space.
|
; <DSV_DWGPSPBLK> - Create a block of all entities in paperspace.
|
; <DSV_DWGPSPRST> - Restore a paperspace block to paper space.
|
; <DSV_DWGLYOCLR> - Remove a layout block from model space.
|
; <DSV_DWGLYOALLCLR> - Remove all layout blocks from mspace and block tbl. |
; <DSV_DWGLYOBLK> - Create a block of all entities on the current layout. |
; <DSV_DWGLYOALLBKS> - Create a block of all entities on each layout.
|
; <DSV_DWGLYORST> - Restore a layout block to the current layout.
|
; <DSV_DWGLYOALLRST> - Restore all layout blocks to respective layouts.
|
; <DSV_DWGLYOLYS> - Get viewports with frozen layer names from layout block|
; <DSV_DWGLYOEXT> - Get the extents of a given layout block.
|
; <DSV_DWGEXPW> - Package paper space and Wblock the current drawing.
|
; <DSV_DWGIMPW> - Insert a drawing and restore paper space entities.
|
; <DSV_DWGCNVPSP> - Wblock the drawing saving model and paper space.
|
; -------------------------------------------------------------------------;
; --------------------------------------------------------------------------;<_SYSVAR_> - Functions used to manipulate system variables.
|
; --------------------------------------------------------------------------|
; <DSV_NSV> - Resets list of open sysvar changes.
|
; <DSV_KSV> - Adds or replaces a name/value pair in open sysvar changes. |
; <DSV_SSV> - SETS the current value of a system variable and adds to list.|
; <DSV_RSV> - RESETS a system variable to its saved value.
|
; <DSV_SVADD> - Adds a change to the system variable change history list. |
; <DSV_SVDB> - Displays the list of system variable change history.
|
; <DSV_NO&SV> - Restores the list of system variable changes still open. |
; <DSV_ASV> - Sets all system variables named in the Stds[SYSVARS] group. |
; <DSV_IBASE0> - Restores the insertion base system variable to 0,0,0
|
; <DSV_USERVARS> - Gets the contents of each user variable.
|
; --------------------------------------------------------------------------;

; --------------------------------------------------------------------------;<_SETTINGS_> - Control of layers, colors, linetypes and styles


|
; --------------------------------------------------------------------------|
; <DSV_SYMBTBL> - Return list of registered apps defined in the drawing
|
; <DSV_LYRSDWG> - Return list of layers defined in the drawing.
|
; <DSV_LYRFIND> - Return list of layers having a given prefix or suffix. |
; <DSV_LYRSNOT> - Return list of drawing layers that are not in the list. |
; <DSV_LYRSDEF> - Divide suplied list by whether each name is defined.
|
; <DSV_LYRSTAT> - Print and return the status of a list of drawing layers. |
; <DSV_LYRGETVIS> - Return all drawing layers visible, off, and frozen.
|
; <DSV_LYRSETVIS> - Set the global visibility of a list of layers.
|
; <DSV_LYRVLAOBJ> - Return the vla layer object for the specified layer. |
; <DSV_LYRTHWDFLT> - Return whether a given layer is thawed in new vports. |
; <DSV_LYRADD> - Add a new layer object to the current drawing.
|
; <DSV_VPRT-OBJ-LIST> - Return the vla viewport collection object.
|
; <DSV_LYRMAK> - Make sure a given layer is defined.
|
; <DSV_LYRMAK-PS> - Make a layer to be visible only in paperspace.
|
; <DSV_LYRMAK-CV> - Make a layer to be visible only in the current vport. |
; <DSV_LYRPRPSET> - Set a given layer's color and linetype.
|
; <DSV_LYRVFY> - Check if layer is defined. If so, return the layer name. |
; <DSV_LYRCHK> - Check if layer is defined. If so, return the layer name. |
; <DSV_CLYRCHK> - Check if given layer is current.
|
; <DSV_CLYRSET> - Set a layer saving the current one to return to later. |
; <DSV_CLYRPRV> - Reset to the previously saved layer name.
|
; <DSV_LYRFRZ> - Freeze a layer name globally.
|
; <DSV_LYRFRZVP> - Freeze a layer name in all viewports.
|
; <DSV_LYRTHW> - Freeze a layer name globally.
|
; <DSV_LYRTHWVP> - Thaw a layer name in all viewports.
|
; -------------------------------------------------------------------------|
; <DSV_CLRNUM> - Returns a color number no matter what is supplied.
|
; <DSV_CLRNAM> - Returns a color name no matter what is supplied.
|
; <DSV_CLRCHK> - See if the current entity color matches the specified one.|
; <DSV_CLRSET> - Set a color saving the current one to return to later.
|
; <DSV_CLRPRV> - Reset to the previously saved color name.
|
; <DSV_LYRCLRGET> - Get the color of the given layer.
|
; <DSV_LYRCLRSET> - Set the color of the given layer.
|
; -------------------------------------------------------------------------|
; <DSV_LTPMAKE> - Attempts to load the specified linetype.
|
; <DSV_LTPCHK> - See if the current ltype matches the specified.
|
; <DSV_LTPSET> - Set a linetype saving the current one to return to later. |
; <DSV_LTPPRV> - Reset to the previously saved linetype name.
|
; <DSV_LYRLTPGET> - Get the linetype of the given layer.
|
; <DSV_LYRLTPSET> - Set the linetype of the given layer.
|
; -------------------------------------------------------------------------|
; <DSV_PROPSET> - Set layer, linetype, and color names saving current ones.|
; <DSV_PROPPRV> - Reset to the saved layer, linetype, and color names.
|
; -------------------------------------------------------------------------|
; <DSV_OSNAPSET> - Set the osnap mode saving the current setting.
|
; <DSV_OSNAPPRV> - Reset to the saved osnap mode.
|
; -------------------------------------------------------------------------|
; <DSV_<VLASTYLESCOLLECT>> - Return the vla object for the text styles collecti
on.|
; <DSV_STYLENAMES> - Return the names and enames of all defined text styles.|
; <DSV_<VLADIMSTYLESCOLLECT>> - Return the vla object for the dimension styles
collection.|
; <DSV_DIMSTYLENAMES> - Return the names and enames of all defined dimension st
yles.|
; <DSV_FONTFIND> - Searches for a font file with SHX, TTF, PS, GSF, PFB. |
; <DSV_STYMAKE> - Creates or redefines a text style to specified values. |
; <DSV_STYPROPS> - Convert a string to an assoc list of style properties. |

; <DSV_STYUSED> - Return all style names referenced by text entities.


|
; <DSV_STYSTD> - Make all text reference the standard style.
|
; <DSV_STYSET> - Set a text style saving the current one to return later. |
; <DSV_STYPRV> - Reset to the saved style name.
|
; -------------------------------------------------------------------------;
; --------------------------------------------------------------------------;<_LAYOUTS_> - Subroutines used to control layouts and spaces
|
; --------------------------------------------------------------------------|
; <DS_<LYOTBL>> - Return the vla object for the layouts collection.
|
; <DS_<LYOACTV>> - Return the vla object for the current drawing.
|
; <DSV_LYOALL> - Get data and plot settings on all defined layouts.
|
; <DSV_LYOLIST> - Get all layout names and associated entity names
|
; <DSV_<LYOLIST>> - Get layout names and vlax object names by tab order. |
; <DSV_LYOENT>- Return the entity name for the given layout name.
|
; <DSV_LYOMAKE> - Define a new layout given the properties.
|
; <DSV_LYOTPLT> - Make new layout based on a given template
|
; <DSV_LYOCHG> - Change the properties of a given layout.
|
; <DSV_LYODELX> - Delete all layouts not on the given list
|
; <DSV_LYOCUR> - Return tab name of current layout.
|
; <DSV_LYOSET> - Set a specified layout as current.
|
; <DSV_LYOLOC> - Return corner points of the viewing area of a layout.
|
; <DSV_LYOLOCSET> - Verify corner points of the viewing area of a layout. |
; <DSV_LYODEL> - Delete the named layout if it exists
|
; <DSV_LYONAM> - Return layout name of a given entity
|
; <DSV_LYOSORT> - Sort entities by space and layout.
|
; -------------------------------------------------------------------------|
; <DSV_PSPCHK> - Check to see if paper space is current.
|
; <DSV_PSPSET> - Set paper space as current.
|
; <DSV_PSPMOV> - Move objects from model space to paper space.
|
; -------------------------------------------------------------------------|
; <DSV_MSPCHK> - Check to see if model space is current
|
; <DSV_MSPSET> - Set model space as current.
|
; <DSV_MSPMOV> - Move objects from paper space to model space.
|
; -------------------------------------------------------------------------;
; --------------------------------------------------------------------------;<_PLOTSETTINGS_> - Functions to control plot settings in a layout
|
; --------------------------------------------------------------------------|
; <DSV_PLTPROP> - Display all plot settings from the current layout.
|
; <DSV_PLTDVCLST> - Get a list of all available plot devices.
|
; <DSV_PLTDVCGET> - Get the current plot device for the given layout.
|
; <DSV_PLTDVCOPTS> - Get all plot device options for the given layout.
|
; <DSV_PLTDVCSET> - Change the specified plot device for the given layout. |
; <DSV_PLTPSZGET> - Get the current paper size for the given layout.
|
; <DSV_PLTPSZOPTS> - Get all paper size options for the current plot device|
; <DSV_PLTPSZSET> - Change the specified paper size for the given layout. |
; <DSV_PLTMGNGET> - Get the current paper margins for the given layout.
|
; <DSV_PLTMGNSET> - Change the current paper margins for the given layout. |
; <DSV_PLTLOCGET> - Get the current paper location for the given layout. |
; <DSV_PLTLOCSET> - Change the current paper location for the given layout.|
; <DSV_PLTIMGGET> - Get the current paper image origin for a given layout. |
; <DSV_PLTOGNGET> - Get the current paper location for the given layout. |
; <DSV_PLTOGNSET> - Change the current paper location for the given layout.|
; <DSV_PLTROTGET> - Get the current paper rotation for the given layout. |
; <DSV_PLTROTSET> - Change the current paper rotation for the given layout.|
; <DSV_PLTDIAGET> - Get the properties of the plot setting dialog.
|
; <DSV_PLTDIASET> - Set the properties of the plot settings dialog.
|
; -------------------------------------------------------------------------;

; --------------------------------------------------------------------------;<_VIEWPORTS_> - Subroutines used to control viewports


|
; --------------------------------------------------------------------------|
; <DSV_<VPTTBL>> - Return the vla object for the viewport collection.
|
; <DSV_<VPTACTV>> - Return the vla object for the current drawing.
|
; <DSV_VPEDATA> - Return entity data only if entity is a viewport.
|
; <DSV_VPMSENTS> - Get a list of MS vport enames in the current layout.
|
; <DSV_VPLYO> - Get layout name of an existing viewport.
|
; <DSV_VPIDST> - Get numerid and status of an existing viewport.
|
; <DSV_VPMSIDST> - Get ids and status of all vports on the current layout. |
; <DSV_VPCUR> - Return the entity name of the current viewport.
|
; <DSV_VPON> - Make sure all viewports on current layout are on.
|
; <DSV_VPSET> - Make the specified viewport entity the active one.
|
; <DSV_VPNAM> - Make name for viewport based on layout and id.
|
; <DSV_VPMSNAMS> - Get names of all existing vports in the current layout. |
; <DSV_VPFIND> - Return ename list of vport having a layer name prefix.
|
; <DSV_VPLOC> - Get diagonal corner points of an existing viewport.
|
; <DSV_VPMSLIST> - Find all viewports on current layout.
|
; <DSV_VPMSDWGLIST> - Get a vpinfo list for all viewports on drawing.
|
; <DSV_VPINFO> - Get list of layout id status entity name for a viewport. |
; <DSV_VPLIST> - Compile a list of VPINFO lists for all viewports.
|
; <DSV_VPPSLIST> - Find all paper space viewports and return by layout.
|
; <DSV_VPDEL> - Erase all model space viewports on current layout.
|
; <DSV_VPPROP> - Get properties of an existing viewport.
|
; <DSV_VPSIZE> - Calculate all size properties of a viewport entity.
|
; <DSV_VPREQD> - Get required center and viewport height from two ms pts. |
; <DSV_VPDSPT> - Calculate the ds point that coincides with given ms point.|
; <DSV_PSPPNT> - Calculate the ps point that coincides with given ms point.|
; <DSV_MSPPNT> - Calculate the ms point that coincides with given ps point.|
; <DSV_VPCRNRS> - Calculate the 4 paper space corner points of a viewport. |
; <DSV_VPMSPTS> - Calculate the 4 model space points at viewport corners. |
; <DSV_MSP0Z> - Get the WCS 0 elev point that coincides with a WCS point. |
; <DSV_ISPTINVP> - Is a model space point within the given viewport.
|
; -------------------------------------------------------------------------|
; <DSV_VLYGETFRZ> - Get layers currently frozen in an existing viewport. |
; <DSV_VLYGETTHW> - Get layers currently thawed in an existing viewport. |
; <DSV_VLYGETHID> - Get layers currently hidden in an existing viewport. |
; <DSV_VLYGETVIS> - Get layers currently visible in an existing viewport. |
; <DSV_VLYADDFRZ> - Add a list of layers to the ones frozen in a viewport. |
; <DSV_VLYADDTHW> - Add a list of layers to the ones visible in a viewport.|
; <DSV_VLYMAKFRZ> - Freeze a list of layers in a viewport.
|
; <DSV_VLYMAKTHW> - Make a list of layers the only ones visible in viewport|
; <DSV_VLYSETVIS> - Utilize the VPLAYER command but prevent screen messages|
; <DSV_VLYADDVIS> - Add a list of layers to the ones visible in a viewport.|
; <DSV_VLYWHRVIS> - Get viewport entities where the given layer is visible.|
; <DSV_VLYALLVIS> - Get layouts and viewports where layer(s) is/are visible|
; -------------------------------------------------------------------------;
;---------------------------------------------------------------------------;<_VIEWING_> - Subroutines used to control viewing direction
|
; --------------------------------------------------------------------------|
; <DSV_VIEWINFO> - Get view parameters of an existing viewport.
|
; <DSV_VIEWGETSCALE> - Get view scale of an existing viewport.
|
; <DSV_VIEWSETSCALE> - Set view scale of an existing viewport.
|
; <DSV_SCALE-CHK> - Set view scale of an existing viewport
|
; <DSV_VIEWEXT> - Zoom model space to extents with only viewport layers. |
; <DSV_VIEWCMD> - Commands for standard viewpoints.
|
; <DSV_VIEWSTD> - Convert standard view code to directon vector.
|
; <DSV_VIEWANEL> - Convert direction vector to orientation and elevation. |
; <DSV_VIEWVECT> - Convert orientation and elevation to a direction vector.|

; <DSV_VIEWDIR> - Convert given value to directon vector if possible.


|
; <DSV_VIEWMAKE> - Adjust model space view in viewport as specified.
|
; <DSV_VIEWPNT> - Changes the display viewing point.
|
; <DSV_VIEWSIZ> - Changes the display magnification.
|
; <DSV_VIEWCHGSIZ> - Changes the display center and magnification
|
; <DSV_VIEWHGT> - Calculates viewport height required for a given scale. |
; <DS_NORMAL> - Return extrusion directions for each of the standard views.|
; <DS_UCS2OCS> - Convert points from WCS to OCS using extrusion direction. |
; -------------------------------------------------------------------------;
; --------------------------------------------------------------------------;<_GROUPS_> - Subroutines used to control groups
|
; --------------------------------------------------------------------------|
; <DSV_GRPNAMS> - Returns all the names of groups defined as ACAD_GROUP. |
; <DSV_GRPNEXT> - Returns the data of the next (or first) ACAD_GROUP.
|
; <DSV_GRPSEARCH> - Returns the data of ACAD_GROUP with requested name.
|
; <DSV_GRPMAKE> - Creates a new ACAD_GROUP containing the given entities. |
; -------------------------------------------------------------------------;
; --------------------------------------------------------------------------;<_DICTIONARY_> - Query functions to obtain data contained in dictionaries |
; --------------------------------------------------------------------------|
; <DS_<VLADICTSCOLLECT>> - Get the vla object for the dict collection.
|
; <DS_DICTNAMES> - Return the names and enames of all defined dictionaries.|
; <DS_DICTGET> - Find or create a dictionary and return ename.
|
; <DS_DICTPUT> - Add data with a tag to the specified dictionary.
|
; <DS_DICTIDX> - get tag and ename list of all records in a dictionary.
|
; <DS_DICTDATA> - Guide through dictionary object data to see format code. |
; <DSV_DICTCODES> - Guide through dictionary object data to see format code|
; -------------------------------------------------------------------------; --------------------------------------------------------;--Dwg Values:
; --------------------------------------------------------;DwgsCollection{VLA} -------------- (dsv_<dwgstable>)
;DwgsOpenList{VLA} ---------------- (dsv_<dwgslist>)
;ActiveDwg{VLA} ------------------- (dsv_<dwgactv>)
;UtilityObject{VLA} --------------- (dsv_<util>)
;PaperSpaceCollection{VLA} -------- (dsv_<pspctbl>)
;ModelSpaceCollection{VLA} -------- (dsv_<mspctbl>)
;BlocksCollection{VLA} ------------ (dsv_<blktbl>)
;BlocksList{VLA} ------------------ (dsv_<blkslist>)
;InsertsByName -------------------- (dsv_<blkrefs> BKNAM)
;BlockObject/Ename ---------------- (dsv_<BlkObj> BKNAM)
; --------------------------------------------------------;DwgWidth ------------------------- (dsv_dwgwidth)
;DwgHeight ------------------------ (dsv_dwgheight)
;DwgDepth ------------------------- (dsv_dwgdepth)
;DwgSize(WidxHgt) ----------------- (dsv_dwgsize)
;DwgMax --------------------------- (dsv_dwgmax)
;DwgCenter ------------------------ (dsv_dwgcenter)
;ScreenSize ----------------------- (dsv_dwgscrsiz)
; --------------------------------------------------------;DwgSaveAs ------------------------ (dsv_dwgsave PATHNAME)
;DwgClear ------------------------- (dsv_dwgclear)
;DwgEmpty? ------------------------ (dsv_dwgempty)
; --------------------------------------------------------;LoadDwg -------------------------- (dsv_dwgload FIL)
;LoadDwgWith'OpenDwg.scr'Scr ------ (dsv_openscr FIL)
;LoadDwgCommand ------------------- (c:loaddwg)

;ReLoadDwgCommand ----------------- (c:reopen)


; --------------------------------------------------------------------------;
;{{<_IMPORT_>****************************************************************
;
*
; Functions to clear or import drawings
*
;
*
; }**************************************************************************
;
; { <DSV_DWGPSPCLR>==========================================================
; Remove a paperspace block from model space.
|
; --------------------------------------------------------------------------(defun DSV_DWGPSPCLR (/ SS)
(if (ds_verac 13)
(progn
(if (ds_verac 15)
(setvar "CTAB" "Model")
;set model space
(dsv_mspset)
;set model space
)
(if (setq SS (ssget "X" (list (cons 0 "INSERT")(cons 2 "PAPERSPACE"))))
(ds_command "_.ERASE" (list SS ""))
;erase inserts found
)
(dse_prgall)
(if (tblsearch "BLOCK" "PAPERSPACE")(dse_prgblk "PAPERSPACE"))
(null (tblsearch "BLOCK" "PAPERSPACE"))
)
)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_DWGPSPCLR")
; }
;
; { <DSV_DWGPSPBLK>==========================================================
; Create or refresh a block of all entities that are on paperspace.
|
; If KEEP! is not nil do not erase the original entities that were blocked. |
; --------------------------------------------------------------------------(defun DSV_DWGPSPBLK (KEEP! / SS LYO RET)
(if (ds_verac 13)
(progn
(dsv_dwgpspclr)
;remove any paperspace blocks
(dsv_pspset)
;set paper space
(if (null (setq SS (ssget "X" (list (cons 67 1)))))
;get entities
(progn
(ds_command "_.POINT" (list "0,0"))
;if no entities make one
(setq SS (ssget "X" (list (cons 67 1))))
)
)
;(setvar "CMDECHO" 1)
(dsv_ssv "EXPERT" 4)
(ds_command "_.BLOCK" (list "PAPERSPACE" "0,0" SS ""))
(dsv_rsv "EXPERT")
(if KEEP! (ds_command "_.OOPS" nil))
(dsv_ssv "ATTREQ" 0)
(dsv_mspset)
;set model space
(ds_command "_.INSERT" (list "PAPERSPACE" "0,0" "0.0001" "0.0001" "0"))
;(setvar "CMDECHO" 0)
(dsv_rsv "ATTREQ")
(if (setq SS (ssget "X" (list (cons 0 "INSERT")(cons 2 "PAPERSPACE"))))
(setq RET T)
)

(dsv_pspset)

;set paper space

)
)
RET
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_DWGPSPBLK")
; }
;
; { <DSV_DWGPSPRST>==========================================================
; Restore a paperspace block to paper space.
|
; --------------------------------------------------------------------------(defun DSV_DWGPSPRST (/ OK! E SS RET)
(if (ds_verac 13)
(if (tblsearch "BLOCK" "PAPERSPACE")
;if paperspace block is defined
(progn
(princ "\nRestoring Paper Space.")
(if (ds_verac 15)
(progn
(setvar "USERS1" "P")
;mark for existing mode
(setq OK! (dsv_lyomake "All_Pages"))
;make layout from scratch
(dsv_lyodelx (list "All_Pages"))
;delete all except
(setvar "CTAB" "All_Pages")
(if (setq SS (ssget "X" (list (cons 67 1)(cons 410 "All_Pages"))))
(ds_command "_.ERASE" (list SS ""))
;erase everything
)
)
(if (setq SS (ssget "X" (list (cons 67 1))))
;get entities
(ds_command "_.ERASE" (list SS ""))
;erase inserts found
)
)
(dsv_pspset)
;set paper space
(setq E (entlast))
(ds_command "_.INSERT" (list "*PAPERSPACE" "0,0" "1.0" "0"))
(if (/= E (entlast))(setq RET T))
(dsv_vpon)
;turn on all viewports
(dsv_pspset)
;set paper space
(ds_command "_.ZOOM" (list "E"))
)
)
)
RET
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_DWGPSPRST")
; }
;
; { <DSV_DWGLYOCLR>==========================================================
; Remove a layout block from model space and block table.
|
; --------------------------------------------------------------------------(defun DSV_DWGLYOCLR (LYO / SS RET)
(if (ds_verac 15)
(progn
(dsv_dwgpspclr)
;remove any paperspace blocks
(setvar "CTAB" "Model")
;set model space
(if (entlast)
(if (setq SS (ssget "X" (list (cons 0 "INSERT")(cons 2 LYO))))
(ds_command "_.ERASE" (list SS ""))
;erase all inserts found
)

)
(if (tblsearch "BLOCK" LYO)(dse_prgblk LYO))
(if (null (tblsearch "BLOCK" LYO))(setq RET T))

;purge block

)
)
RET
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_DWGLYOCLR")
; }
;
; { <DSV_DWGLYOALLCLR>=======================================================
; Remove all layout blocks from model space and block table.
|
; --------------------------------------------------------------------------(defun DSV_DWGLYOALLCLR (/ RET CLYO)
(if (ds_verac 15)
;do layouts exist?
(progn
(setq RET T)
;assume everything will work
(setq CLYO (getvar "CTAB"))
(foreach LYO (layoutlist)
(setvar "CTAB" LYO)
(if (null (dsv_dwglyoclr LYO))(setq RET nil))
;one didn't work
)
(setvar "CTAB" CLYO)
)
)
RET
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_DWGLYOALLCLR")
; }
;
; { <DSV_DWGLYOBLK>==========================================================
; Create or refresh a block of all entities on the current layout.
|
; If KEEP! is not nil do not erase the original entities that were blocked. |
; --------------------------------------------------------------------------(defun DSV_DWGLYOBLK (KEEP! / LYO SS RET)
(setvar "EXPERT" 4)
(if (ds_verac 15)
;do layouts exist?
(progn
(setq LYO (getvar "CTAB"))
(dsv_dwgpspclr)
;remove any paperspace blocks
(dsv_dwglyoclr)
;remove blocks for this layout
(dsv_pspset)
;set paper space
(if (null (setq SS (ssget "X" (list (cons 67 1)(cons 410 LYO)))))
(progn
(ds_command "_.POINT" (list "0,0"))
;if no entities make one
(setq SS (ssget "X" (list (cons 67 1)(cons 410 LYO))))
)
)
(ds_command "_.BLOCK" (list LYO "0,0" SS ""))
(if KEEP! (ds_command "_.OOPS" nil))
(dsv_mspset)
;set model space
(dsv_ssv "ATTREQ" 0)
(ds_command "_.INSERT" (list LYO "0,0" "0.0001" "0.0001" "0"))
(dsv_rsv "ATTREQ")
(if (setq SS (ssget "X" (list (cons 0 "INSERT")(cons 2 LYO))))
(setq RET T)

)
(dsv_pspset)

;set paper space


)
(princ "[DwgLyoBlk] Layouts not supported in this AutoCad release.")
)
(setvar "EXPERT" 0)
RET

;return T if successful
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_DWGLYOBLK")
; }
;
; { <DSV_DWGLYOALLBKS>=======================================================
; Create or refresh a block of all entities on each layout.
|
; If KEEP! is not nil do not erase the original entities that were blocked. |
; --------------------------------------------------------------------------(defun DSV_DWGLYOALLBKS (KEEP! / RET CLYO SS RET)
(if (ds_verac 15)
;do layouts exist?
(progn
(setq RET T)
(setq CLYO (getvar "CTAB"))
(foreach LYO (layoutlist)
(setvar "CTAB" LYO)
(if (null (dsv_dwglyoblk KEEP!))(setq RET nil))
)
(setvar "CTAB" CLYO)
)
)
RET
)
; --------------------------------------------------------------------------(defun C:LYOBLKS ()(dsv_dwglyoallbks))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_DWGLYOALLBKS")
; }
;
; { <DSV_DWGLYORST>==========================================================
; Restore a layout block to paper space of the current layout.
|
; Return the layout name if successful.
|
; --------------------------------------------------------------------------(defun DSV_DWGLYORST (LYO / E OK! SS RET)
(if (ds_verac 15)
(if (tblsearch "BLOCK" LYO)
;if layout block is defined
(progn
(dsv_pspset)
;set paper space
(setq E (entlast))
(if (member LYO (layoutlist))
(setvar "CTAB" LYO)
(setq OK! (dsv_lyomake LYO))
)
(if (setq SS (ssget "X" (list (cons 67 1)(cons 410 LYO))))
(ds_command "_.ERASE" (list SS ""))
;erase everything
)
(ds_command "_.INSERT" (list (strcat "*" LYO) "0,0" "1.0" "0"))
(dsv_vpon)
;turn on all viewports
(dsv_pspset)
;set paper space
(ds_command "_.ZOOM" (list "E"))
(if (/= E (entlast))(setq RET LYO))
)
)

)
RET
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_DWGLYORST")
; }
;
; { <DSV_DWGLYOALLRST>=======================================================
; Restore all layout blocks to their respective layouts.
|
; --------------------------------------------------------------------------(defun DSV_DWGLYOALLRST (/ PG LYO RET)
(if (ds_verac 15)
;do layouts exist?
(progn
;Note: increment page names from cfg file
(setq PG "Page00")
(setq PG (dsk_fmtint PG 1 2))
(while (tblsearch "BLOCK" PG)
(if (setq LYO (dsv_dwglyorst PG))(setq RET (cons LYO RET)))
)
)
)
RET
)
; --------------------------------------------------------------------------(defun C:LYORSTS ()(dsv_dwglyoallrst))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_DWGLYOALLRST")
; }
;
; { <DSV_DWGLYOLYS>==========================================================
; Return a list of viewports with frozen layer names from layout block.
|
; --------------------------------------------------------------------------(defun DSV_DWGLYOLYS (PG / TD E ED VPL&)
(if (setq TD (tblsearch "BLOCK" PG))
;old style drawing
(progn
(setq E (cdr (assoc -2 TD)))
(while E
;look at all entities in block def
(setq ED (entget E))
(if (= (cdr (assoc 0 ED)) "VIEWPORT")
(setq VPL& (cons (list E (dsv_vlygetfrz E)) VPL&))
)
(setq E (entnext E))
)
)
)
VPL&
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_DWGLYOLYS")
; }
;
; { <DSV_DWGLYOEXT>==========================================================
; Return a list of 2 points with the extents of a given layout block.
|
; --------------------------------------------------------------------------(defun DSV_DWGLYOEXT (PG / TD E LOC LOC& RET)
(if (setq TD (tblsearch "BLOCK" PG))
;old style drawing
(progn
(setq E (cdr (assoc -2 TD)))
(while E
;look at all entities in block def
(setq LOC (ds_getextents E nil))

(setq LOC& (append LOC& LOC))


(setq E (entnext E))
)
(setq RET (ds_boxboundary LOC&))
)
)
RET
)
; --------------------------------------------------------------------------(defun C:DWGLYOEXT01 ()(dsv_dwglyoext "PAGE01"))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_DWGLYOEXT")
; }
;
; { <DSV_DWGEXPW>============================================================
; Wblock the current drawing so that paper space entities contained can be |
; inserted later.
|
; --------------------------------------------------------------------------(defun DSV_DWGEXPW (PTHDWG / LYO RET)
(setvar "EXPERT" 4)
(cond
((ds_verac 15)
(if (= (getvar "USER1") "P")
(dsv_dwgpspblk nil)
(dsv_dwglyoallbks nil)
)
(setvar "CTAB" "Model")
)
((ds_verac 13)
(dsv_dwgpspblk nil)
(dsv_mspset)
)
)
(ds_command "_.WBLOCK" (list PTHDWG "*"))
(setq RET (findfile PTHDWG))

;put in a new one


;set model space
;put in a new one
;set model space
;wblock dwg to archive
;check if it got written

)
; --------------------------------------------------------------------------(defun C:WBLKD ()(dsv_dwgexpw (strcat (ds_wrkpth)(ds_username))))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_DWGEXPW")
; }
;
; { <DSV_DWGIMPW>============================================================
; Insert the named drawing so that blocked paper space entities contained |
; are visible and active.
|
; --------------------------------------------------------------------------(defun DSV_DWGIMPW (SRC / ERR F E RET)
;sample arguments (setq SRC "K:\\Cpak\\Addtest\\Validate\\P75997.DWG")
(if (and (setq ERR (strcat "Improper name for SRC: " (ds_frcstr SRC)))
(ds_isstrval? SRC)
(setq SRC (ds_exten "dwg" SRC))
(setq ERR (strcat "Can not find SRC: " (ds_frcstr SRC)))
(setq F (findfile SRC))
(setq ERR "")
)
(progn
(dsv_dwgclear)
(setvar "EXPERT" 4)
(cond

((ds_verac 15)
(setvar "CTAB" "Model")
(setq E (entlast))
(ds_command "_.-INSERT" (list (strcat "*" F) "0,0" "1" "0"))
(if (/= E (entlast))(setq RET T))
(ds_command "_.ZOOM" (list "E"))
;view all entities
(if (tblsearch "BLOCK" "PAPERSPACE")
;old style drawing
(dsv_dwgpsprst)
(dsv_dwglyoallrst)
)
)
((ds_verac 13)
(dsv_mspset)
;set model space
(setq E (entlast))
(ds_command "_.INSERT" (list (strcat "*" F) "0,0" "1" "0"))
(ds_command "_.ZOOM" (list "E"))
;view all entities
(if (tblsearch "BLOCK" "PAPERSPACE")
;old style drawing
(ds_command "_.INSERT" (list "*PAPERSPACE" "0,0" "1" "0"))
)
(ds_command "_.ZOOM" (list "E"))
(ds_command "_.ZOOM" (list ".95x"))
(dsv_vpon)
(if (/= E (entlast))(setq RET T))
)
)
)
(princ (strcat "\n" ERR))
)
RET
)
; --------------------------------------------------------------------------(defun C:DWGIMPW (DWG)
(if (setq DWG (getfiled "Drawing to Import" "" "dwg" 2))
(dsv_dwgimpw DWG)
)
)
; --------------------------------------------------------------------------(defun DSV_DWGIMPW_TEST ()
;(dsv_dwgimpw "E:\\Add\\Validate\\P56906.DWG")
(dsv_dwgimpw "K:\\Cpak\\Addtest\\Validate\\P75997.DWG")
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_DWGIMPW")
; }
;
; { <DSV_DWGCNVPSP>==========================================================
; Wblock the current drawing so that paper space entities contained can be |
; inserted later.
|
; --------------------------------------------------------------------------(defun DSV_DWGCNVPSP (PTHDWG / LYO RET)
(setvar "EXPERT" 4)
(cond
((ds_verac 15)
(if (= (getvar "USER1") "P")
(dsv_dwgpspblk nil)
(dsv_dwglyoallbks nil)
)
(setvar "CTAB" "Model")
)

;put in a new one


;set model space

((ds_verac 13)
(dsv_dwgpspblk nil)
(dsv_mspset)
)
)
(ds_command "_.WBLOCK" (list PTHDWG "*"))
(setq RET (findfile PTHDWG))

;put in a new one


;set model space
;wblock dwg to archive
;check if it got written

)
; --------------------------------------------------------------------------(defun C:WBLKD ()(dsv_dwgexpw (strcat (ds_wrkpth)(ds_username))))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_DWGCNVPSP")
; }
;
; { <DSV_TMPOUT>=============================================================
; Create an external file for transfering selected entities between drawings|
; --------------------------------------------------------------------------(defun DSV_TMPOUT (SS FIL ASK / FILE P)
(if (null SS)
(progn
(princ "\nSelect objects to transfer: ")
(setq SS (ssget))
)
)
(if (and SS (= (type SS) 'PICKSET)(> (sslength SS) 0))
(progn
(ds_ssv "EXPERT" 2)
(if ASK
(progn
(command ".WBLOCK" FIL "")
(initget 15)
(if (setq P (getpoint "\nReference Base point: "))(command P))
(command SS "")
)
(command ".WBLOCK" FIL "" "0,0" SS "")
)
(if (setq FILE (findfile (strcat FIL ".DWG")))
(princ (strcat "\nExternal drawing file " FILE " created."))
)
(ds_rsv "EXPERT")
)
)
)
; --------------------------------------------------------------------------(defun C:TMPOUT ()(dsv_tmpout nil "TMP" nil))
; --------------------------------------------------------------------------(defun C:TEMPOUT ()(dsv_tmpout nil "TEMP" nil))
; --------------------------------------------------------------------------(defun C:BLKOUT ()(dsv_tmpout nil "TMP" T))
; --------------------------------------------------------------------------(defun C:BLOCKOUT ()(dsv_tmpout nil "TEMP" T))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_TMPOUT")
; }
;
; { <DSV_TMPIN>==============================================================
; Import the external file for transfering selected entities between drawings
; --------------------------------------------------------------------------(defun DSV_TMPIN (FIL ASK / FNAM FILE P)
(setq FNAM (strcat FIL ".DWG"))

(if (setq FILE (findfile FNAM))


(progn
(princ (strcat "\nExternal drawing file " FILE " found."))
(if ASK
(progn
(command ".INSERT" (strcat "*" FNAM))
(initget 15)
(if (setq P (getpoint "\nReference Base point: "))(command P))
(command "1.0" "0")
)
(command ".INSERT" (strcat "*" FNAM) "0,0" "1.0" "0")
)
)
(if (setq FNAM (getfiled "Specify Directory" "" "DWG" 2))
(if ASK
(progn
(command ".INSERT" (strcat "*" FNAM))
(initget 15)
(if (setq P (getpoint "\nReference Base point: "))(command P))
(command "1.0" "0")
)
(command ".INSERT" (strcat "*" FNAM) "0,0" "1.0" "0")
)
)
)
(princ)
)
; --------------------------------------------------------------------------(defun C:TMPIN ()(dsv_tmpin "TMP" nil))
; --------------------------------------------------------------------------(defun C:TEMPIN ()(dsv_tmpin "TEMP" nil))
; --------------------------------------------------------------------------(defun C:BLKIN ()(dsv_tmpin "TMP" T))
; --------------------------------------------------------------------------(defun C:BLOCKIN ()(dsv_tmpin "TEMP" T))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_TMPIN")
; }
;}
;{{<_SYSVAR_>****************************************************************
;
*
; Commands used to manipulate system variables
*
;
*
; }**************************************************************************
;
; { <DSV_NSV>================================================================
; Resets list of open sysvar changes.
|
; --------------------------------------------------------------------------|
; Global: {DSV_&SV_}
|
; Return: nil
|
; --------------------------------------------------------------------------(defun DSV_NSV ()(setq DSV_&SV nil) T) ;reinitialize current changed sysvars
(dsv_nsv)
;run routine on loading
; --------------------------------------------------------------------------(defun DS_NSV ()(dsv_nsv))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_NSV")
; }
;
; { <DSV_KSV>================================================================

; Adds or replaces a name/value pair in DSV_&SV_ with the current value of |


; the system variable named N.
|
; --------------------------------------------------------------------------|
; Input: N = name of system variable
|
; Global: {DSV_&SV,DSV_!SV,DSV_&SV_}
|
; Return: previous saved value or nil
|
; --------------------------------------------------------------------------(defun DSV_KSV (N / F$ V O)
(setq F$ (func_in "DSV_KSV" "N"))
(setq V (getvar N))
;current value
(if (and (listp DSV_&SV_)(setq O (assoc N DSV_&SV))) ;N already in DSV_&SV
(setq DSV_&SV (subst (list N V) O DSV_&SV)) ;replace with current value
(setq DSV_&SV (cons (list N V) DSV_&SV))
;add to list
)
(if DSV_!SV
;save history if flag set
(setq DSV_&SV_ (cons (list N "{set}" V "{old}" (cadr O)) DSV_&SV_))
)
(func_ex F$ (cadr O))
;return previous value
)
; --------------------------------------------------------------------------(defun DS_KSV (N)(dsv_ksv N))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_KSV")
; }
;
; { <DSV_SSV>================================================================
; Sets the current value of the system variable named N to V and saves all |
; previous values in a key list with the variable name. If a key list is |
; not present with the variable name it is created and added to DSV_&SV.
|
; Returned the most recent previous value.
|
; --------------------------------------------------------------------------|
; Input: N = name of system variable (string)
|
;
V = value to set (unknown)
|
; Local: X = current sysvar value (unknown)
|
;
M = message to log on error
|
; Global: {DSV_&SV,DSV_!SV,DSV_&SV_}
|
; Return: current value of sysvar
|
; --------------------------------------------------------------------------(defun DSV_SSV (N V / F$ X L M L& LN LV)
(setq F$ (func_in "DSV_SSV" (list "N" "V")))
(setq N (strcase N) X (getvar N))
;get current value
(setq V (ds_matchtype V X))
;change to correct data type
(if (ds_islist? DSV_&SV)
(if (setq L& (assoc N DSV_&SV))
;N is already in DSV_&SV
(progn
(setq LN (car L&) LV (cons X (cadr L&)))
(setq DSV_&SV (subst (list LN LV) L& DSV_&SV))
;add V to list
)
(progn
(setq DSV_&SV (cons (list N (list X)) DSV_&SV))
;add N to list
)
)
(progn
(setq DSV_&SV (list (list N (list X))))
;new list
)
)
(setvar N V)
;change system variable
(dsv_svadd N "{s}" X V)
;save history if flag set
(func_ex F$ X)
;return previous value
)

; --------------------------------------------------------------------------(defun DS_SSV (N V)(dsv_ssv N V))


; --------------------------------------------------------------------------(defun SSV_TEST ()
(ds_ssv "CMDECHO" 1)
(ds_ssv "OSMODE" 0)
(ds_ssv "ORTHOMODE" 0)
(ds_ssv "EXPERT" 0)
(ds_ssv "OSMODE" 53)
(ds_ssv "OSMODE" 22)
(ds_rsv "OSMODE")
(ds_rsv "OSMODE")
(ds_ssv "HIGHLIGHT" 1)
(ds_ssv "TEXTEVAL" 1)
(ds_rsv "OSMODE")
(ds_rsv "ORTHOMODE")
(ds_ssv "DRAGMODE" 2)
)
;(ssv_test)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_SSV")
; }
;
; { <DSV_RSV>================================================================
; RESETS the system variable named N to its most recent value in DSV_&SV_ |
; and removes that value from the keylist of the variable in DSV_&SV. If |
; there are no remaining settings for the variable, it the variable name is |
; removed from DSV_&SV. If N is "*" all values in DSV_&SV are reset to the |
; original value. Returns T if a value was present to reset to.
|
; --------------------------------------------------------------------------|
; Input: N = name of system variable (string)
|
; Local: X = current value of sysvar
|
;
Z = saved name value pair (list)
|
;
&S = temporary open changes list
|
; Global: {DSV_&SV,DSV_!SV,DSV_&SV_}
|
; Return: supressed
|
; --------------------------------------------------------------------------(defun DSV_RSV (N / F$ X L& D& V &S RET NL&)
(setq F$ (func_in "DSV_RSV" "N"))
(setq X (getvar N))
(if (ds_islist? DSV_&SV)
(if (setq L& (assoc (strcase N) DSV_&SV))
(progn
(setq D& (cadr L&) V (car D&))
;previous settings
(setvar N V)
(dsv_svadd N "{r}" X V)
;save history if flag set
(setq RET (= (getvar N) V))
(if (> (length D&) 1)
(setq NL& (subst (cdr D&) D& L&) DSV_&SV (subst NL& L& DSV_&SV))
(setq DSV_&SV (dsk_listdel L& DSV_&SV))
)
)
(progn
(if (= N "*")
(progn
(foreach V DSV_&SV
(setvar (car V)(last (cadr V)))
(dsv_svadd N "{r}" X V)
;save history if flag set
)
(setq DSV_&SV nil)
(setq RET T)

)
)
)
)
)
(func_ex F$ RET)
)
; --------------------------------------------------------------------------(defun DS_RSV (N)(dsv_rsv N))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_RSV")
; }
;
; { <DSV_SVADD>==============================================================
; Adds a change to the system variable change history list.
|
; --------------------------------------------------------------------------|
; Local: N = sysvar name (string)
|
;
F_SV = each saved sysvar name and data pair (list)
|
; Return: supressed
|
; --------------------------------------------------------------------------(defun DSV_SVADD (N OP OV NV / GP NGP)
(if DSV_!SV
;save history if flag set
(progn
(if (setq GP (assoc N DSV_&SV_))
;{N {OP OV NV}{OP OV NV}}
(setq NGP (append GP (list (list OP OV NV)))
DSV_&SV_ (subst NGP GP DSV_&SV_)
)
(setq DSV_&SV_ (cons (list N (list OP OV NV)) DSV_&SV_))
)
)
)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_SVADD")
; }
;
; { <DSV_SVDB>===============================================================
; Displays the list of system variable change history.
|
; --------------------------------------------------------------------------|
; Local: N = sysvar name (string)
|
;
F_SV = each saved sysvar name and data pair (list)
|
; Return: supressed
|
; --------------------------------------------------------------------------(defun C:SV_DB ()
(if DSV_&SV
(foreach F_SV (reverse DSV_&SV)(terpri)(prin1 F_SV))
(princ "\nNo SysVar changes are pending. ")
)
(if DSV_&SV_
(foreach F_SV (reverse DSV_&SV_)(terpri)(prin1 F_SV))
(princ "\nNo SysVar history is available. ")
)
(prin1)

;supress return
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_SVDB")
; }
;
; { <DSV_NO&SV>==============================================================

; Restores the list of system variable changes still open.


|
; --------------------------------------------------------------------------|
; Local: N = counter of open changes (integer)
|
;
F_SV = each saved sysvar name and data pair
|
; Global: {DSV_&SV_}
|
; Return: qty of sysvars restored (integer)
|
; --------------------------------------------------------------------------(defun DSV_NO&SV (SHOW / N)
(setq N (length DSV_&SV))
(if (and SHOW (> N 0))
(progn (princ "\nRestoring ")(prin1 N)(princ " system values:"))
)
(foreach F_SV DSV_&SV (dsv_rsv (car F_SV)))
;reset system vars
(setq DSV_&SV nil) N
;return qty of system vars changed
)
; --------------------------------------------------------------------------(defun DS_NO&SV ()(dsv_no&sv T))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_NO&SV")
; }
;
; { <DSV_ASV>================================================================
; Sets values all system variables found in the Stds cfg [SYSVARS] group. |
; Uses GLOBAL variables: {CFG_STD$,CFG_STD&,DS_RPT}
|
; --------------------------------------------------------------------------(defun DSV_ASV (/ VARS VARN NVAL QUE SS CVAL CHG)
(if DS_RPT (princ "\nChanging SysVars..."))
(if (null CFG_STD$)(setq CFG_STD$ (ds_stdcfg)))
(if (setq VARS (getstds "SYSVARS"))
(progn
(foreach VAR VARS
(setq VARN (car VAR) NVAL (cadr VAR)) ;variable name & desired new value
(if (= VARN "DIMSTYLE")(setq QUE (cons VAR QUE) NVAL ""))
(if (member VARN (list "DIMTXSTY" "TEXTSTYLE"))
(progn
(dse_chksty (strcase NVAL))
(if (null (tblsearch "STYLE" NVAL))(setq NVAL ""))
)
)
(if (member VARN (list "DIMBLK"))
(if (and
(ds_blkchk NVAL)
(setq SS (dse_insblk NVAL "0,0" "1" "0"))
)
(ds_command "_.ERASE" (list SS ""))
(setq QUE (cons VAR QUE) NVAL "")
)
)
(if (and
(setq CVAL (getvar VARN))
;if variable name is vali
d
NVAL (/= NVAL "")

;value is specifie

d
)
(progn
(cond
((ds_isstr? CVAL)(setq NVAL (strcase NVAL)))
((= (type CVAL)(quote REAL))(setq NVAL (ds_frcreal NVAL)))
((= (type CVAL)(quote INT))(setq NVAL (ds_frcint NVAL)))

((and (= (type CVAL)(quote LIST))(= (length CVAL) 2))


(setq NVAL (ds_2dpoint NVAL))
)
((and (= (type CVAL)(quote LIST))(= (length CVAL) 3))
(setq NVAL (ds_3dpoint NVAL))
)
)
(if (/= CVAL NVAL)
(progn
(setq CHG T)
;(if DS_RPT
(progn
(princ "\nChanging ")(prin1 VARN)
(princ " from ")(prin1 CVAL)
(princ " to ")(prin1 NVAL)
)
;)
(setvar VARN NVAL)
)
)
)
)
)
(if CHG (progn (ds_cmdstop "*")(terpri)(command "_.REGEN")))
(terpri)
)
;
(log_err "SYSVARS group not found" (list "ASV" (list "CFG_STD$")(list CFG_S
TD$)))
)
)
; --------------------------------------------------------------------------(defun DS_ASV ()(dsv_asv))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_ASV")
; }
;}
;
; { <DSV_IBASE0>=============================================================
; Restores the insertion base system variable to 0,0,0
|
; --------------------------------------------------------------------------|
; Return: new insertion base point (point list)
|
; --------------------------------------------------------------------------(defun DSV_IBASE0 ()
(setvar "INSBASE" (origin))
;unconditionally change
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_IBASE0")
; }
;
; { <DSV_USERVARS>===========================================================
; Gets the contents of each user variable.
|
; --------------------------------------------------------------------------|
; Return: existing values (assoc list)
|
; --------------------------------------------------------------------------(defun DSV_USERVARS (/ RET)
(setq RET (cons (list "USERI1" (getvar "USERI1")) RET))
(setq RET (cons (list "USERI2" (getvar "USERI2")) RET))
(setq RET (cons (list "USERI3" (getvar "USERI3")) RET))
(setq RET (cons (list "USERI4" (getvar "USERI4")) RET))
(setq RET (cons (list "USERI5" (getvar "USERI5")) RET))

(setq RET (cons


(setq RET (cons
(setq RET (cons
(setq RET (cons
(setq RET (cons
(setq RET (cons
(setq RET (cons
(setq RET (cons
(setq RET (cons
(setq RET (cons
(reverse RET)

(list
(list
(list
(list
(list
(list
(list
(list
(list
(list

"USERR1"
"USERR2"
"USERR3"
"USERR4"
"USERR5"
"USERS1"
"USERS2"
"USERS3"
"USERS4"
"USERS5"

(getvar
(getvar
(getvar
(getvar
(getvar
(getvar
(getvar
(getvar
(getvar
(getvar

"USERR1"))
"USERR2"))
"USERR3"))
"USERR4"))
"USERR5"))
"USERS1"))
"USERS2"))
"USERS3"))
"USERS4"))
"USERS5"))

RET))
RET))
RET))
RET))
RET))
RET))
RET))
RET))
RET))
RET))

)
; --------------------------------------------------------------------------(defun C:USERVARS ()(foreach V (dsv_uservars)(terpri)(prin1 V)))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_IBASE0")
; }
;}
;{{<_SETTINGS_>**************************************************************
;
*
; Subroutines used to control layers, colors, linetypes, styles and space *
;
*
; }**************************************************************************
;
; { <DSV_SYMBTBL>============================================================
; Return list of registered apps defined in the drawing
|
; --------------------------------------------------------------------------(defun DSV_SYMBTBL (TBL / F$ DAT NAM RET)
(setq F$ (func_in "DSV_SYMBTBL" "TBL"))
(setq DAT (tblnext TBL T))
(while DAT
(setq NAM (cdr (assoc 2 DAT)))
(setq RET (cons NAM RET))
(setq DAT (tblnext TBL))
)
(if RET (setq RET (reverse RET)))
(func_ex F$ RET)
;return list of named items in table
)
; --------------------------------------------------------------------------;(setq ALLAPPID& (dsv_symbtbl "APPID"))
;(setq ALLDIMSTYLE& (dsv_symbtbl "DIMSTYLE"))
;(setq ALLLAYER& (dsv_symbtbl "LAYER"))
;(setq ALLLTYPE& (dsv_symbtbl "LTYPE"))
;(setq ALLSTYLE& (dsv_symbtbl "STYLE"))
;(setq ALLUCS& (dsv_symbtbl "UCS"))
;(setq ALLVIEW& (dsv_symbtbl "VIEW"))
;(setq ALLVPORT& (dsv_symbtbl "VPORT"))
(setq DSEVMT@ "DSV_SYMBTBL")
; }
;
; { <DSV_LYRSDWG>============================================================
; Return list of layers defined in the drawing
|
; --------------------------------------------------------------------------(defun DSV_LYRSDWG (/ F$ DAT NAM RET)
(setq F$ (func_in "DSV_LYRSDWG" nil))
(setq RET (dsv_symbtbl "LAYER"))
(func_ex F$ RET)
;return list of layer names
)
;(setq ALLLYRS& (dsv_lyrsdwg))
; --------------------------------------------------------------------------(defun DSV_LYRALL ()(dsv_lyrsdwg))

; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYRSDWG")


; }
;
; { <DSV_LYRSFIND>===========================================================
; Return list of layers having the given string as a prefix or a suffix
|
; --------------------------------------------------------------------------(defun DSV_LYRSFIND (ID / F$ DAT LN NAM RET)
(setq F$ (func_in "DSV_LYRSFIND" "ID"))
(setq DAT (tblnext "LAYER" T))
(setq LN (if (ds_isstrval? ID)(strlen ID) 0))
(if (/= LN 0)(setq ID (strcase ID)))
(while DAT
(setq NAM (cdr (assoc 2 DAT)))
(if (= LN 0)
(setq RET (cons NAM RET))
(if
(and
(> (strlen NAM) LN)
(or
(= (strcase (substr NAM 1 LN)) ID)
;prefix
(= (strcase (substr NAM (- (1+ (strlen NAM)) LN))) ID)
;suffix
)
)
(setq RET (cons NAM RET))
)
)
(setq DAT (tblnext "LAYER"))
)
(if RET (setq RET (reverse RET)))
(func_ex F$ RET)
;return list of layer names
)
;(dsv_lyrsfind LY)
; --------------------------------------------------------------------------(defun DSV_LYRFIND (ID)(dsv_lyrsfind ID))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYRSFIND")
; }
;
; { <DSV_LYRSNOT>============================================================
; Return list of drawing layers that are not in the supplied list
|
; --------------------------------------------------------------------------(defun DSV_LYRSNOT (LYRS& / F$ DLYRS& RET)
(setq F$ (func_in "DSV_LYRSNOT" "LYRS&"))
(setq DLYRS& (dsv_lyrsdwg))
;start with all defined layers
(if (ds_islist? LYRS&)
;check that given list is valid
(foreach F_LYR (reverse DLYRS&)
;go through defined layers
(if (not (member F_LYR LYRS&))
;if layer is not one of given
(setq RET (cons F_LYR RET))
;add to return list
)
)
(setq RET DLYRS&)
;no names given so return all layers
)
(func_ex F$ RET)
;return list of layer names
)
; --------------------------------------------------------------------------(defun DSV_LYRNOT (LYRS&)(dsv_lyrsnot LYRS&))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYRSNOT")
; }
;

; { <DSV_LYRSDEF>============================================================
; Divide suplied list by whether each is defined in the drawing.
|
; --------------------------------------------------------------------------(defun DSV_LYRSDEF (LYRS& / F$ DLYRS OK& BAD&)
(setq F$ (func_in "DSV_LYRSDEF" "LYRS&"))
(if (ds_islist? LYRS&)
;check that given list is valid
(progn
(setq DLYRS (reverse (dsv_lyrsdwg)))
;start with all defined layers
(foreach F_LYR LYRS&
;go through given layers
(if (ds_membstr F_LYR DLYRS)
;if layer is on list of valid
(setq OK& (cons F_LYR OK&))
;add to return list
(setq BAD& (cons F_LYR BAD&))
;else add to bad list
)
)
(if BAD& (func_trc F$ "Layers are not defined" (list "BAD&")))
;log bad layers
)
(func_msg F$ "Bad data" (list "LYRS&"))
;log bad given list
)
(func_ex F$ (list OK& BAD&))
;return 2 lists of layer names
)
; --------------------------------------------------------------------------(defun DSV_LYRDEF (LYRS&)(dsv_lyrsdef LYRS&))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYRSDEF")
; }
;
; { <DSV_LYRSTAT>============================================================
; Print and return the status of a given list of drawing layers.
|
; {LyrNam Clr Ltp Frz/Thw On/Off Lock/Unlk CvpFrz/CvpThw}
|
; {"Page01_vp" "7" "C" "T" "N" "U" "CT"}
|
; --------------------------------------------------------------------------(defun DSV_LYRSTAT (LYRS& / F$ DAT FLG FRZ UNL OFF LST CLR LTP RET)
(setq F$ (func_in "DSV_LYRSTAT" "LYRS&"))
(if (ds_isstrval? LYRS&)(setq LYRS& (list LYRS&)))
(foreach F_LYR (reverse LYRS&)
;go through given layers
(if (setq DAT (tblsearch "LAYER" F_LYR))
;layer data
(progn
(setq FLG (cdr (assoc 70 DAT)))
(setq FRZ (if (= 1 (logand 1 FLG)) "Frz" "Thw"))
(setq UNL (if (= 4 (logand 4 FLG)) "Lck" "Unl"))
(setq OFF (if (< (cdr (assoc 62 DAT)) 0) "Off" "On"))
(setq CLR (abs (cdr (assoc 62 DAT))))
(setq LTP (cdr (assoc 6 DAT)))
(setq LST (list F_LYR CLR LTP FRZ OFF UNL))
(setq RET (cons LST RET))
)
)
)
(if RET (setq RET (reverse RET)))
(foreach F_LYR RET (princ "\n")(prin1 F_LYR))(princ "\n")
(func_ex F$ RET)
;return list of layer data
)
; --------------------------------------------------------------------------;(defun DSV_LYRSTAT (LYRS&)(dsv_lyrsprop LYRS&))
; --------------------------------------------------------------------------(defun LYST (MK)
(princ "\n")(prin1 MK)
(dsv_lyrstat (list "Page01_vp" "Page02_vp"))
;(ds_wait)

(princ)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYRSTAT")
; }
;
; { <DSV_LYRGETVIS>==========================================================
; Return lists of all layers and their visibility settings
|
; First list is layer names visible globally (both thawed & on)
|
; Second is breakdown assoc list by "T","F","ON","OFF"
|
; --------------------------------------------------------------------------(defun DSV_LYRGETVIS (/ F$ DAT NAM FRZ OFF FRZ& OFF& ON& VIS& RET)
(setq F$ (func_in "DSV_LYRGETVIS" nil))
(setq DAT (tblnext "LAYER" T))
;data of first layer
(while DAT
(setq NAM (cdr (assoc 2 DAT)))
(setq FRZ (= 1 (logand 1 (cdr (assoc 70 DAT)))))
;layer is frozen
(setq OFF (< (cdr (assoc 62 DAT)) 0))
;layer is off
(if FRZ (setq FRZ& (cons NAM FRZ&)))
(if OFF (setq OFF& (cons NAM OFF&)))
(if (and (null FRZ)(null OFF))
(setq VIS& (cons NAM VIS&))
;add name to list
)
(setq DAT (tblnext "LAYER"))
;data of next layer
)
(if VIS& (setq VIS& (reverse VIS&)))
(if FRZ& (setq FRZ& (reverse FRZ&)))
(setq THW& (dsv_lyrnot FRZ&))
(if OFF& (setq OFF& (reverse OFF&)))
(setq ON& (dsv_lyrnot OFF&))
(setq GBL& (list (list "T" THW&)(list "F" FRZ&)(list "ON" ON&)(list "OFF" OFF&
)))
(setq RET (list VIS& GBL&))
(func_ex F$ RET)
;return 2 lists
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYRGETVIS")
; }
;
; { <DSV_LYRSETVIS>==========================================================
; Utilize the LAYER command for a list of layers
|
; LYRS& is an assoc list of keyword and layers
|
; {{"T" {"0" "01" "L01"}}{"F" {"SA01" "LSA01"}}}
|
; if ON or OFF is specified those layers will be thawed if frozen
|
; --------------------------------------------------------------------------(defun DSV_LYRSETVIS (LYRS& / F$ GLB& GTHW& GFRZ& GOFF& CON& OP LY& TEST&
LYS& FZ& TH& OF& ON& TMP& CMD& CLY NLY OK!)
(setq F$ (func_in "DSV_LYRSETVIS" "LYRS&"))
(if (setq GLB& (cadr (dsv_lyrgetvis)))
(progn
(setq GTHW& (cadr (car GLB&)))
(setq GFRZ& (cadr (cadr GLB&)))
(setq GON& (cadr (caddr GLB&)))
(setq GOFF& (cadr (cadddr GLB&)))
(foreach F_L& LYRS&
(setq OP (car F_L&) LY& (cadr F_L&))
(cond
((= OP "F")(setq TEST& GFRZ&))
((= OP "T")(setq TEST& GTHW&))

;all layers by visibility


;all globally thawed layers
;all globally frozen layers
;all globally on layers
;all globally off layers
;each layer group in spec
;operator and layers

((= OP "OFF")(setq TEST& GOFF&))


((= OP "ON")(setq TEST& GON&))
)
(setq LYS& (car (dsv_lyrdef LY&)) LY& nil)
(foreach F_LY LYS&
;check if
(cond
((= OP "F")
(if (not (ds_membstr F_LY TEST&))(setq
)
((= OP "T")
(if (not (ds_membstr F_LY TEST&))(setq
)
((= OP "OFF")
(if (not (ds_membstr F_LY TEST&))(setq
(if (not (ds_membstr F_LY GTHW&))(setq
)
((= OP "ON")
(if (not (ds_membstr F_LY TEST&))(setq
(if (not (ds_membstr F_LY GTHW&))(setq
)
)
)

;filter out undefined


layer is already correct
FZ& (cons F_LY FZ&)))
TH& (cons F_LY TH&)))
OF& (cons F_LY OF&)))
TH& (cons F_LY TH&)))
ON& (cons F_LY ON&)))
TH& (cons F_LY TH&)))

)
(foreach F_LY ON&
(if (and (not (ds_membstr F_LY GTHW&))(not (ds_membstr F_LY TH&)))
(setq TMP& (cons F_LY TMP&))
)
)
(setq CLY (getvar "CLAYER"))
(if FZ& (setq CMD& (cons "F" (cons (ds_strgjoin FZ& ",") CMD&))))
(if TMP& (setq CMD& (cons "F" (cons (ds_strgjoin TMP& ",") CMD&))))
(if OF& (setq CMD& (cons "OFF" (cons (ds_strgjoin OF& ",") CMD&))))
(if ON& (setq CMD& (cons "ON" (cons (ds_strgjoin ON& ",") CMD&))))
(if TMP& (setq CMD& (cons "T" (cons (ds_strgjoin TMP& ",") CMD&))))
(if TH& (setq CMD& (cons "T" (cons (ds_strgjoin TH& ",") CMD&))))
(if (or (ds_membstr CLY FZ&)(ds_membstr CLY TMP&))
(progn
;if current layer is to be frozen
(if TH& (setq NLY (car TH&)))
;use first in thaw list
(if (and GTHW& (null NLY))(setq NLY (car GTHW&))) ;or global list
(setq CMD& (cons "T" (cons NLY (cons "S" (cons NLY CMD&)))))
)
)
(if CMD& (setq CMD& (reverse (cons "" (reverse CMD&)))))
;add ""
(if CMD& (ds_command "_.LAYER" CMD&))
;make changes
(setq OK! T)
(setq GLB& (cadr (dsv_lyrgetvis)))
;all layers by visibility
)
)
(func_ex F$ OK!)
)
; --------------------------------------------------------------------------(defun DSV_LYRSETVIS_TEST1 (/ LYRS1& LYRS2& LYRS3& LYRS4&)
(setq LYRS1& (list "Layer1" "Layer3" "Layer5"))
(setq LYRS2& (list "Layer2" "Layer4" "Layer6"))
(setq LYRS3& (list "Layer7" "Layer9"))
(setq LYRS4& (list "Layer8" "Layer10"))
(dsv_lyrsetvis (list (list "F" LYRS1&)(list "T" LYRS2&)(list "OFF" LYRS3&)(lis
t "ON" LYRS4&)))
)
;(dsv_lyrsetvis_test1)
; ---------------------------------------------------------------------------

(defun DSV_LYRSETVIS_TEST2 (/ LYRS1& LYRS2& LYRS3& LYRS4&)


(setq LYRS1& (list "Layer2" "Layer4" "Layer6"))
(setq LYRS2& (list "Layer1" "Layer3" "Layer5"))
(setq LYRS3& (list "Layer8" "Layer10"))
(setq LYRS4& (list "Layer7" "Layer9"))
(dsv_lyrsetvis (list (list "F" LYRS1&)(list "T" LYRS2&)(list "OFF" LYRS3&)(lis
t "ON" LYRS4&)))
)
;(dsv_lyrsetvis_test2)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYRSETVIS")
; }
; --------------------------------------------------------------------------; (setq <activeDwg> (dsv_<DwgActv>))
; (setq <activeLyr> (vlax-get-property <activeDwg> 'ActiveLayer));
; (setq <activeLyrNam> (vlax-get-property <activeLyr> 'Name))
; (vlax-put-property <activeLyr> 'Name NAM)
; (setq <specLyr> (vlax-put-property <activeDwg> 'ActiveLayer))
; (setq <layers> (vlax-get-property <activeDwg> 'Layers))
; (setq <specLyr> (vlax-invoke-method <layers> 'Item NAM))
; (setq <layer> (vlax-get-property <layers> 'Layer))
;
; { <DSV_LYRVLAOBJ>==========================================================
; Return the vla layer object for the specified layer.
|
; --------------------------------------------------------------------------(defun DSV_LYRVLAOBJ (NAM / <activeDwg> <layers> <specLyr>)
(if (tblsearch "LAYER" NAM) ;(setq NAM "0")(setq NAM "Layer1")
(progn
(setq <activeDwg> (dsv_<DwgActv>))
(setq <layers> (vlax-get-property <activeDwg> 'Layers))
(setq <specLyr> (vlax-invoke-method <layers> 'Item NAM))
)
)
)
;(dsv_lyrvlaobj "0") (dsv_lyrvlaobj "E01a_OUT")
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYRVLAOBJ")
; }
;
; { <DSV_LYRTHWDFLT>=========================================================
; Return whether a given drawing layer is thawed in new viewports.
|
; --------------------------------------------------------------------------(defun DSV_LYRTHWDFLT (NAM / <specLyr> <FRZ> RET)
(if (setq <specLyr> (dsv_lyrvlaobj NAM)) ;(setq NAM "0")(setq NAM "Layer1")
(progn
(setq <FRZ> (vlax-get-property <specLyr> 'ViewportDefault))
(setq RET (if (equal <FRZ> ':vlax-false) T nil))
)
)
)
;(dsv_lyrthwdflt "Layer1")
; --------------------------------------------------------------------------(defun DSV_LYRTHWCHRT (/ ALLLYRS& RET)
(foreach F_LYR (setq ALLLYRS& (dsv_lyrsdwg))
(setq RET (cons (list F_LYR (dsv_lyrthwdflt F_LYR)) RET))
)
RET
)
; --------------------------------------------------------------------------(defun C:LYRTHWCHT ()
(if (setq LYRS& (dsv_lyrthwchrt))
(foreach F_LYR LYRS&
(princ "\n")(princ (car F_LYR))

(princ (if (cadr F_LYR) "{Thaw}" "{Freeze}"))


)
)
)
;(c:lyrthwcht)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYRVLAOBJ")
; }
;
; { <DSV_LYRADD>=============================================================
; Add a new layer object to the current drawing.
|
; --------------------------------------------------------------------------(defun DSV_LYRADD (NAM / <acadObject> <acadDocument> <layers> <newLyr>)
(setq <activeDwg> (dsv_<DwgActv>))
(setq <layers> (vlax-get-property <activeDwg> 'Layers))
(setq <newLyr> (vlax-invoke-method <layers> 'Add NAM))
)
;(setq NAM "Layer03")
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYRADD")
; }
;
; { <DSV_VPRT-OBJ-LIST>======================================================
; Return the vla viewport collection object.
|
; --------------------------------------------------------------------------(defun DSV_VPRT-OBJ-LIST (/ <acadObject> <actvViewport> <VprtXdata>
<allViewports> <allViews> <ViewportsQty> N <View> <Vprt> <VP&>)
(setq <activeDwg> (dsv_<DwgActv>))
(setq <actvViewport> (vlax-get-property <activeDwg> 'ActivePViewport))
(setq <VprtXdata> (vlax-invoke-method <actvViewport> 'GetXData "ACAD" TYPES VA
LUES))
(setq <allViewports> (vlax-get-property <activeDwg> 'Viewports))
(setq <allViews> (vlax-get-property <activeDwg> 'Views))
(setq <ViewportsQty> (vlax-get-property <allViewports> 'Count))
(setq N 0)
(setq <View> (vlax-invoke-method <allViews> 'Item (vlax-make-variant N 2)))
(setq <Vprt> (vlax-invoke-method <allViewports> 'Item (vlax-make-variant N 2))
)
(while <Vprt>
(setq N (1+ N) <VP&> (cons <Vprt> <VP&>))
(setq <Vprt> (vlax-invoke-method <viewports> (vlax-make-variant N 2)))
)
) ;(vlax-ename->vla-object entname)
(setq <VP&> (dsv_vprt-obj-list))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VPRTVLAOBJ")
; }
;
; { <DSV_LYRMAK>=============================================================
; Make a given layer and set its color and linetype. Return the layer name.|
; --------------------------------------------------------------------------(defun DSV_LYRMAK (PRP& / LYR <newLyr> RET)
(if (ds_isstrval? PRP&)(setq PRP& (ds_strgdiv PRP& ",")))
(setq LYR (car PRP&))
(if (not (tblsearch "LAYER" LYR))
;does not exist yet
(setq <newLyr> (dsv_lyradd LYR))
;(ds_command "_.-LAYER" (list "N" LYR ""))
)
(if (tblsearch "LAYER" LYR)
(progn
(dsv_lyrprpset PRP&)

(setq RET LYR)


)
)
RET

;return Name if layer exists


)
;(setq PRP& "Layer03,7,Continuous") ;(dsv_lyrmak "01,7,Continuous")
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYRMAK")
; }
;
; { <DSV_LYRMAK-FZ>==========================================================
; Make a given layer and set its color and linetype. Freeze the layer.
|
; --------------------------------------------------------------------------(defun DSV_LYRMAK-FZ (PRP& / LYR <newLyr> VP& RET)
(if (ds_isstrval? PRP&)(setq PRP& (ds_strgdiv PRP& ",")))
(setq LYR (car PRP&))
(if (not (tblsearch "LAYER" LYR))
;does not exist yet
(setq <newLyr> (dsv_lyradd LYR))
;(ds_command "_.-LAYER" (list "N" LYR ""))
)
(if (tblsearch "LAYER" LYR)
(progn
(vlax-put-property <newLyr> 'Freeze ':vlax-true)
(vlax-put-property <newLyr> 'ViewportDefault ':vlax-true)
(if (setq VP& (dsv_vpmslist (getvar "CTAB")))
(foreach F_VP VP&
;(setq F_VP (car VP&))
(dsv_vpset (car F_VP))
(dsv_pspset)
(ds_ssv "CMDECHO" 0)
(ds_command "_.VPLAYER" (list "F" LYR "A" "T" LYR "" ""))
(ds_rsv "CMDECHO")
)
)
(dsv_lyrprpset PRP&)
(setq RET LYR)
)
)
RET
;return Name if layer exists
)
;(setq PRP& "Layer03,7,Continuous") ;(dsv_lyrmak "01,7,Continuous")
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYRMAK-FZ")
; }
;
; { <DSV_LYRMAK-PS>==========================================================
; Make a given layer to be visible only in paperspace and set its color and |
; linetype. Return the layer name.
|
; --------------------------------------------------------------------------(defun DSV_LYRMAK-PS (PRP& / LYR <newLyr> VP& RET)
(if (ds_isstrval? PRP&)(setq PRP& (ds_strgdiv PRP& ",")))
(setq LYR (car PRP&))
(if (not (tblsearch "LAYER" LYR))
;does not exist yet
(setq <newLyr> (dsv_lyradd LYR))
(setq <newLyr> (dsv_lyrvlaobj LYR))
)
(if (tblsearch "LAYER" LYR)
(progn
(vlax-put-property <newLyr> 'ViewportDefault ':vlax-true)
(if (setq VP& (dsv_vpmslist (getvar "CTAB")))
(foreach F_VP VP&
;(setq F_VP (car VP&))

(dsv_vpset (car F_VP))


;(setq <vpobj> (vlax-ename->vla-object (car F_VP)))
(dsv_pspset)
(ds_ssv "CMDECHO" 0)
(ds_command "_.VPLAYER" (list "F" LYR "A" "T" LYR "" ""))
(ds_rsv "CMDECHO")
)
)
(dsv_lyrprpset PRP&)
(setq RET LYR)
)
)
RET

;return Name if layer exists


)
;(dsv_lyrmak-ps "Page01,7,Continuous")
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYRMAK-PS")
; }
;
; { <DSV_LYRMAK-CV>==========================================================
; Make a given layer to be visible only in the current viewport and set its |
; color and linetype. Return the layer name.
|
; THW$ can be "A" (all vports), "C" (current vport only), or "N" (no vports)|
; --------------------------------------------------------------------------(defun DSV_LYRMAK-CV (PRP& / CMD& LYR <newLyr> RET)
(if (ds_isstrval? PRP&)(setq PRP& (ds_strgdiv PRP& ",")))
(setq CMD& (list "") LYR (car PRP&))
;Freeze in all but the current viewport
(if (not (tblsearch "LAYER" LYR))
;does not exist yet
(setq <newLyr> (dsv_lyradd LYR))
(setq <newLyr> (dsv_lyrvlaobj LYR))
)
(if (tblsearch "LAYER" LYR)
(progn
(vlax-put-property <newLyr> 'ViewportDefault ':vlax-true)
(if (setq VP& (dsv_vpmslist (getvar "CTAB")))
(progn
(dsv_vpset (car F_VP))
(dsv_pspset)
(ds_ssv "CMDECHO" 0)
(ds_command "_.VPLAYER" (list "F" LYR "A" "T" LYR "" ""))
(ds_rsv "CMDECHO")
(dsv_mspset)
(ds_ssv "CMDECHO" 0)
(ds_command "_.VPLAYER" (list "T" LYR "" ""))
(ds_rsv "CMDECHO")
)
)
(dsv_lyrprpset PRP&)
(setq RET LYR)
)
)
RET
;return Name if layer exists
)
;(dsv_lyrmak-cv "L01,7,Continuous")
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYRMAK")
; }
;
; { <DSV_LYRPRPSET>==========================================================
; Set a given layer's color and linetype. Return the layer name.
|

; --------------------------------------------------------------------------(defun DSV_LYRPRPSET (PRP& / LYR CLR LTP RET)


(if (ds_isstrval? PRP&)(setq PRP& (ds_strgdiv PRP& ",")))
(setq LYR (car PRP&))
(setq CLR (if (cadr PRP&)(cadr PRP&) "7"))
(setq LTP (if (caddr PRP&)(caddr PRP&) "CONTINUOUS"))
(if (tblsearch "LAYER" LYR)
(progn
(dsv_lyrclrset LYR CLR)
(dsv_lyrltpset LYR LTP)
(setq RET LYR)
)
)
RET
;return Name if layer exists
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYRPRPSET")
; }
;
; { <DSV_LYRVFY>=============================================================
; Check that a layer is defined. If not, create it to be thawed in only
|
; the current viewport. If the layer is to be created and properties are |
; also present (color and linetype) set them. If defined return layer name.|
; --------------------------------------------------------------------------(defun DSV_LYRVFY (PRP& / LYR RET)
(if (ds_isstrval? PRP&)(setq PRP& (ds_strgdiv PRP& ",") LYR (car PRP&)))
(if (and LYR (/= LYR ""))
(if (not (tblsearch "LAYER" LYR))
(ds_command "_.LAYER" (list "N" LYR ""))
)
)
(if (tblsearch "LAYER" LYR)(setq RET LYR))
RET
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYRVFY")
; }
;
; { <DSV_LYRCHK>=============================================================
; See if the specified layer is defined.
|
; --------------------------------------------------------------------------(defun DSV_LYRCHK (LY)
(and LY (tblsearch "LAYER" LY))
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYRCHK")
; }
;
; { <DSV_CLYRCHK>=============================================================
; See if the current layer matches the specified one.
|
; --------------------------------------------------------------------------(defun DSV_CLYRCHK (LY)
(and LY (= (strcase LY)(strcase (getvar "CLAYER"))))
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_CLYRCHK")
; }
;

; { <DSV_CLYRSET>============================================================
; Set a layer name. Make sure it is Thawed, On, and Unlocked. If L! save |
; the current layer to return to later.
|
; Global vars: {DSV_CLYRPRV_NAM}
|
; --------------------------------------------------------------------------(defun DSV_CLYRSET (LY L! / CL DT D L&)
(if (and (ds_isstrval? LY)
(setq LY (dsv_lyrvfy LY))
)
(progn
(if (/= (strcase LY)(strcase (setq CL (getvar "CLAYER"))))
(progn
(setq DT (tblsearch "LAYER" LY))
(setq D (cdr (assoc 70 DT)))
(if (= 1 (logand 1 D))(setq L& (cons "T" L&) L& (cons LY L&)))
(if (< (cdr (assoc 62 DT)) 0)(setq L& (cons "ON" L&) L& (cons LY L&)))
(if (= 4 (logand 4 D))(setq L& (cons "U" L&) L& (cons LY L&)))
(setq L& (cons "S" L&) L& (cons LY L&) L& (cons "" L&))
(dsv_ssv "CMDECHO" 0)
(ds_command "_.LAYER" (reverse L&))
(dsv_rsv "CMDECHO")
;(if (setq CE (dsv_vpcur))(dsv_vlyaddthw CE (list LY)))
(if L!
(if (null DSV_CLYRPRV_NAM&)
(setq DSV_CLYRPRV_NAM& (list CL))
(setq DSV_CLYRPRV_NAM& (cons CL DSV_CLYRPRV_NAM&))
)
)
)
)
)
)
(= (strcase LY)(strcase (getvar "CLAYER")))
;if now current, return T
)
; --------------------------------------------------------------------------(defun DSV_LYRNXT (LY)(dsv_clyrset LY T))
(defun DS_CLYRNXT (LY)(dsv_clyrset LY T))
; --------------------------------------------------------------------------(defun DSV_LYRSET (LY)(dsv_clyrset LY nil))
(defun DS_LYRSET (LY)(dsv_clyrset LY nil))
(defun DS_SETLAY (LY)(dsv_clyrset LY nil))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_CLYRSET")
; }
;
; { <DSV_CLYRPRV>============================================================
; Reset to the saved layer name.
|
; Global vars: {DSV_CLYRPRV_NAM}
|
; --------------------------------------------------------------------------(defun DSV_CLYRPRV (/ LY)
(if (and DSV_CLYRPRV_NAM&
(setq LY (car DSV_CLYRPRV_NAM&))
)
(progn
(if (/= (strcase LY)(strcase (getvar "CLAYER")))
(progn
(dsv_ssv "CMDECHO" 0)
(ds_command "_.LAYER" (list "S" LY ""))
(dsv_rsv "CMDECHO")

)
)
(setq DSV_CLYRPRV_NAM& (cdr DSV_CLYRPRV_NAM&))
)
)
(princ)
)
; --------------------------------------------------------------------------(defun DS_CLYRPRV ()(dsv_clyrprv))
(defun DSV_LYRPRV ()(dsv_clyrprv))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_CLYRPRV")
; }
;
; { <DSV_LYRFRZ>=============================================================
; Freeze a layer name globally.
|
; --------------------------------------------------------------------------(defun DSV_LYRFRZ (LY / CL DT D L&)
(if (and LY (/= LY ""))
(if (dsv_lyrvfy LY)
(progn
(if (= LY (getvar "CLAYER"))(dsv_lyrset "0"))
(setq DT (tblsearch "LAYER" LY))
(setq D (cdr (assoc 70 DT)))
(if (/= 1 (logand 1 D))(setq L& (cons "F" L&) L& (cons LY L&)))
(setq L& (cons "" L&))
(ds_command "_.LAYER" (reverse L&))
)
)
)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYRFRZ")
; }
;
; { <DSV_LYRFRZVP>===========================================================
; Freeze a layer name in all viewports.
|
; --------------------------------------------------------------------------(defun DSV_LYRFRZVP (LY / CL DT D L&)
(if (and LY (/= LY ""))
(if (dsv_lyrvfy LY)
(ds_command "_.VPLAYER" (list "F" "A" ""))
)
)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYRFRZVP")
; }
;
; { <DSV_LYRTHW>=============================================================
; Thaw a layer name globally.
|
; --------------------------------------------------------------------------(defun DSV_LYRTHW (LY / CL DT D L&)
(if (and LY (/= LY ""))
(if (dsv_lyrvfy LY)
(progn
(setq DT (tblsearch "LAYER" LY))

(setq D (cdr (assoc 70 DT)))


(if (= 1 (logand 1 D))(setq L& (cons "T" L&) L& (cons LY L&)))
(setq L& (cons "" L&))
(ds_command "_.LAYER" (reverse L&))
)
)
)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYRTHW")
; }
;
; { <DSV_LYRTHWVP>===========================================================
; Thaw a layer name in all viewports.
|
; --------------------------------------------------------------------------(defun DSV_LYRTHWVP (LY / CL DT D L&)
(if (and LY (/= LY ""))
(if (dsv_lyrvfy LY)
(ds_command "_.VPLAYER" (list "T" "A" ""))
)
)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYRTHWVP")
; }
;
; { <DSV_CLRNUM>=============================================================
; Returns a color number no matter what is supplied
|
; Usage:
|
; Input:V=Color Value to verify
|
;
D=Default to use if V is invalid
|
; Local vars:
|
; Return:0-256
|
; --------------------------------------------------------------------------(defun DSV_CLRNUM (V / VI C)
(if (and (= (type V) 'STR)(/= V ""))(setq C (ascii (strcase V)))) ;1st char
(setq VI (ds_vfyint V))
(cond ((or (null V)(= V "")) 7)
((or (= V 0)(and C (= (strcase V) "BYBLOCK"))) 0)
((or (= V 256)(and C (= (strcase V) "BYLAYER"))) 256)
((and VI (> VI 0)(< VI 257)) VI)
((= C 82) 1)
((= C 89) 2)
((= C 71) 3)
((= C 67) 4)
((= C 66) 5)
((= C 77) 6)
((= C 87) 7)
(T 7)
;use backup default of white
)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_CLRNUM")
; }
;
; { <DSV_CLRNAM>=============================================================
; Returns a color name no matter what is supplied
|
; Usage:
|
; Input:V=Color Value to verify
|

;
D=Default to use if V is invalid
|
; Local vars:
|
; Return:0-256
|
; --------------------------------------------------------------------------(defun DSV_CLRNAM (V / VI C)
(if (and (= (type V) 'STR)(/= V ""))(setq C (ascii (strcase V)))) ;1st char
(setq VI (ds_vfyint V))
(cond ((or (null V)(= V "")) "BYLAYER")
((or (= VI 0)(and C (= (strcase V) "BYBLOCK"))) "BYBLOCK")
((or (= VI 256)(and C (= (strcase V) "BYLAYER"))) "BYLAYER")
((and VI (> VI 0)(< VI 256))(itoa VI))
((= C 82) "1")
((= C 89) "2")
((= C 71) "3")
((= C 67) "4")
((= C 66) "5")
((= C 77) "6")
((= C 87) "7")
(T "BYLAYER")
)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_CLRNAM")
; }
;
; { <DSV_CLRCHK>=============================================================
; See if the current entity color matches the specified one.
|
; --------------------------------------------------------------------------(defun DSV_CLRCHK (CL)
(and CL (= (strcase (dsv_clrnam CL))(strcase (getvar "CECOLOR"))))
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_CLRCHK")
; }
;
; { <DSV_CLRSET>=============================================================
; Set a color name saving the current color to return to later.
|
; Global vars: {DSV_CLRPRVNAM}
|
; --------------------------------------------------------------------------(defun DSV_CLRSETCUR (CL L! / CC)
(if (and CL (/= CL ""))
(progn
(if (/= (dsv_clrnum CL)(dsv_clrnum (setq CC (getvar "CECOLOR"))))
(progn
(setq CL (dsv_clrnum CL))
(cond
((= CL 0)(setvar "CECOLOR" "BYBL
OCK"))
((= CL 256)(setvar "CECOLOR" "BY
LAYER"))
(T (setvar "CECOLOR" CL))
)
)
)
(if L!
(if (null DSV_CLRPRV_NAM&)
(setq DSV_CLRPRV_NAM& (list CC))
(setq DSV_CLRPRV_NAM& (cons CC DSV_CLRPRV_NAM&))
)
)

)
)
(= (dsv_clrnum CL)(dsv_clrnum (getvar "CECOLOR")));if now current, return T
)
; --------------------------------------------------------------------------(defun DSV_CLRNXT (LY)(dsv_clrsetcur LY T))
; --------------------------------------------------------------------------(defun DSV_CLRSET (LY)(dsv_clrsetcur LY nil))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_CLRSET")
; }
;
; { <DSV_CLRPRV>=============================================================
; Reset to the most recently saved color name.
|
; Global vars: {DSV_CLRPRV_NAM&}
|
; --------------------------------------------------------------------------(defun DSV_CLRPRV ()
(if (and DSV_CLRPRV_NAM& (setq CL (car DSV_CLRPRV_NAM&)))
(progn
(if (/= (dsv_clrnum CL)(dsv_clrnum (getvar "CECOLOR")))
(setvar "CECOLOR" CL)
)
(setq DSV_CLRPRV_NAM& (cdr DSV_CLRPRV_NAM&))
)
)
(princ)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_CLRPRV")
; }
;
; { <DSV_LYRCLRGET>==========================================================
; Get the color setting of the given layer.
|
; --------------------------------------------------------------------------(defun DSV_LYRCLRGET (LYR / DAT)
(if (and (= (type LYR) 'STR)(setq DAT (tblsearch "LAYER" LYR))) ;layer data
(cdr (assoc '62 DAT))
;return color number
)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYRCLRGET")
; }
;
; { <DSV_LYRCLRSET>==========================================================
; Change the color setting of the given layer.
|
; --------------------------------------------------------------------------(defun DSV_LYRCLRSET (LYR CLR / ECL)
(if (and (= (type CLR) 'STR)
(setq ECL (dsv_lyrclrget LYR))
;layer valid?
(setq CLR (dsv_clrnam CLR))
;color valid?
(/= ECL CLR)
;color different?
)
(ds_command "_.LAYER" (list "C" CLR (strcase LYR) ""))
;make change
)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYRCLRSET")
; }

;
; { <DSV_LTPMAKE>============================================================
; Attempts to load the specified linetype. Returns the linetype name if
|
; successful.
|
; --------------------------------------------------------------------------(defun DSV_LTPMAKE (LTP)
;vlax: ThisDrawing.Linetypes.Load linetypeName, "acad.lin"
;vlax: DwgObj.LinetypeScale = 0.5
;
DwgObj.Update
(if (setq LTP (ds_chkname LTP))
(if (tblsearch "LTYPE" LTP)
;already loaded
LTP
;return linetype name
(progn
(ds_command "_.LINETYPE" (list "L" LTP "ACAD.LIN" ""))
(if (tblsearch "LTYPE" LTP) LTP) ;return name if successfully loaded
)
)
)
)
; --------------------------------------------------------------------------(defun C:LTPMAK (/ NAM)
(if (setq NAM (getstring "\nEnter linetype name: "))
(prin1 (dsv_ltpmake NAM))
)
(princ)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LTPMAKE")
; }
;
; { <DSV_LTPCHK>=============================================================
; See if the current ltype matches the specified.
|
; --------------------------------------------------------------------------(defun DSV_LTPCHK (LT)
(and LT (= (strcase LT)(strcase (getvar "CELTYPE"))))
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LTPCHK")
; }
;
; { <DSV_LTPSET>=============================================================
; Set a ltype name and if L! saving the current ltype to return to later. |
; Global vars: {DSV_LTPPRV_NAM&}
|
; --------------------------------------------------------------------------(defun DSV_LTPSETCUR (LT L! / CL)
;vlax: ThisDrawing.ActiveLinetype = ThisDrawing.Linetypes.Item("CONTINUOUS")
(if (and LT (/= LT "")(not (dsv_ltpchk LT))(setq LT (dsv_ltpmake LT)))
(progn
(if (/= (strcase LT)(strcase (setq CL (getvar "CELTYPE"))))
(setvar "CELTYPE" LT)
)
(if L!
(if (null DSV_LTPPRV_NAM&)
(setq DSV_LTPPRV_NAM& (list CL))
(setq DSV_LTPPRV_NAM& (cons CL DSV_LTPPRV_NAM&))
)
)
)
)
(= (strcase LT)(strcase (getvar "CELTYPE")))
;if now current, return T

)
; --------------------------------------------------------------------------(defun DSV_LTPNXT (LY)(dsv_ltpsetcur LY T))
; --------------------------------------------------------------------------(defun DSV_LTPSET (LY)(dsv_ltpsetcur LY nil))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LTPSETCUR")
; }
;
; { <DSV_LTPPRV>=============================================================
; Reset to the saved ltype name.
|
; Global vars: {DSV_LTPPRV_NAM&}
|
; --------------------------------------------------------------------------(defun DSV_LTPPRV (/ LT)
(if (and DSV_LTPPRV_NAM& (setq LT (car DSV_LTPPRV_NAM&)))
(progn
(if (/= (strcase LT)(strcase (getvar "CELTYPE")))
(setvar "CELTYPE" LT)
)
(setq DSV_LTPPRV_NAM& (cdr DSV_LTPPRV_NAM&))
)
)
(princ)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LTPPRV")
; }
;
; { <DSV_LYRLTPGET>==========================================================
; Get the linetype setting of the given layer.
|
; --------------------------------------------------------------------------(defun DSV_LYRLTPGET (LYR / DAT)
(if (and (= (type LYR) 'STR)(setq DAT (tblsearch "LAYER" LYR))) ;layer data
(cdr (assoc '6 DAT))
;return linetype name
)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYRLTPGET")
; }
;
; { <DSV_LYRLTPSET>==========================================================
; Change the linetype setting of the given layer.
|
; --------------------------------------------------------------------------(defun DSV_LYRLTPSET (LYR LTP / ELT)
(if (and (= (type LTP) 'STR)
(setq ELT (dsv_lyrltpget LYR))
;layer valid?
(setq LTP (dsv_ltpmake LTP))
;linetype defined?
(/= ELT LTP)
;linetype different?
)
(ds_command "_.LAYER" (list "LT" LTP (strcase LYR) ""))
;make change
)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYRLTPSET")
; }
;
; { <DSV_PROPSET>============================================================
; Set layer, linetype, and color names saving the current ones to return to |
; later.
|
; ---------------------------------------------------------------------------

(defun DSV_PROPSET (PRP&)


(dsv_clyrset (car PRP&) T)
(dsv_ltpnxt (cadr PRP&))
(dsv_clrnxt (caddr PRP&))
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_PROPSET")
; }
;
; { <DSV_PROPPRV>============================================================
; Reset to the saved layer, linetype, and color names.
|
; --------------------------------------------------------------------------(defun DSV_PROPPRV ()
(ds_layprv)
(ds_ltpprv)
(ds_clrprv)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_PROPPRV")
; }
;
; { <DSV_OSNAPSET>===========================================================
; Set the osnap mode saving the current setting to return to later.
|
; Global vars: {DSV_LTPPRVNAM}
|
; --------------------------------------------------------------------------(defun DSV_OSNAPSET (N / OS)
(setq OS (getvar "OSMODE"))
(if (null DSV_OSNAPSET_OS)(setq DSV_OSNAPSET_OS (getvar "OSMODE")))
(setvar "OSMODE" N)
(princ)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_OSNAPSET")
; }
;
; { <DSV_OSNAPPRV>===========================================================
; Reset to the saved osnap mode.
|
; Global vars: {DSV_LTPPRVNAM}
|
; --------------------------------------------------------------------------(defun DSV_OSNAPPRV ()
(if DSV_OSNAPSET_OS (setvar "OSMODE" DSV_OSNAPSET_OS))
(setq DSV_OSNAPSET_OS nil)
;no pending ltype
(princ)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_OSNAPPRV")
; }
;
; { <DSV_<VLASTYLESCOLLECT>>=================================================
; Return the vla object for the text styles collection.
|
; --------------------------------------------------------------------------(defun DSV_<VLASTYLESCOLLECT> (/ <activeDwg>)
(if (ds_verac 15)
(progn
(vl-load-com)
(if (setq <activeDwg> (dsv_<DwgActv>))
(vlax-get-property <activeDwg> 'TextStyles)
)
)
)

)
;(setq <stylesTable> (dsv_<vlastylescollect>))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_<VLASTYLESCOLLECT>")(loadrpt)
; }
;
; { <DSV_STYLENAMES>=========================================================
; Return the names and enames of all defined text styles.
|
; --------------------------------------------------------------------------(defun DSV_STYLENAMES (/ <stylesTable> I <Obj> NM E RET)
(if (ds_verac 15)
(progn
(vl-load-com)
(setq <stylesTable> (dsv_<vlastylescollect>))
(setq I (vlax-get-property <stylesTable> 'Count))
(while (> I 0)
(setq <Obj> (vla-item <stylesTable> (setq I (1- I))))
(setq NM (vlax-get-property <Obj> 'Name))
(setq E (vlax-vla-object->ename <Obj>))
(setq RET (cons (list NM E) RET))
)
)
)
RET
)
;(setq StyleNames (dsv_stylenames))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_STYLENAMES")(loadrpt)
; }
;
; { <DSV_<VLADIMSTYLESCOLLECT>>==============================================
; Return the vla object for the dimension styles collection.
|
; --------------------------------------------------------------------------(defun DSV_<VLADIMSTYLESCOLLECT> (/ <activeDwg>)
(if (ds_verac 15)
(progn
(vl-load-com)
(if (setq <activeDwg> (dsv_<DwgActv>))
(vlax-get-property <activeDwg> 'DimStyles)
)
)
)
)
;(setq <DimStylesTable> (dsv_<vladimstylescollect>))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_<VLASTYLESCOLLECT>")(loadrpt)
; }
;
; { <DSV_DIMSTYLENAMES>======================================================
; Return the names and enames of all defined dimension styles.
|
; --------------------------------------------------------------------------(defun DSV_DIMSTYLENAMES (/ <dimstylesTable> I <Obj> NM E RET)
(if (ds_verac 15)
(progn
(vl-load-com)
(setq <dimstylesTable> (dsv_<vladimstylescollect>))
(setq I (vlax-get-property <dimstylesTable> 'Count))
(while (> I 0)
(setq <Obj> (vla-item <dimstylesTable> (setq I (1- I))))
(setq NM (vlax-get-property <Obj> 'Name))
(setq E (vlax-vla-object->ename <Obj>))
(setq RET (cons (list NM E) RET))
)

)
)
RET
)
;(setq DimStyleNames (dsv_dimstylenames))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_DIMSTYLENAMES")(loadrpt)
; }
;
; { <DSV_FONTFIND>===========================================================
; Searches for a font file by using extensions SHX, TTF, PS, GSF, PFB
|
; FNT=Font name, P=Special search directory
|
; --------------------------------------------------------------------------(defun DSV_FONTFIND (FNT P / F& D N F)
(setq F& (ds_pfx FNT) D (car F&) N (cadr F&))
(cond
((setq F (findfile (strcat D N ".SHX"))))
((and P (setq F (findfile (strcat P N ".SHX")))))
((setq F (findfile (strcat N ".SHX"))))
((setq F (findfile (strcat D N ".TTF"))))
((and P (setq F (findfile (strcat P N ".TTF")))))
((setq F (findfile (strcat N ".TTF"))))
((setq F (findfile (strcat D N ".PS"))))
((and P (setq F (findfile (strcat P N ".PS")))))
((setq F (findfile (strcat N ".PS"))))
((setq F (findfile (strcat D N ".GSF"))))
((and P (setq F (findfile (strcat P N ".GSF")))))
((setq F (findfile (strcat N ".GSF"))))
((setq F (findfile (strcat D N ".PFB"))))
((and P (setq F (findfile (strcat P N ".PFB")))))
((setq F (findfile (strcat N ".PFB"))))
((= (caddr F&) "TTF")(setq F FNT))
;let windows find it
) F
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_FONTFIND")
; }
;
; { <DSV_STYMAKE>============================================================
; Creates a new text style or redefines an existing one to specified values |
; STY=Style name (default "STANDARD")
|
; PRP&=(("FONT" "ROMANS")("HGT" 0.0)("WID" 1.0)("OBL" 0.0)
|
;
("BACK" nil)("UPSD" nil)("VERT" nil))
|
; Global vars: {DS_PRGPTH}
|
; --------------------------------------------------------------------------(defun DSV_STYMAKE (STY PRP& / N LN B C L TD F I FNT H W O U V FILE)
(if (ds_isstrval? STY)
(progn
(setq N 1)
(if (> (setq LN (strlen STY)) 31)
;check style name characters
(setq B T)
;too long
(repeat LN
(setq C (substr STY N 1))
(setq L (dsk_patchr C))
(if (not (member L (list "U" "L" "N")))(setq B T))
;invalid char
(setq N (1+ N))
)
)
(if B (setq STY "STANDARD"))
(if (setq TD (tblsearch "STYLE" STY))
;already defined

(setq F (cdr (assoc 3 TD)))


;current font
)
(if (setq I (assoc "FONT" PRP&))(setq FNT (ds_frcstr (cadr I))))
(setq H (if (setq I (assoc "HGT" PRP&))(ds_vfyreal (cadr I)) "0.0"))
(setq W (if (setq I (assoc "WID" PRP&))(ds_vfyreal (cadr I)) "1.0"))
(setq O (if (setq I (assoc "OBL" PRP&))(ds_vfyreal (cadr I)) "0.0"))
(setq B (if (setq I (cadr (assoc "BACK" PRP&))) "Y" "N"))
(setq U (if (setq I (cadr (assoc "UPSD" PRP&))) "Y" "N"))
(setq V (if (setq I (cadr (assoc "VERT" PRP&))) "Y" "N"))
(if FNT
;is given font valid
(progn
(setq N 1 I nil)
(if (> (setq LN (strlen FNT)) 31)
;check font name characters
(setq I T)
;too long
(repeat LN
(setq C (substr FNT N 1))
(setq L (dsk_patchr C))
(if (not (member L (list "U" "L" "N")))(setq I T));invalid char
(setq N (1+ N))
)
)
)
)
(if (or (null FNT) I)(setq FNT (if F F "ROMANS")))
(if (dsv_fontfind FNT nil)
(setq FILE FNT)
(setq FILE (dsv_fontfind FNT (ds_prgpth)))
)
(if FILE
(progn
;(dsv_ssv "CMDECHO" 1)
;command group ----(ds_cmdstop "*")
;cancel all open commands
(command "_.STYLE" STY FNT H W O B U)
;set style
(if (= (getvar "CMDNAMES") "STYLE")(command V))
;vertical prompt
(if (= (getvar "CMDNAMES") "STYLE")(command))
;(dsv_rsv "CMDECHO")
)
(progn (princ "\nFont file not found for ")(prin1 FNT))
)
(tblsearch "STYLE" STY)
)
)
)
; --------------------------------------------------------------------------(defun DSV_STYFONT (STY FONT / PRP&)
;set style to use specified font
(setq PRP&
(list (list "FONT" FONT)(list "HGT" 0.0)(list "WID" 1.0)(list "OBL" 0.0)
(list "BACK" nil)(list "UPSD" nil)(list "VERT" nil)
)
)
(dsv_stymake STY PRP&)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_STYMAKE")
; }
;
; { <DSV_STYPROPS>===========================================================
; Return an assoc list of style properties from a comma delim text string. |
; ---------------------------------------------------------------------------

(defun DSV_STYPROPS (TX / L NM FN HT WD OB BK UD VT PRP&)


(setq L (ds_strgdiv TX ","))
(setq NM (car L) L (cdr L))
(setq FN (car L) L (cdr L))
(setq HT (car L) L (cdr L))
(setq WD (car L) L (cdr L))
(setq OB (car L) L (cdr L))
(setq BK (car L) L (cdr L))
(setq UD (car L) L (cdr L))
(setq VT (car L) L (cdr L))
(if (null NM)(setq NM "STANDARD"))
(if (null FN)(setq FN "ROMANS.SHX"))
(if (null HT)(setq HT "0.0"))
(if (null WD)(setq WD "1.0"))
(if (null OB)(setq OB "0.0"))
(setq PRP&
(list (list "FONT" FN)(list "HGT" HT)(list "WID" WD)(list "OBL" OB)
(list "BACK" BK)(list "UPSD" UD)(list "VERT" VT)
)
)
(dsv_stymake NM PRP&)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_STYPROPS")
; }
;
; { <DSV_STYUSED>============================================================
; Return all style names other than STANDARD referenced by text entities
|
; --------------------------------------------------------------------------(defun DSV_STYUSED (/ R S N S& SS R&)
(setq R T)
(while (setq S (tblnext "STYLE" R))
(setq R nil)
(if (/= (setq N (cdr (assoc 2 S))) "STANDARD")
(setq S& (cons N S&) N nil)
)
)
(foreach S S&
(setq SS (ssget "X" (list '(0 . "TEXT")(cons 7 S)))) ;text using style S
(if (and SS (= (type SS) 'PICKSET)(> (sslength SS) 0))
;if any found
(setq R& (cons S R&))
;add style name to return list
)
) R&
;return list of style names referenced by text
)
; --------------------------------------------------------------------------(defun C:STYUSED ()(prin1 (styused))(prin1))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_STYUSED")
; }
;
; { <DSV_STYSTD>=============================================================
; Make sure that the standard style is the only one referenced by text
|
; --------------------------------------------------------------------------(defun DSV_STYSTD (/ SS N E ED)
(foreach S (dsv_styused)
;each style name with text in drawing
(setq N 0)
(setq SS (ssget "X" (list '(0 . "TEXT")(cons 7 S))))
;get the text
(if (and SS (= (type SS) 'PICKSET)(> (sslength SS) 0))

(repeat (sslength SS)


;every entity found
(setq E (ssname SS N) N (1+ N) ED (entget E))
(dsk_entmod (subst (cons 7 "STANDARD")(assoc 7 ED) ED)) ;modify edata
)
)
)
)
; --------------------------------------------------------------------------(defun C:STYSTD ()(dsv_stystd)(prin1))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_STYSTD")
; }
; { <DSV_STYSET>=============================================================
; Set a specified text style saving the current style to return to later. |
; Global vars: {DSV_STYPRVNAM}
|
; --------------------------------------------------------------------------(defun DSV_STYSET (STY / CS TD)
(if (and STY (/= STY ""))
(if (/= STY (setq CS (getvar "TEXTSTYLE")))
(progn
(if (not (setq TD (tblsearch "STYLE" STY)))
;not already defined
(dsv_stymake STY nil)
;define it as romans
)
(if (tblsearch "STYLE" STY)
(progn
(setvar "TEXTSTYLE" STY)
(if (null DSV_STYPRVNAM)(setq DSV_STYPRVNAM CS))
)
)
)
)
)
)
; --------------------------------------------------------------------------(defun C:STYSET (/ EP)
(dsc_in "C:STYSET")
(if (setq EP (entsel "\nSelect entity"))(ds_styset (ds_entlay (car EP))))
(dsc_ex)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_STYSET")
; }
;
; { <DSV_STYPRV>=============================================================
; Reset to the saved style name.
|
;
|
; Global vars: {DSV_STYPRVNAM}
|
; --------------------------------------------------------------------------(defun DSV_STYPRV ()
(if (and DSV_STYPRVNAM (/= DSV_STYPRVNAM (getvar "TEXTSTYLE")));not already se
t
(setvar "TEXTSTYLE" DSV_STYPRVNAM)
)
(setq DSV_STYPRVNAM nil)
;no pending style
)
; --------------------------------------------------------------------------(defun C:STYPRV ()(ds_styprv))
; ---------------------------------------------------------------------------

(setq DSEVMT@ "DSV_STYPRV")


; }
;}
;{{<_LAYOUTS_>***************************************************************
;
|
; Functions to control layout and tab handling
|
;
|
; }**************************************************************************
;
; { <DS_<LYOTBL>>============================================================
; Return the vla object for the layouts collection.
|
; --------------------------------------------------------------------------(defun DS_<LYOTBL> ()
(if (ds_verac 15)
(progn
(vl-load-com)
(vla-get-layouts <activeDwg>)
)
)
)
;(setq <layoutsTable> (ds_<LyoTbl>))
; --------------------------------------------------------------------------(setq DSCTRL@ "DS_<LYOTBL>")(loadrpt)
; }
;
; { <DS_<LYOACTV>>===========================================================
; Return the vla object for the current drawing.
|
; --------------------------------------------------------------------------(defun DS_<LYOACTV> ()
(if (ds_verac 15)
(progn
(vl-load-com)
(vla-get-activelayout (dsv_<DwgActv>))
)
)
)
;(setq <activeLyo> (dsv_<LyoActv>))
; --------------------------------------------------------------------------(setq DSCTRL@ "DS_<LYOACTV>")(loadrpt)
; }
;
; { <DSV_LYOALL>=============================================================
; Gather all plot settings and layout data and arrange by tab number
|
; Given: nothing
|
; Return: list with LayoutName, TabSequence, Data on PSpc,Ext,Lim,Ucs
|
; --------------------------------------------------------------------------(defun DSV_LYOALL (/ PL! FG! I PG FL PS SS LM BM RM TM PX PY OX OY WX WY
OX2 OY2 WX2 WY2 SCP SCD SCF SCT PFG PUN PRT PBY NM LC TB LN LX IB UO EN EX
UX UY UR PB VC UN UB PTN PTM PTSZ1 PTSZ2 PTSC PTTY PL PBED PB L& REC RET C
ED FG)
(if (ds_verac 15)
(progn
(princ "\nFinding existing layouts...")
(setq PL! nil FG! nil)
(foreach I (dictsearch (namedobjdict) "ACAD_LAYOUT")
;layouts index
(if (= (car I) 350)
;actual layout ent
(progn
(setq PG nil FL nil PS nil SS nil LM nil BM nil RM nil TM nil)
(setq PX nil PY nil OX nil OY nil WX nil WY nil)
(setq OX2 nil OY2 nil WX2 nil WY2 nil)
(setq SCP nil SCD nil SCF nil SCT nil)

(setq PFG nil PUN nil PRT nil PBY nil)


(setq NM nil LC nil TB nil LN nil LX nil IB nil UO nil)
(setq EN nil EX nil UX nil UY nil UR nil)
(setq PB nil VC nil UN nil UB nil)
(setq ED (entget (cdr I)))
(foreach I ED
(setq C (car I))
(if (= C 100)
(if (= (cdr I) "AcDbPlotSettings")
;plot data
(setq PL! T FG nil)
(if (= (cdr I) "AcDbLayout")
;layout data
(setq FG! T PL! nil)
)
)
)
(if PL!
;in plot data section
(cond
((= C 1)(setq PG (cdr I)))
;page setup name
((= C 2)(setq FL (cdr I)))
;plot config
((= C 4)(setq PS (cdr I)))
;paper size
((= C 7)(setq SS (cdr I)))
;style sheet
((= C 40)(setq LM (cdr I)))
;left margin
((= C 41)(setq BM (cdr I))) ;bottom margin
((= C 42)(setq RM (cdr I)))
;right margin
((= C 43)(setq TM (cdr I)))
;top margin
((= C 44)(setq PX (cdr I)))
;paper horiz
((= C 45)(setq PY (cdr I)))
;paper vert
((= C 46)(setq OX (cdr I)))
;origin horiz
((= C 47)(setq OY (cdr I)))
;origin vert
((= C 48)(setq WX (cdr I))) ;plot window X
((= C 49)(setq WY (cdr I))) ;plot window Y
((= C 148)(setq OX2 (cdr I))) ;origin horiz
((= C 149)(setq OY2 (cdr I))) ;origin vert
((= C 140)(setq WX2 (cdr I))) ;plot window X
((= C 141)(setq WY2 (cdr I))) ;plot window Y
((= C 142)(setq SCP (cdr I)));plot scl paper
((= C 143)(setq SCD (cdr I))) ;plot scl dwg
((= C 147)(setq SCF (cdr I))) ;plot scl fct
((= C 75)(setq SCT (cdr I)))
;scale type
((= C 70)(setq PFG (cdr I)))
;plot flags
((= C 72)(setq PUN (cdr I)))
;paper units
((= C 73)(setq PRT (cdr I))) ;paper rotation
((= C 74)(setq PBY (cdr I))) ;boundary type
)
(if FG!
(cond
((= C 1)(setq NM (cdr I)))
;layout name
((= C 70)(setq LC (cdr I)));ltype and limchk
((= C 71)(setq TB (cdr I)))
;tab number
((= C 10)(setq LN (cdr I))) ;limits minimum
((= C 11)(setq LX (cdr I))) ;limits maximum
((= C 12)(setq IB (cdr I))) ;insertion base
((= C 13)(setq UO (cdr I)))
;UCS origin
((= C 14)(setq EN (cdr I))) ;extents minimum
((= C 15)(setq EX (cdr I))) ;extents maximum
((= C 16)(setq UX (cdr I)))
;UCS X axis
((= C 17)(setq UY (cdr I)))
;UCS Y axis
((= C 76)(setq UR (cdr I))) ;UCS ortho type
((= C 330)(setq PB (cdr I)));paper space blk
((= C 331)(setq VC (cdr I))) ;current vport

((= C 345)(setq UN (cdr I)))


;UCS name
((= C 346)(setq UB (cdr I))) ;UCS ortho base
)
)
)
)
(setq
(setq
(setq
(setq
(setq
(setq
(setq
(setq
(setq
(setq
(setq
(setq
(setq
(setq

PTN (list "*PltCfg*" PG FL SS))


PTM (list "*PpSz*" PS (list PX PY)(list LM BM RM TM)))
PTSZ1 (list "*PltSz1*" (list OX OY)(list WX WY)))
PTSZ2 (list "*PltSz2*" (list OX2 OY2)(list WX2 WY2)))
PTSC (list "*Pscl*" SCP SCD SCF SCT))
PTTY (list "*Ptyp*" PFG PUN PRT PBY))
PL (if (= (rem LC 2) 1) "PSLT1" "PSLT0"));dwgltype of pspace
LC (if (> LC 1) "LMCK1" "LMCK0"))
;limits checking
UO (list "*Ucs*" UO UX UY UR UN UB))
;ucs data group
EX (list "*Ext*" EN EX))
;extents group
LN (list "*Lim*" LC LN LX))
;limits group
PBED (entget PB (list "*")))
PB (list "*PSp*" IB VC PL PBED))
;paper space group
L& (cons (list TB NM TB PB EX LN UO PTN PTM PTSZ1 PTSZ2 PTSC P

TTY) L&))
)
)
)
(if L&
(repeat
(setq
(setq
(setq
)
(prompt
)

(setq I (length L&))


I (1- I))
REC (assoc I L&))
RET (cons (cdr REC) RET))

;arrange by tab number


;data for next tab
;save without tab index

"\nNo layouts defined")

)
)
RET
)
; --------------------------------------------------------------------------(defun DSV_LYODAT (NAM / LED C PD! PD& LD! LD&)
(if (ds_verac 15)
(if (setq LED (dsv_lyo-ed NAM))
(progn
(foreach I LED
(setq C (car I))
(if (= C 100)
(if (= (cdr I) "AcDbPlotSettings")
(setq PD! T LD! nil)
(if (= (cdr I) "AcDbLayout")
(setq LD! T PD! nil)
)
)
)
(if PD!
(setq PD& (cons I PD&))
(if LD! (setq LD& (cons I LD&)))
)
)
)
)
)

;plot data
;layout data

;in plot data section


;in layout data section

(if (and PD& LD&)(list (reverse LD&)(reverse PD&)))


)
;(setq LDT (dsv_lyodat "Layout1"))
; --------------------------------------------------------------------------(defun DSV_LYO-ED (NAM / DE DED DICT& DLE DLED LYO& EE RET)
(if (and (setq DE (namedobjdict))
(setq DED (entget DE (list "*")))
)
(progn
(setq DICT& (multi-ed-assoc DED 100 (list 3 350)))
(setq DLE (cadr (assoc "ACAD_LAYOUT" DICT&)))
(setq DLED (entget DLE (list "*")))
(setq LYO& (multi-ed-assoc DLED 100 (list 3 350)))
(if (setq EE (cadr (assoc NAM LYO&)))
(setq RET (entget EE (list "*")))
(progn (princ "\n[LyoData]Layout ")(prin1 NAM)(princ " is not defined\n"
))
)
)
)
RET
)
; --------------------------------------------------------------------------(defun C:GLHELP ()
(princ "\nLayout name")(princ " [Tab sequence]")
(princ "\n*PSp*-BasePt,CurVp,Ltype,PaperSpcBlk")
(princ "\n*Ext*-ExtBotLeft,ExtTopRight")
(princ "\n*Lim*-LtypLmCk,LimBotLeft,LimTopRight")
(princ "\n*Ucs*-Orig,Xaxis,Yaxis,OrthoTyp,Name,BasePt")
(princ "\n*PltCfg*-PagNam,PltCfgFil,StyleSht")
(princ "\n*PpSz*-PaperSzNam,PaperSz,Margins(L/B/R/T)")
(princ "\n*PltSz1*-Origin,Window")
(princ "\n*PltSz2*-Origin,Window")
(princ "\n*PScl*-PlotUnits,DwgUnits,SclFct,SclTyp")
(princ "\n*PTyp*-PlotFlags,PlotUnits,PlotRot,PltTyp")
(prin1)
)
; --------------------------------------------------------------------------(defun C:GL (/ I)
(c:glhelp)
(foreach I (dsv_lyoall)
;each tab
(princ "\n\n")
(princ (car I))
(princ " [")
(princ (cadr I))
(princ "]")
(foreach P (cdr (cdr I))
(princ "\n")
(prin1 P)
)
)
(prin1)
)
; --------------------------------------------------------------------------;Model [0]
;("*Psd*" (0.0 0.0 0.0) <Entity name: 4005dcf8> nil "PSLT1")
;("*Ext*" (0.0 0.0 0.0) (0.0 0.0 0.0))
;("*Lim*" "LMCK0" (0.0 0.0 0.0) (12.0 9.0 0.0))
;("*Ucs*" (0.0 0.0 0.0) (1.0 0.0 0.0) (0.0 1.0 0.0) 0 nil nil)
;((-1 . <Entity name: 4005dcf8>) (0 . "BLOCK_RECORD")

; (330 . <Entity name: 4005dc08>) (5 . "1F") (100 . "AcDbSymbolTableRecord")


; (100 . "AcDbBlockTableRecord") (2 . "*Model_Space")
; (360 . <Entity name: 4005dd00>) (340 . <Entity name: 4005dd10>)
;)
;
;Layout1 [1]
;("PSD" (0.0 0.0 0.0) <Entity name: 4005dcd8> <Entity name: 4005dd70> "PSLT1")
;("EXT" (0.959892 0.80438 0.0) (8.63902 7.23942 0.0))
;("LIM" "LMCK0" (-0.700542 -0.2281 0.0) (10.2995 8.2719 0.0))
;("UCS" (0.0 0.0 0.0) (1.0 0.0 0.0) (0.0 1.0 0.0) 0 nil nil)
;((-1 . <Entity name: 4005dcd8>) (0 . "BLOCK_RECORD")
; (330 . <Entity name: 4005dc08>) (5 . "1B") (100 . "AcDbSymbolTableRecord")
; (100 . "AcDbBlockTableRecord") (2 . "*Paper_Space0")
; (360 . <Entity name: 4005dce0>) (340 . <Entity name: 4005dcf0>)
;)
;
;Layout2 [2]
;("PSD" (0.0 0.0 0.0) <Entity name: 4005dd18> <Entity name: 4005dda0> "PSLT1")
;("EXT" (0.959892 0.80438 0.0) (8.63902 7.23942 0.0))
;("LIM" "LMCK0" (-0.700542 -0.2281 0.0) (10.2995 8.2719 0.0))
;("UCS" (0.0 0.0 0.0) (1.0 0.0 0.0) (0.0 1.0 0.0) 0 nil nil)
;((-1 . <Entity name: 4005dd18>) (0 . "BLOCK_RECORD")
; (330 . <Entity name: 4005dc08>) (5 . "23") (100 . "AcDbSymbolTableRecord")
; (100 . "AcDbBlockTableRecord") (2 . "*Paper_Space1")
; (360 . <Entity name: 4005dd20>) (340 . <Entity name: 4005dd30>)
;)
;
;Layout3 [3]
;("PSD" (0.0 0.0 0.0) <Entity name: 4005ddb8> nil "PSLT1")
;("EXT" (0.0 0.0 0.0) (0.0 0.0 0.0))
;("LIM" "LMCK0" (0.0 0.0 0.0) (12.0 9.0 0.0))
;("UCS" (0.0 0.0 0.0) (1.0 0.0 0.0) (0.0 1.0 0.0) 0 nil nil)
;((-1 . <Entity name: 4005ddb8>) (0 . "BLOCK_RECORD")
; (330 . <Entity name: 4005dc08>) (5 . "37") (100 . "AcDbSymbolTableRecord")
; (100 . "AcDbBlockTableRecord") (2 . "*Paper_Space")
; (360 . <Entity name: 4005ddc8>) (340 . <Entity name: 4005ddc0>)
;)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYOALL")
; }
;
; { <DSV_LYOLIST>============================================================
; Get all layout names and associated entity names sorted by tab order.
|
; Given: Nothing
|
; Return: list or nil
|
; --------------------------------------------------------------------------(defun DSV_LYOLIST (/ N CNT <LYO> NAM$ M! RET)
(setq LED (dictsearch (namedobjdict) "ACAD_LAYOUT"))
;all layouts
(foreach ITM LED
;get entity following (3 . SpecifiedLayoutName)
(if (= (car ITM) 3)(setq OK T NAM (cdr ITM)))
(if (and OK (= (car ITM) 350))
(setq LYO& (cons (list NAM (cdr ITM)) LYO&) OK nil)
)
)
(foreach F_NAM (reverse (layoutlist))
(setq LYO (assoc F_NAM LYO&))
(setq RET (cons LYO RET))
)
(if (setq LYO (assoc "Model" LYO&))(setq RET (cons LYO RET)))
RET
;return list

)
;(setq LYOLIST (dsv_lyolist))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYOLIST")
; }
;
; { <DSV_<LYOLIST>>==========================================================
; Get all layout names and associated vlax object names sorted by tab order.|
; Given: Nothing
|
; Return: list or nil
(layoutlist)
|
; --------------------------------------------------------------------------(defun DSV_<LYOLIST> (/ N <LyoTbl> <LyoObj> NAM$ TAB MS PS RET)
(setq N 0 <LyoTbl> (ds_<LyoTbl>))
(repeat (vla-get-count <LyoTbl>)
(setq <LyoObj> (vlax-invoke-method <LyoTbl> "Item" N))
(setq NAM$ (vla-get-name <LyoObj>))
(setq TAB (vla-get-taborder <LyoObj>))
(if (= (vla-get-modeltype <LyoObj>) :vlax-true)
(setq MS (cons (list TAB NAM$ <LyoObj>) MS))
(setq PS (cons (list TAB NAM$ <LyoObj>) PS))
)
(setq N (1+ N))
)
(if MS (setq MS (dsk_sortmtx MS 1)))
(if PS (setq PS (dsk_sortmtx PS 1)))
(foreach F_LYO (reverse (append MS PS))
(setq RET (cons (cdr F_LYO) RET))
)
RET
)
;(setq <LyoList> (dsv_<LyoList>))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_<LYOLIST>")
; }
;
; { <DSV_LYOENT>=============================================================
; Return the entity for the named layout
|
; Given: LAyout Name
|
; Return: ename or nil
|
; --------------------------------------------------------------------------(defun DSV_LYOENT (NAM / DE DED OK LE LED)
(setq LE (cadr (assoc NAM (dsv_lyolist))))
)
;(setq LYOENT (dsv_lyoent "Layout1"))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYOENT")
; }
;
; { <DSV_LYOMAKE>============================================================
; Make new layout
|
; Given: tab name and either template name or plot settings list
|
; Return: T or nil to indicate success
|
; --------------------------------------------------------------------------(defun DSV_LYOMAKE (NAM / F$ OK! PG& PFX PG# LYO1& VPE1& LYO2& VPE2& NEWVP&
NEW OK! RET)
(setq F$ (func_in "DSV_LYOMAKE" "NAM"))
(setq NAM (ds_frcstr NAM))
(if (ds_verac 15)
(progn
(setq OK! T)
(setq PG& (dsk_lnpdiv NAM)) ;divide prefix and number - {"Page" "01"}

(setq PFX (car PG&))


;prefix - "Page"
(setq PG# (atoi (cadr PG&)))
;new layout sequence - 1
(setq LYO1& (layoutlist))
;current layouts
(if (ds_membstr NAM LYO1&)(ds_command "_.-LAYOUT" (list "D" NAM)))
(ds_command "_.-LAYOUT" (list "N" NAM))
(setq LYO2& (layoutlist))
;layouts after command
(foreach F_LYO LYO2&
(if (not (member F_LYO LYO1&))(setq NEW F_LYO))
;new one
)
(if (and NEW (/= NEW NAM)(not (member NAM LYO1&)))
(ds_command "_.-LAYOUT" (list "R" NEW NAM))
;if created, rename
)
(if (ds_membstr NAM (layoutlist))
;verify the rename
(progn
(func_msg F$ (strcat "Added layout: " NAM) nil)
(if (not (ds_membstr NAM DSV_TABNDX&))
(setq DSV_TABNDX& (reverse (cons NAM (reverse DSV_TABNDX&))))
)
(dsv_pltdiaset NAM)
;stop plot settings dialog
)
(progn
(func_msg F$ (strcat "Requested layout "
NAM " was NOT created.") nil)
(setq OK! nil)
)
)
)
(progn
(func_msg F$ "Layouts are not supported in this version"
nil)
(setq OK! nil)
)
)
(if (null OK!)(ds_wait))
(setq RET (or (member NAM (layoutlist))))
(func_ex F$ RET)
;return T or nil to indicate success
)
; --------------------------------------------------------------------------(defun C:MKLYO[TEST] (/ DAT1 PG1 DAT2 PG2 DAT3 PG3 DAT4 PG4)
(setq DSV_PGTOTQTY 4)
(setq DAT1 (ds_pgdata "CPAK" 1))
(setq PG1 (cons (car DAT1)(cdr (assoc "PgDef" (cdr DAT1)))))
(dsv_lyomake PG1)
(setq DAT2 (ds_pgdata "CPAK" 2))
(setq PG2 (cons (car DAT2)(cdr (assoc "PgDef" (cdr DAT2)))))
(dsv_lyomake PG2)
(setq DAT3 (ds_pgdata "CPAK" 3))
(setq PG3 (cons (car DAT3)(cdr (assoc "PgDef" (cdr DAT3)))))
(dsv_lyomake PG3)
(setq DAT4 (ds_pgdata "CPAK" 4))
(setq PG4 (cons (car DAT4)(cdr (assoc "PgDef" (cdr DAT4)))))
(dsv_lyomake PG4)
(setvar "CTAB" (car PG1))
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYOMAKE")
; }
;
; { <DSV_LYOTPLT>============================================================
; Make new layout based on a given template
|

; Given: tab name and template name


|
; Return: T or nil to indicate success
|
; --------------------------------------------------------------------------(defun DSV_LYOTPLT (NAM TPLT / F$ OK! PG& PFX PG# LYO1& TPLT! PROP& LYO2& NEW
EX! RET)
(setq F$ (func_in "DSV_LYOTPLT" (list "NAM" "TPLT")))
(if (ds_verac 15)
(if (and (ds_isstrval? TPLT) TPLT (/= TPLT "None")(ds_tplvfy TPLT))
(progn
(setq OK! T)
(setq PG& (dsk_lnpdiv NAM)) ;divide prefix and number - {"Page" "01"}
(setq PFX (car PG&))
;prefix - "Page"
(setq PG# (atoi (cadr PG&)))
;new layout sequence - 1
(setq LYO1& (layoutlist))
;current layouts
(if (ds_membstr NAM LYO1&)(ds_command "_.-LAYOUT" (list "D" NAM)))
(ds_command "_.-LAYOUT" (list "T" TPLT "LAYOUT1"))
(setq LYO2& (layoutlist))
;layouts after command
(foreach LYO LYO2&
(if (not (member LYO LYO1&))(setq NEW LYO))
;new one
)
(if (and NEW (/= NEW NAM))
(ds_command "_.-LAYOUT" (list "R" NEW NAM))
;if created, rename
)
(func_msg F$ (strcat "Added layout: " NAM) nil)
(if (ds_membstr NAM (layoutlist))
;verify the rename
(progn
(if (not (ds_membstr NAM DSV_TABNDX&))
(setq DSV_TABNDX& (reverse (cons NAM (reverse DSV_TABNDX&))))
)
(dsv_pltdiaset NAM)
)
)
)
)
(progn
(func_msg F$ "Layouts are not supported in this version"
nil)
(setq OK! nil)
)
)
(if (null OK!)(ds_wait))
(setq RET (or (member NAM (layoutlist))))
(func_ex F$ RET)
;return T or nil to indicate success
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYOTPLT")
; }
;
; { <DSV_LYOCHG>=============================================================
; Change the properties of a given layout.
|
; Given: tab name and plot settings list
|
; Return: T or nil to indicate success
|
; --------------------------------------------------------------------------(defun DSV_LYOCHG (NAM PROP& / F$ OK! DVC PSZ MGN LOC RET)
(setq F$ (func_in "DSV_LYOCHG" (list "NAM" "PROP&")))
(if (ds_verac 15)
(if (ds_membstr NAM (layoutlist))
;verify the layout name
(progn
(setq OK! T)
;assume everything will work

(setq DVC (cdr (assoc "DVC" PROP&)))


(setq PSZ (cdr (assoc "PSZ" PROP&)))
(setq MGN (cdr (assoc "MGN" PROP&)))
(setq LOC (cdr (assoc "LOC" PROP&)))
(if (setq OK! (dsv_pltdvcset NAM DVC))
(if (setq OK! (dsv_pltpszset NAM PSZ))
(progn
(dsv_pltmgnset NAM MGN)
(dsv_pltlocset NAM LOC)
(setvar "CTAB" "Model")
(setvar "CTAB" NAM)
)
(setq OK! (prompt "\n[LyoChg]Paper size was not successfully set "))
)
(setq OK! (prompt "\n[LyoChg]Plot device was not successfully set "))
)
(if (member NAM (layoutlist))(setvar "CTAB" NAM))
(setq RET (or (ds_membstr NAM (layoutlist)))) ;T or nil to report succes
s
)
(setq OK! (prompt (strcat "\n[LyoChg] - Layout " (ds_frcstr NAM) " does no
t exist ")))
)
(setq OK! (prompt (strcat "\n[LyoChg] - Layouts are not supported in this ve
rsion ")))
)
(if (null OK!)(getstring "Press enter to continue..."))
(func_ex F$ RET)
;return data list or nil
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYOCHG")
; }
;
; { <DSV_LYODELX>============================================================
; Delete all layouts not on the given list
|
; Given: tab name and template name
|
; Return: T or nil to indicate success
|
; --------------------------------------------------------------------------(defun DSV_LYODELX (NDX& / ND RET)
(if (ds_verac 15)
(if (ds_islist? NDX&)
(progn
(foreach N NDX&
(if (ds_islist? N)
(setq ND (cons (car N) ND))
(if (ds_isstrval? N)(setq ND (cons N ND)))
)
)
(if ND (setq NDX& ND))
(setq NDX& (cons "Model" NDX&))
(foreach F_LYO (layoutlist)
(if (not (member F_LYO NDX&))
(ds_command "_.-LAYOUT" (list "D" F_LYO))
)
)
(setq RET T)
(foreach F_LYO (layoutlist)
(if (member F_LYO NDX&)(setq RET nil))
)

)
)
)
RET
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYODELX")
; }
;
; { <DSV_LYOCUR>=============================================================
; Return tab name of current layout
|
; --------------------------------------------------------------------------(defun DSV_LYOCUR (/ VR)
(if (ds_verac 15)
(getvar "CTAB")
(if (ds_verac 13)
(if (= (getvar "TILEMODE") 1) "MS" "PS")
"MS"
)
)
)
; --------------------------------------------------------------------------(defun C:CLYO ()(prin1 (dsv_lyocur))(princ))
;show current layout name
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYOCUR")
; }
;
; { <DSV_LYOSET>=============================================================
; Set given layout as current
|
; --------------------------------------------------------------------------(defun DSV_LYOSET (NM / RET)
(if (ds_verac 15)
(if (ds_membstr NM (layoutlist))
(progn
(if (/= (strcase NM)(strcase (getvar "CTAB")))(setvar "CTAB" NM))
(setq RET (dsv_pspset))
)
(if (= NM "PS")
(setq RET (dsv_pspset))
(progn
(princ "\n")(prin1 NM)(princ " is not a valid layout.")
(setq RET nil)
)
)
)
(if (ds_verac 13)
(if (= (strcase NM) "PS")
(setq RET (dsv_pspset))
(if (or (= (strcase NM) "MS")(= (strcase NM) "MODEL"))
(setq RET (dsv_mspset))
)
)
)
)
RET
)
; --------------------------------------------------------------------------(defun C:SLYO (/ NM)
(if (setq NM (getstring "\nLayout name: "))
(dsv_lyoset NM)

)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYOSET")
; }
;
; { <DSV_LYOLOC>=============================================================
; Return diagonal corner points of the viewing area of the given layout.
|
; --------------------------------------------------------------------------(defun DSV_LYOLOC (NM / VP RET)
(if (setq VP (cdr (assoc NM (dsv_vppslist))))
(setq RET (dsv_vploc VP))
)
RET
)
;(setq LYOLOC& (dsv_lyoloc (dsv_lyocur)))
;--------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYOLOC")
; }
;
; { <DSV_LYOLOCSET>==========================================================
; Verify diagonal corner points of the viewing area of the given layout.
|
; --------------------------------------------------------------------------(defun DSV_LYOLOCSET (NM LOC / BL TR VP LOC P1 P2)
(setq BL (car LOC) TR (cadr LOC))
(if (setq VP (cdr (assoc NM (dsv_vppslist))))
(progn
(setq LOC (dsv_vploc VP) P1 (car LOC) P2 (cadr LOC))
(if (or (not (ds_samept? P1 BL))(not (ds_samept? P2 TR)))
(ds_command "_.ZOOM" (list "W" BL TR))
)
)
)
(princ)
)
;(dsv_lyolocset (dsv_lyocur)(list (list 0.0 0.0)(list 34.0 22.0)))
;--------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYOLOCSET")
; }
;
; { <DSV_LYODEL>=============================================================
; Delete the named layout if it exists
|
; Given: tab name
|
; Return: T or nil to indicate success
|
; --------------------------------------------------------------------------(defun DSV_LYODEL (NAM / ND RET)
(if (and (setq ERR "Layouts are not available before Autocad 2000")
(ds_verac 15)
(setq ERR "Name given is not a valid string")
(ds_isstrval? NAM)
(setq ERR "Can not delete the 'Model' tab")
(/= (strcase NAM) "MODEL")
(setq ERR (strcat "'" NAM "' is not a defined layout"))
(setq <LO> (cadr (assoc NAM (dsv_<LyoList>))))
(setq ERR (strcat "'" NAM "' can not translate to Vlax"))
(setq <LO> (vlax-ename->vla-object LE))
)
(progn
(setvar "CTAB" "Model")
(setq <OK> (vlax-invoke-method <LO> "Delete"))
;(foreach N NDX&

; (if (ds_islist? N)
;
(setq ND (cons (car N) ND))
;
(if (ds_isstrval? N)(setq ND (cons N ND)))
; )
;)
;(if ND (setq NDX& ND))
;(setq NDX& (cons "Model" NDX&))
;(foreach F_LYO (layoutlist)
; (if (not (member F_LYO NDX&))
;
(ds_command "_.-LAYOUT" (list "D" F_LYO))
; )
;)
(setq RET T)
(foreach F_LYO (layoutlist)
(if (= (strcase F_LYO)(strcase NAM))(setq RET nil))
)
)
)
RET
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYODEL")
; }
;
; { <DSV_LYONAM>=============================================================
; Return layout name of a given entity
|
; --------------------------------------------------------------------------(defun DSV_LYONAM (E / ED LYO)
(setq ED (entget E))
(if (ds_verac 15)
(setq LYO (cdr (assoc 410 ED)))
(if (ds_verac 12)
(setq LYO (if (= (cdr (assoc 67 ED)) 1) "PS" "MS"))
(setq LYO "MS")
)
)
LYO
)
; --------------------------------------------------------------------------(defun C:ELYO (/ EP)
;show layout name of selected object
(if (setq EP (entsel))(prin1 (dsv_lyonam (car EP))))
(princ)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYONAM")
; }
;
; { <DSV_LYOSORT>============================================================
; Sort entities by space and layout. Accept entities as a name, a list, or |
; SSET. RETURN entities as an association list with key identifiers.
|
; If Autocad is release 15 or later key identifiers are "Model" and each of |
; the layout names (in paper space) defined in the drawing.
|
; If Autocad is release 13 or 14 key identifiers are "Model" and "Paper"
|
; If Autocad is before release 13 the only key identifier is "Model"
|
; --------------------------------------------------------------------------(defun DSV_LYOSORT (SS / N RET LYO E ED)
(setq SS (dse_sset SS) N 0)
(cond
((ds_verac 15)

(setq RET (list (list "Model" (ssadd))))


(foreach LYO (layoutlist)(setq RET (cons (list LYO (ssadd)) RET)))
(setq RET (reverse RET))
(repeat (sslength SS)
(setq E (ssname SS N) N (1+ N) ED (entget E))
(setq LYO (cdr (assoc 410 ED)))
(ssadd E (cadr (assoc LYO RET)))
)
)
((ds_verac 13)
(setq RET (list (list "Model" (ssadd))(list "Paper" (ssadd))))
(repeat (sslength SS)
(setq E (ssname SS N) N (1+ N) ED (entget E))
(setq LYO (if (= (cdr (assoc 67 ED)) 1) "Paper" "Model"))
(ssadd E (cadr (assoc LYO RET)))
)
)
(T (setq RET (list (list "Model" SS))))
)
RET
)
; --------------------------------------------------------------------------(defun C:LYOSORT (/ SS)
(setq SS (ssget "X") DSV_LYOSORT (dsv_lyosort SS))
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_LYOSORT")
; }
;
; { <DSV_PSPCHK>=============================================================
; Check to see if paper space is current
|
; --------------------------------------------------------------------------(defun DSV_PSPCHK (/ RET)
(cond
((ds_verac 15)
(setq RET (and (/= (getvar "CTAB") "Model")(= (getvar "CVPORT") 1)))
)
((ds_verac 12)
(setq RET (and (= (getvar "TILEMODE") 0)(= (getvar "CVPORT") 1)))
)
(T (setq RET nil))
)
RET
)
; --------------------------------------------------------------------------(defun DSV_PSPACE? ()(dsv_pspchk))
; --------------------------------------------------------------------------(defun DS_PSPACE? ()(dsv_pspchk))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_PSPCHK")
; }
;
; { <DSV_PSPSET>=============================================================
; Set paper space as current
|
; --------------------------------------------------------------------------(defun DSV_PSPSET (/ VR RET)
(if (ds_verac 15)
(if (= (getvar "CTAB") "Model")(setvar "CTAB" (car (layoutlist))))
(if (ds_verac 13)
(if (= (getvar "TILEMODE") 0)(setvar "TILEMODE" 0))

)
)
(if (/= (getvar "CVPORT") 1)(ds_command "_.PSPACE" nil))
(setq RET (dsv_pspchk))
RET
)
; --------------------------------------------------------------------------(defun DSV_PSPACE! ()(dsv_pspset))
; --------------------------------------------------------------------------(defun DS_PSPACE! ()(dsv_pspset))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_PSPSET")
; }
;
; { <DSV_PSPMOV>=============================================================
; Move given objects from model space to paper space with same coordinates. |
; --------------------------------------------------------------------------(defun DSV_PSPMOV (E& / EE& SS PFX)
(if (ds_verac 15)
(progn
(if (not (ds_list? E&))(setq E& (list E&)))
;make sure it is a lis
t
(setq SS (ssadd))
(foreach E E&
(if (ds_isent? E)
(if (= (cdr (assoc 67 (entget E))) 0)(ssadd E SS))
)
)
(if (ssname SS 0)
(progn
(setq PFX (if (ds_verac 15) "_.-" "_."))
(dsv_mspset)
(ds_command (strcat PFX "BLOCK")(list "TEMP" "0,0" SS))
(dsv_pspset)
(ds_command (strcat PFX "INSERT")(list "*TEMP" "0,0" "1" "0"))
)
)
(setq SS nil)(gc)
)
)
(princ)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_PSPMOV")
; }
;
; { <DSV_MSPCHK>=============================================================
; Check to see if model space is current
|
; --------------------------------------------------------------------------(defun DSV_MSPCHK (/ RET)
(cond
((ds_verac 15)
(setq RET (or (= (getvar "CTAB") "Model")(/= (getvar "CVPORT") 1)))
)
((ds_verac 12)
(setq RET (and (= (getvar "TILEMODE") 0)(/= (getvar "CVPORT") 1)))
)
(T (setq RET T))
)
RET

)
; --------------------------------------------------------------------------(defun DSV_MSPACE? ()(dsv_mspchk))
; --------------------------------------------------------------------------(defun DS_MSPACE? ()(dsv_mspchk))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_MSPCHK")
; }
;
; { <DSV_MSPSET>=============================================================
; Set model space as current
|
; --------------------------------------------------------------------------(defun DSV_MSPSET (/ VP& OK!)
(if (ds_verac 13)
(if (= (getvar "TILEMODE") 0)
;only if paperspace is not locked out
(if (= (getvar "CVPORT") 1)
;only if in paper space now
(if (setq VP& (dsv_vpmslist (getvar "CTAB")))
;ms vports
(progn
(setq OK! nil)
(foreach F_VP VP&
(setq STR (cadr (caddr F_VP)))
(if (and (/= STR "HID")(/= STR "OFF"))
(setq OK! T)
)
)
(ds_command "_.MSPACE" nil)
;switch to one
)
)
;already in model space
)
)
)
T
)
; --------------------------------------------------------------------------(defun DSV_MSPACE! ()(dsv_mspset))
; --------------------------------------------------------------------------(defun DS_MSPACE! ()(dsv_mspset))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_MSPSET")
; }
;
; { <DSV_MSPMOV>=============================================================
; Move given objects from paper space to model space with same coordinates. |
; --------------------------------------------------------------------------(defun DSV_MSPMOV (E& / EE& SS PFX)
(if (ds_verac 15)
(progn
(if (not (ds_islist? E&))(setq E& (list E&)))
;make sure it is a l
ist
(setq SS (ssadd))
(foreach E E&
(if (ds_isent? E)
(if (= (cdr (assoc 67 (entget E))) 1)(ssadd E SS))
)
)
(if (ssname SS 0)
(progn
(setq PFX (if (ds_verac 15) "_.-" "_."))
(dsv_pspset)

(ds_ssv "EXPERT" 4)
(ds_command (strcat PFX "BLOCK")(list "TEMP" "0,0" SS ""))
(dsv_mspset)
(ds_command (strcat PFX "INSERT")(list "*TEMP" "0,0" "1" "0"))
(ds_rsv "EXPERT")
)
)
(setq SS nil)(gc)
)
)
(princ)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_MSPMOV")
; }
;}
;{{<_PLOTSETTINGS_>**********************************************************
;
*
; Functions to control plot settings in a given layout
*
;
*
; }**************************************************************************
;
; { <DSV_PLTPROP>============================================================
; Display all plot settings from the current layout.
|
; --------------------------------------------------------------------------(defun DSV_PLTPROP (/ DVC PSZ MGN LOC)
(setq DVC (dsv_pltdvcget nil))
(princ "\nPlot Device: ")(prin1 DVC)
(setq PSZ (dsv_pltpszget nil))
(princ "\nPaper size: ")(prin1 (car PSZ))
(princ " - Dimensions: ")(prin1 (cdr PSZ))
(setq MGN (dsv_pltmgnget nil))
(princ "\nMargins: ")(prin1 MGN)
(setq LOC (dsv_pltlocget nil))
(princ "\nLocation: ")(prin1 LOC)
(princ)
)
; --------------------------------------------------------------------------;(setq LED1 (entget (dsv_lyoent "All_Pages")))
;(setq LED2 (entget (dsv_lyoent "All_Pages")))
; --------------------------------------------------------------------------(defun C:PLOTPROP ()(dsv_pltprop))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_PLTPROP")
; }
;
; { <DSV_PLTDVCLST>==========================================================
; Get a list of all available plot devices.
|
; Given: nothing
|
; Return: Plot defice name or pc3 file (string)
|
; --------------------------------------------------------------------------(defun DSV_PLTDVCLST (/ <LyoActv>)
(setq <LyoActv> (ds_<LyoActv>))
(setenv "HideSystemPrinters" "0")
(vla-RefreshPlotDeviceInfo <LyoActv>)
(vlax-invoke <LyoActv> 'getplotdevicenames)
)
;(setq PDVC-ALL$ (dsv_pltdvclst))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_PLTDVCLST")
; }

;
; { <DSV_PLTDVCGET>==========================================================
; Get the current plot device for the given layout.
|
; Given: LayoutName
|
; Return: Plot defice name or pc3 file (string)
|
; --------------------------------------------------------------------------(defun DSV_PLTDVCGET (NAM / LED)
(if (not (member NAM (layoutlist)))(setq NAM (getvar "CTAB")))
(setq LED (entget (dsv_lyoent NAM)))
(cdr (assoc 2 LED))
;plotter config name
)
;(setq PDVC-C$ (dsv_pltdvcget (getvar "CTAB")))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_PLTDVCGET")
; }
;
; { <DSV_PLTDVCOPTS>=========================================================
; Get all plot device options for the given layout.
|
; Given: LayoutName
|
; Return: all plot device names (list)
|
; --------------------------------------------------------------------------(defun DSV_PLTDVCOPTS (NAM / LO <PDV>)
(if (not (member NAM (layoutlist)))(setq NAM (getvar "CTAB")))
(vl-load-com)
;make sure active x is loaded
(setq LO (vlax-ename->vla-object (dsv_lyoent NAM)))
(vlax-invoke-method LO "RefreshPlotDeviceInfo")
(setq <PDV> (vlax-invoke-method LO "GetPlotDeviceNames"))
(vlax-safearray->list (vlax-variant-value <PDV>))
)
;(setq PDVC-O& (dsv_pltdvcopts (getvar "CTAB")))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_PLTDVCOPTS")
; }
;
; { <DSV_PLTDVCSET>==========================================================
; Change the specified plot device for the given layout.
|
; Given: LayoutName, PlotDeviceName
|
; Return: T or nil
|
; --------------------------------------------------------------------------;The plot device name is specified in the ConfigName property
; --------------------------------------------------------------------------;The plot origin is controlled with thePlotOrigin property.
;If the CenterPlot property is set to TRUE it alters the plot origin.
; --------------------------------------------------------------------------;The PlotType property must be one of the following:
;acDisplay - Prints current model space display (not avail in paper spc).
;acExtents - Prints the extents of the current space.
;acLimits - Prints the limits of the current space.
;acView - Prints the view named by the ViewToPlot property.
;acWindow - Prints the window specified by the SetWindowToPlot method.
;acLayout - Prints the specified layout (not avail in model space).
; --------------------------------------------------------------------------;To enter a standard scale, first set the UseStandardScale property to TRUE.
;Then enter the desired scale using theStandardScale property.
;Or use the acScaleToFit value of the StandardScale property
;To enter a custom scale, first set the UseStandardScale property to FALSE.
;Then enter the custom scale using theSetCustomScale method.
; --------------------------------------------------------------------------;To scale lineweights, set the ScaleLineweights property to TRUE.
; --------------------------------------------------------------------------(defun DSV_PLTDVCSET (NAM PLTR / IPLT NAMS& LO CPLT RET)

(if (not (member NAM (layoutlist)))(setq NAM (getvar "CTAB")))


(setq IPLT (dsv_pltdvcget NAM))
(if (/= IPLT PLTR)
(if
(and
(ds_isstrval? PLTR)
(setq NAMS& (dsv_pltdvcopts NAM))
(ds_membstr PLTR NAMS&)
;Note: in future expand on the use of options to find a device
)
(progn
(vl-load-com)
;make sure active x is loaded
(setq LO (vlax-ename->vla-object (dsv_lyoent NAM)))
(vlax-put-property LO "ConfigName" PLTR)
(vlax-invoke-method LO "RefreshPlotDeviceInfo")
(setq CPLT (dsv_pltdvcget NAM))
(if (not (equal (strcase PLTR)(strcase CPLT)))
(progn
(princ "[PltDevSet]Device was not set correctly.")
(princ "\nRequested: ")(prin1 PLTR)
(princ "\nCurrent: ")(prin1 CPLT)
(setq RET nil)
)
(setq RET T)
;return T if successful
)
)
(progn
(princ "\n[PltDevSet]Requested plot device was not available.")
(princ "\nRequested: ")(prin1 PLTR)
(princ "\nAvailable: ")(prin1 NAMS&)
(setq RET nil)
)
)
(setq RET T)
;return T if successful
)
RET
)
;(dsv_pltdvcset (getvar "CTAB") "HP LaserJet 8100.pc3")
;(dsv_pltdvcset (getvar "CTAB") "\\USHSTFILE1\HSTCAD01")
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_PLTDVCSET")
; }
;
; { <DSV_PLTPSZGET>==========================================================
; Get the current paper size for the given layout.
|
; Given: LayoutName
|
; Return: list as follows:
|
; Return: list {"Nam", WidInches, HgtInches}
|
; --------------------------------------------------------------------------(defun DSV_PLTPSZGET (NAM / LED PSZ WID HGT)
(if (not (member NAM (layoutlist)))(setq NAM (getvar "CTAB")))
(setq LED (entget (dsv_lyoent NAM)))
(setq PSZ (cdr (assoc 4 LED)))
;papersize config name
(setq WID (/ (cdr (assoc 44 LED)) 25.4))
(setq HGT (/ (cdr (assoc 45 LED)) 25.4))
(list PSZ WID HGT)
)
;(setq PPSZ-C& (dsv_pltpszget (getvar "CTAB")))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_PLTPSZGET")
; }

;
; { <DSV_PLTPSZOPTS>=========================================================
; Get all paper size options for the current plot device.
|
; Given: LayoutName
|
; Return: all paper size names (list)
|
; --------------------------------------------------------------------------(defun DSV_PLTPPRSIZES (LYO / LE LO <PSZ> NAMS CPDVC$ CPPSZ& LED WID HGT RET)
(if (not (member LYO (layoutlist)))(setq LYO (getvar "CTAB")))
(vl-load-com)
;make sure active x is loaded
(setq LE (dsv_lyoent LYO))
(setq LO (vlax-ename->vla-object LE))
(vlax-invoke-method LO "RefreshPlotDeviceInfo")
(setq <PSZ> (vlax-invoke-method LO "GetCanonicalMediaNames"))
(setq NAMS (reverse (vlax-safearray->list (vlax-variant-value <PSZ>))))
(setq CPDVC$ (dsv_pltdvcactv LYO))
(setq CPPSZ& (dsv_pltpszget LYO))
(foreach NAM NAMS
(vlax-put-property LO "CanonicalMediaName" NAM)
(setq LED (entget LE))
(setq WID (/ (cdr (assoc 44 LED)) 25.4))
(setq HGT (/ (cdr (assoc 45 LED)) 25.4))
(setq RET (cons (list NAM WID HGT) RET))
)
(vlax-put-property LO "CanonicalMediaName" (car CPPSZ&))
(if RET (reverse RET))
)
;(setq PPSZ-O& (dsv_pltpprsizes (getvar "CTAB")))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_PLTPSZOPTS")
; }
;
; { <DSV_PLTPSZOPTS>=========================================================
; Get all paper size options for the current plot device.
|
; Given: LayoutName
|
; Return: all paper size names (list)
|
; --------------------------------------------------------------------------(defun DSV_PLTPSZOPTS (NAM / LO <PSZ>)
(if (not (member NAM (layoutlist)))(setq NAM (getvar "CTAB")))
(vl-load-com)
;make sure active x is loaded
(setq LO (vlax-ename->vla-object (dsv_lyoent NAM)))
(vlax-invoke-method LO "RefreshPlotDeviceInfo")
(setq <PSZ> (vlax-invoke-method LO "GetCanonicalMediaNames"))
(reverse (vlax-safearray->list (vlax-variant-value <PSZ>)))
)
;(setq PPSZ-O& (dsv_pltpszopts (getvar "CTAB")))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_PLTPSZOPTS")
; }
;
; { <DSV_PLTPSZSET>==========================================================
; Change the specified paper size for the given layout.
|
; Given: LayoutName, {"PszNam", WidInches, HgtInches}
|
; Return: T or nil
|
; --------------------------------------------------------------------------(defun DSV_PLTPSZSET (NAM PSZ& / IPSZ& NAMS& DEF& PSZV LO CPSZ&)
(if (not (member NAM (layoutlist)))(setq NAM (getvar "CTAB")))
(setq IPSZ& (dsv_pltpszget NAM))
(setq NAMS& (dsv_pltpszopts NAM))
(if (setq PSZV (ds_membstr (car PSZ&) NAMS&))
;Note: in future expand on the use of numeric sizes to find a setting
(progn

(vl-load-com)
;make sure active x is loaded
(setq LO (vlax-ename->vla-object (dsv_lyoent NAM)))
(vlax-put-property LO "CanonicalMediaName" (car PSZV))
)
(progn
(princ "\n[PltPszSet]Requested paper size was not available.")
(princ "\nRequested: ")(prin1 (car PSZ&))
(princ "\nAvailable: ")(prin1 NAMS&)
)
)
(setq CPSZ& (dsv_pltpszget NAM))
(equal (strcase (car PSZ&))(strcase (car CPSZ&)))
;return T if it worked
(if (not (equal (strcase (car PSZ&))(strcase (car CPSZ&))))
(progn
(princ "[PltPszSet]Paper size was not set correctly.")
(princ "\n
{Nam Wid Hgt}")
(princ "\nRequested: ")(prin1 PSZ&)
(princ "\nCurrent: ")(prin1 CPSZ&)
nil
)
(progn
; (princ "OK")
T
;return T if successful
)
)
)
;(dsv_pltpszset (getvar "CTAB") "11x17")
;(dsv_pltpszset (getvar "CTAB") "8.5x11")
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_PLTPSZSET")
; }
;
; { <DSV_PLTMGNGET>==========================================================
; Get the current paper margins for the given layout.
|
; Given: LayoutName
|
; Return: list as follows:
|
; --------------------------------------------------------------------------(defun DSV_PLTMGNGET (NAM / LED LM BM RM TM)
(if (not (member NAM (layoutlist)))(setq NAM (getvar "CTAB")))
(setq LED (entget (dsv_lyoent NAM)))
(setq LM (/ (cdr (assoc 40 LED)) 25.4))
;left margin
(setq BM (/ (cdr (assoc 41 LED)) 25.4))
;bottom margin
(setq RM (/ (cdr (assoc 42 LED)) 25.4))
;right margin
(setq TM (/ (cdr (assoc 43 LED)) 25.4))
;top margin
(list LM BM RM TM)
)
;(setq PMGN-C& (dsv_pltmgnget (getvar "CTAB")))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_PLTMGNGET")
; }
;
; { <DSV_PLTMGNSET>==========================================================
; Change the current paper margins for the given layout.
|
; Given: LayoutName
|
; Return: ename or nil
|
; --------------------------------------------------------------------------(defun DSV_PLTMGNSET (NAM MGN& / LED LE MG NED CMGN&)
(if (not (member NAM (layoutlist)))(setq NAM (getvar "CTAB")))
(setq LED (entget (setq LE (dsv_lyoent NAM))) NED LED)
(setq MG (ds_frcint (* (ds_frcreal (car MGN&)) 25.4)))
;left margin

(if (or (<= MG 0)(> MG 75))(setq MG (car MGN-D&)))


;within range
(setq NED (subst (cons 40 MG)(assoc 40 LED) NED))
(setq MG (ds_frcint (* (ds_frcreal (cadr MGN&)) 25.4))) ;bottom margin
(if (or (<= MG 0)(> MG 75))(setq MG (cadr MGN-D&)))
;within range
(setq NED (subst (cons 41 MG)(assoc 41 LED) NED))
(setq MG (ds_frcint (* (ds_frcreal (caddr MGN&)) 25.4))) ;right margin
(if (or (<= MG 0)(> MG 75))(setq MG (caddr MGN-D&)))
;within range
(setq NED (subst (cons 42 MG)(assoc 42 LED) NED))
(setq MG (ds_frcint (* (ds_frcreal (cadddr MGN&)) 25.4))) ;top margin
(if (or (<= MG 0)(> MG 75))(setq MG (cadddr MGN-D&)))
;within range
(setq NED (subst (cons 43 MG)(assoc 43 LED) NED))
(dse_entmod NED)
(entupd LE)
(setq CMGN& (dsv_pltmgnget NAM))
(equal MGN& CMGN&)
)
;(dsv_pltmgnset (getvar "CTAB") (list 0.25 0.25 0.25 0.25))
; --------------------------------------------------------------------------(defun C:PLOTMGN (/ L LT BT RT TP M)
(setq L (dsv_pltmgnget (getvar "CTAB")))
(setq LT (ds_frcstr (car L)) BT (ds_frcstr (cadr L)))
(setq RT (ds_frcstr (caddr L)) TP (ds_frcstr (cadddr L)))
(princ (strcat "\nLt:" LT "Bt:" BT "Rt:" RT "Tp:" TP))
(setq M (getreal "New margin: "))
(dsv_pltmgnset (getvar "CTAB")(list M M M M))
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_PLTMGNSET")
; }
;
; { <DSV_PLTLOCGET>==========================================================
; Get the current paper location for the given layout.
|
; Given: LayoutName
|
; Return: list {PlotOrigin, ImageOrigin, Rotation}
|
; --------------------------------------------------------------------------(defun DSV_PLTLOCGET (NAM / LED OGNX OGNY IMGX IMGY SCNUM SCDEN ROT)
(if (not (member NAM (layoutlist)))(setq NAM (getvar "CTAB")))
(setq LED (entget (dsv_lyoent NAM)))
(setq EXTN (ds_frcpoint3 (ds_frcpoint2 (cdr (assoc 14 LED)))))
(setq EXTX (ds_frcpoint3 (ds_frcpoint2 (cdr (assoc 15 LED)))))
(setq OGNX (cdr (assoc 46 LED)))
(setq OGNY (cdr (assoc 47 LED)))
(setq IMGX (cdr (assoc 148 LED)))
(setq IMGY (cdr (assoc 149 LED)))
(setq SCNUM (cdr (assoc 142 LED)))
(setq SCDEN (cdr (assoc 143 LED)))
(setq ROT (cdr (assoc 73 LED)))
;rotation in number of quadrants
(list (list OGNX OGNY)(list IMGX IMGY)(list SCNUM SCDEN) ROT (list EXTN EXTX))
)
;(setq PLOC-C& (dsv_pltlocget (getvar "CTAB")))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_PLTLOCGET")
; }
;
; { <DSV_PLTLOCSET>==========================================================
; Change the current paper location for the given layout.
|
; Given: LayoutName, {PlotOrigin, ImageOrigin, Scale, Rotation, Extents}
|
; Return: T or nil to indicate success
|
; --------------------------------------------------------------------------(defun DSV_PLTLOCSET (NAM LOC& / LED LE NED EXTN LOC-D& OGN IGN SC ROT L1 L2
L3 L4 CLOC& C1 C2 C3 C4)

(if (not (member NAM (layoutlist)))(setq NAM (getvar "CTAB")))


(setq LED (entget (setq LE (dsv_lyoent NAM))) NED LED)
;(setq LOC-D& (dsv_pltlocdef))
(if (not (ds_islist? LOC&))(setq LOC& LOC-D&))
(setq OGN (car LOC&))
;plot origin
;(if (not (ds_vfypoint2 OGN))(setq OGN (car LOC-D&)))
;valid point
(setq NED (subst (cons 46 (car OGN))(assoc 46 LED) NED))
(setq NED (subst (cons 47 (cadr OGN))(assoc 47 LED) NED))
(setq IGN (cadr LOC&))
;image origin
;(if (not (ds_vfypoint2 IGN))(setq IGN (cadr LOC-D&)))
;valid point
(setq NED (subst (cons 148 (car IGN))(assoc 148 LED) NED))
(setq NED (subst (cons 149 (cadr IGN))(assoc 149 LED) NED))
(setq SC (caddr LOC&))
;scale
(setq NED (subst (cons 142 (car SC))(assoc 142 LED) NED))
(setq NED (subst (cons 143 (cadr SC))(assoc 143 LED) NED))
;plot window
;(setq NED (subst (cons 48 (car SC))(assoc 48 LED) NED))
;(setq NED (subst (cons 49 (cadr SC))(assoc 49 LED) NED))
;(setq NED (subst (cons 140 (car SC))(assoc 140 LED) NED))
;(setq NED (subst (cons 141 (cadr SC))(assoc 141 LED) NED))
(setq ROT (cadddr LOC&))
;rotation
(setq NED (subst (cons 73 ROT)(assoc 73 LED) NED))
(dse_entmod NED)
(entupd LE)
(setq L1 (car LOC&) L2 (cadr LOC&) L3 (caddr LOC&) L4 (cadddr LOC&))
(setq CLOC& (dsv_pltlocget NAM))
(setq C1 (car CLOC&) C2 (cadr CLOC&) C3 (caddr CLOC&) C4 (cadddr CLOC&))
(if (not (and (equal L1 C1)(equal L2 C2)(equal L3 C3)(equal L4 C4)))
(progn
(princ "\n[PltLocSet]Location was not set correctly.")
(princ "\n
{{Origin}{Image}{Scale} Rot {Extents}}")
(princ "\nRequested: ")(prin1 LOC&)
(princ "\nCurrent: ")(prin1 CLOC&)
nil
)
T
;return T if successful
)
)
;(dsv_pltlocset (getvar "CTAB") (list '(-0.3542 -0.3542) '(0.0 0.0) 1))
;(dsv_pltlocset (getvar "CTAB") (list '(-0.3542 -0.3542) '(17.0 0.0) 1))
;(dsv_pltlocset (getvar "CTAB") (list '(-0.3542 -0.3542) '(0.0 0.0) 1))
;(dsv_pltlocset (getvar "CTAB") (list '(-0.3542 -0.3542) '(0.0 0.0) 1))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_PLTLOCSET")
; }
;
; { <DSV_PLTIMGGET>==========================================================
; Get the current paper image origin for the given layout.
|
; Given: LayoutName
|
; Return: list ImageOrigin
|
; --------------------------------------------------------------------------(defun DSV_PLTIMGGET (NAM / LED IMGX IMGY)
(if (not (member NAM (layoutlist)))(setq NAM (getvar "CTAB")))
(setq LED (entget (dsv_lyoent NAM)))
(setq IMGX (cdr (assoc 148 LED)))
(setq IMGY (cdr (assoc 149 LED)))
(list IMGX IMGY)
)
;(setq PLOC-C& (dsv_pltimgget (getvar "CTAB")))

; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_PLTIMGGET")


; }
;
; { <DSV_PLTOGNGET>==========================================================
; Get the current paper location for the given layout.
|
; Given: LayoutName
|
; Return: list PlotOrigin
|
; --------------------------------------------------------------------------(defun DSV_PLTOGNGET (NAM / LED OGNX OGNY)
(if (not (member NAM (layoutlist)))(setq NAM (getvar "CTAB")))
(setq LED (entget (dsv_lyoent NAM)))
(setq OGNX (cdr (assoc 46 LED)))
(setq OGNY (cdr (assoc 47 LED)))
(list OGNX OGNY)
)
;(setq PLOC-C& (dsv_pltognget (getvar "CTAB")))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_PLTOGNGET")
; }
;
; { <DSV_PLTOGNSET>==========================================================
; Change the current paper location for the given layout.
|
; Given: LayoutName, {PlotOrigin, ImageOrigin, Scale, Rotation, Extents}
|
; Return: T or nil to indicate success
|
; --------------------------------------------------------------------------(defun DSV_PLTOGNSET (NAM LOC& / LED LE NED EXTN LOC-D& OGN IGN L1 L2 L3
CLOC& C1 C2 C3)
(if (not (member NAM (layoutlist)))(setq NAM (getvar "CTAB")))
(setq LED (entget (setq LE (dsv_lyoent NAM))) NED LED)
(setq OGN (car LOC&))
;plot origin
(setq NED (subst (cons 46 (car OGN))(assoc 46 LED) NED))
(setq NED (subst (cons 47 (cadr OGN))(assoc 47 LED) NED))
(setq IGN (cadr LOC&))
;image origin
(setq NED (subst (cons 148 (car IGN))(assoc 148 LED) NED))
(setq NED (subst (cons 149 (cadr IGN))(assoc 149 LED) NED))
(dse_entmod NED)
(entupd LE)
(setq L1 (car LOC&) L2 (cadr LOC&) L3 (caddr LOC&))
(setq CLOC& (dsv_pltlocget NAM))
(setq C1 (car CLOC&) C2 (cadr CLOC&) C3 (caddr CLOC&))
(if (not (and (equal L1 C1)(equal L2 C2)(equal L3 C3)))
(progn
(princ "\n[PltLocSet]Location was not set correctly.")
(princ "\n
{{Origin}{Image}{Scale}}")
(princ "\nRequested: ")(prin1 LOC&)
(princ "\nCurrent: ")(prin1 CLOC&)
nil
)
T
;return T if successful
)
)
;(dsv_pltlocset (getvar "CTAB") (list '(-0.3542 -0.3542) '(0.0 0.0) 1))
;(dsv_pltlocset (getvar "CTAB") (list '(-0.3542 -0.3542) '(17.0 0.0) 1))
;(dsv_pltlocset (getvar "CTAB") (list '(-0.3542 -0.3542) '(0.0 0.0) 1))
;(dsv_pltlocset (getvar "CTAB") (list '(-0.3542 -0.3542) '(0.0 0.0) 1))
; --------------------------------------------------------------------------(defun C:PLOTORIG (/ LOC&)
(dsv_pltognset (getpoint "\nOrigin for plot: "))
(setq LOC& (dsv_pltognget (getvar "CTAB")))

(princ "\nPlot origin is set to ")(prin1 (car LOC&))


(princ "\nImage origin is set to ")(prin1 (cadr LOC&))
(princ)
)
;(c:plotorig)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_PLTOGNSET")
; }
;
; { <DSV_PLTROTGET>==========================================================
; Get the current paper rotation for the given layout.
|
; Given: nothing
|
; Return: T or nil to indicate success
|
; --------------------------------------------------------------------------(defun DSV_PLTROTGET (NAM)
(if (not (member NAM (layoutlist)))(setq NAM (getvar "CTAB")))
(cdr (assoc 73 (entget (dsv_lyoent NAM))))
)
;(dsv_pltrotget)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_PLTROTGET")
; }
;
; { <DSV_PLTROTSET>==========================================================
; Change the current paper rotation for the given layout.
|
; Given: LayoutName, {PlotOrigin, ImageOrigin, Scale, Rotation, Extents}
|
; Return: T or nil to indicate success
|
; --------------------------------------------------------------------------(defun DSV_PLTROTSET (NAM ROT! / LED LE NED)
(if (not (member NAM (layoutlist)))(setq NAM (getvar "CTAB")))
(setq CROT (dsv_pltrotget NAM))
(if ROT!
(if (= CROT 0)
(progn
(if DSV_PLTROTSET-RPT! (princ "\nChanging to rotated. "))
(setq LED (entget (setq LE (dsv_lyoent (getvar "CTAB")))))
(setq NED (subst (cons 73 1)(assoc 73 LED) LED))
(dse_entmod NED)
(entupd LE)
)
(if DSV_PLTROTSET-RPT! (princ "\nAlready was rotated. "))
)
(if (= CROT 1)
(progn
(if DSV_PLTROTSET-RPT! (princ "\nChanging to NOT rotated. "))
(setq LED (entget (setq LE (dsv_lyoent (getvar "CTAB")))))
(setq NED (subst (cons 73 0)(assoc 73 LED) LED))
(dse_entmod NED)
(entupd LE)
)
(if DSV_PLTROTSET-RPT! (princ "\nAlready was NOT rotated. "))
)
)
(= 1 (dsv_pltrotget))
;return new current setting
)
; --------------------------------------------------------------------------(defun C:PLOTROT ()
(setq DSV_PLTROTSET-RPT! T)
(dsv_pltrotset (ds_askyn (= (dsv_pltrotget) 1) "Rotate plots 90 degrees"))
(setq DSV_PLTROTSET-RPT! nil)
(if (= (dsv_pltrotget) 1)

(princ "\nPlot is set to be rotated 90 degrees.")


(princ "\nPlot is set to be NOT rotated 90 degrees.")
)
(princ)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_PLTROTSET")
; }
;
; { <DSV_PLTDIAGET>==========================================================
; Get the properties of the plot setting dialog for the given layout.
|
; Given: LayoutName
|
; Return: list {PlotOrigin, ImageOrigin, Rotation}
|
; --------------------------------------------------------------------------(defun DSV_PLTDIAGET (NAM / LE LED OLD NUM NUM& NED RET)
(if (not (member NAM (layoutlist)))(setq NAM (getvar "CTAB")))
(setq LED (entget (setq LE (dsv_lyoent NAM))))
(setq NUM& (ds_bitwise_all (cdr (assoc 70 LED))))
(setq RET (cons (list "PrevPlotInit" (or (member 16384 NUM&))) RET))
(setq RET (cons (list "InitializingDialog" (or (member 8192 NUM&))) RET))
(setq RET (cons (list "ZoomToPaperOnUpdate" (or (member 4096 NUM&))) RET))
(setq RET (cons (list "UpdatePaper" (or (member 2048 NUM&))) RET))
(setq RET (cons (list "ModelType" (or (member 1024 NUM&))) RET))
(setq RET (cons (list "DrawViewportsFirst" (or (member 512 NUM&))) RET))
;(setq RET (cons (list "Nothing" (or (member 256 NUM&))) RET))
(setq RET (cons (list "PrintLineweights" (or (member 128 NUM&))) RET))
(setq RET (cons (list "ScaleLineweights" (or (member 64 NUM&))) RET))
(setq RET (cons (list "PlotPlotStyles" (or (member 32 NUM&))) RET))
(setq RET (cons (list "UseStdScale" (or (member 16 NUM&))) RET))
(setq RET (cons (list "PlotHidden" (or (member 8 NUM&))) RET))
(setq RET (cons (list "CenterPlot" (or (member 4 NUM&))) RET))
(setq RET (cons (list "ShowPlotStyles" (or (member 2 NUM&))) RET))
(setq RET (cons (list "PlotVportBdr" (or (member 1 NUM&))) RET))
RET
)
;(setq PDIA-C& (dsv_pltdiaget (getvar "CTAB")))
;(progn (foreach PR PDIA-C& (terpri)(prin1 PR))(princ))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_PLTDIAGET")
; }
;
; { <DSV_PLTDIASET>==========================================================
; Set the properties of the plot settings dialog for the given layout.
|
; Given: LayoutName
|
; Return: list {PlotOrigin, ImageOrigin, Rotation}
|
; --------------------------------------------------------------------------(defun DSV_PLTDIASET (NAM / LE LED NUM OLD NUM& NED)
(if (not (member NAM (layoutlist)))(setq NAM (getvar "CTAB")))
(setq LED (entget (setq LE (dsv_lyoent NAM))))
(setq NUM (cdr (setq OLD (assoc 70 LED))))
(setq NUM& (ds_bitwise_all NUM))
(if (member 8192 NUM&)(setq NUM (- NUM 8192)))
(if (member 2048 NUM&)(setq NUM (- NUM 2048)))
(if (member 16 NUM&)(setq NUM (- NUM 16)))
(if (/= NUM (cdr OLD))
(progn
(setq NED (subst (cons 70 NUM) OLD LED))
(dse_entmod NED)
)
)
(setq LED (entget LE))

(setq NUM& (ds_bitwise_all (cdr (assoc 70 LED))))


(and (not (member 8192 NUM&))(not (member 2048 NUM&)))
)
;(dsv_pltdiaset (getvar "CTAB"))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_PLTDIASET")
; }
;}
;{{<_VIEWPORTS_>*************************************************************
;
*
; Subroutines used to control viewports
*
;
*
; }**************************************************************************
;
; { <DSV_<VPTTBL>>===========================================================
; Return the vla object for the viewport collection.
|
; --------------------------------------------------------------------------(defun DSV_<VPTTBL> (/ <activeDwg>)
(if (ds_verac 15)
(progn
(vl-load-com)
(vla-get-viewports (dsv_<DwgActv>))
)
)
)
;(setq <viewports> (dsv_<VptTbl>))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_<VPTTBL>")(loadrpt)
; }
;
; { <DSV_<VPTACTV>>==========================================================
; Return the vla object for the active viewport.
|
; --------------------------------------------------------------------------(defun DSV_<VPTACTV> ()
(if (ds_verac 15)
(progn
(vl-load-com)
(vla-get-activeviewport (dsv_<DwgActv>))
)
)
)
;(setq <activeVpt> (dsv_<VptActv>))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_<VPTACTV>")(loadrpt)
; }
;
; { <DSV_VPEDATA>============================================================
; Return the entity data for the given entity only if it is a viewport.
|
; --------------------------------------------------------------------------(defun DSV_VPEDATA (E / ED RET)
(if (and (ds_verac 12)
(setq E (ds_vfyent E))
(setq ED (entget E (list "*")))
(= (cdr (assoc 0 ED)) "VIEWPORT")
)
(setq RET ED)
)
)
;(setq VPEDATA& (dsv_vpedata (dsv_vpcur)))
; --------------------------------------------------------------------------(defun C:VPEDATA (/ EP RET)
(dsv_pspset)
(if (setq EP (entsel "\nPick a viewport"))
(setq RET (dsv_vpedata (car EP)))

)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VPEDATA")
; }
;
; { <DSV_VPMSENTS>===========================================================
; Get a list of model space viewport enames in the current layout.
|
; --------------------------------------------------------------------------(defun DSV_VPMSENTS (LYO / FLT SS N E RET)
(if (ds_verac 15)
(if (member LYO (layoutlist))
(setq FLT (list (cons 0 "VIEWPORT")(cons 410 LYO)))
(setq FLT (list (cons 0 "VIEWPORT")))
)
(if (ds_verac 12)
(setq FLT (list (cons 0 "VIEWPORT")(cons 67 1)))
(setq FLT (list (cons 0 "VIEWPORT")))
)
)
(if (setq SS (ssget "X" FLT))
(progn
(setq N 0)
(repeat (sslength SS)
(setq E (ssname SS N) N (1+ N))
(setq RET (cons E RET))
)
)
)
RET
)
;(setq VPMSENTS& (dsv_vpmsents "*"))
;(setq VPMSENTS& (dsv_vpmsents (getvar "CTAB")))
; --------------------------------------------------------------------------(defun DSV_VPMSQTY (/ VP&)
(if (setq VP& (dsv_vpmsents (getvar "CTAB")))(length VP&) 0)
)
;(setq VPMSQTY& (dsv_vpmsqty))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VPMSENTS")
; }
;
; { <DSV_VPLYO>==============================================================
; Get layout name of an existing viewport.
|
; Given: ename
|
; Return: layout name (string)
|
; --------------------------------------------------------------------------(defun DSV_VPLYO (E / ED)
(if (ds_verac 15)(if (setq ED (dsv_vpedata E))(cdr (assoc 410 ED)) "PS"))
)
;(setq VPLYO$ (dsv_vplyo (dsv_vpcur)))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VPLYO")
; }
;
; { <DSV_VPIDST>=============================================================
; Get numerid and status of an existing viewport.
|
; Given: ename
|
; Return: id and status (list)
|
; --------------------------------------------------------------------------(defun DSV_VPIDST (E / ED)
(if (setq ED (dsv_vpedata E))(list (cdr (assoc 69 ED))(cdr (assoc 68 ED))))

)
;(setq VPIDST& (dsv_vpidst (dsv_vpcur)))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VPIDST")
; }
;
; { <DSV_VPMSIDST>===========================================================
; Get numerid ids and status of all viewports on the current layout.
|
; Given: nothing
|
; Return: id, ename, and status of all viewports (assoc list)
|
; --------------------------------------------------------------------------(defun DSV_VPMSIDST (LYO / IDST E RET)
(foreach F_E (reverse (dsv_vpmsents LYO))
(setq IDST (dsv_vpidst F_E) ID (car IDST) IDST (cdr IDST))
(setq RET (cons (cons ID (cons F_E IDST)) RET))
)
RET
;(setq VPMSIDST& (dsv_vpmsidst "*"))
)
;(setq VPMSIDST& (dsv_vpmsidst (getvar "CTAB")))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VPMSIDST")
; }
;
; { <DSV_VPCUR>==============================================================
; Return the current model space vport entity name or nil if no vports.
|
; --------------------------------------------------------------------------(defun DSV_VPCUR (/ VPE& ID RET)
(if (setq VPE& (dsv_vpmsidst (getvar "CTAB")))
(if (= (setq ID (getvar "CVPORT")) 1)
;paper space is current
(progn
(setq STC (length VPE&))
(foreach F_VP VPE&
;(setq F_VP (cadr VPE&))
(setq ST (caddr F_VP))
(if (and (> ST 1)(<= ST STC))(setq STC ST RET (cadr F_VP)))
)
)
(setq RET (cadr (assoc ID VPE&)))
)
)
RET
)
;(dsv_vpcur)
; --------------------------------------------------------------------------(defun C:VPCUR ()(prin1 (dsv_vpcur))(princ))
;show current viewport entity
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VPCUR")
; }
;
; { <DSV_VPON>===============================================================
; Find all viewports on current layout and make sure they are on.
|
; --------------------------------------------------------------------------(defun DSV_VPON (/ VP& E&)
(if (setq VP& (dsv_vpmsidst (getvar "CTAB")))
(foreach F_VP VP&
(if (and (/= (car F_VP) 1)(= (caddr F_VP) 0))
(setq E& (cons (cadr F_VP) E&))
)
)
)
(if E& (ds_command "_.MVIEW" (cons "ON" (reverse (cons "" E&)))))
(princ)
)
;(dsv_vpon)
; ---------------------------------------------------------------------------

(setq DSEVMT@ "DSV_VPON")


; }
;
; { <DSV_VPSET>==============================================================
; Make the specified viewport entity the active one
|
; --------------------------------------------------------------------------(defun DSV_VPSET (E / I LYO RET)
(if (setq I (dsv_vpidst E))
(progn
(setq LYO (dsv_vplyo E))
;layout of spec viewport
(if (/= LYO (dsv_lyocur))(dsv_lyoset LYO)) ;change layout if required
(if (dsv_pspchk)(ds_command "_.MSPACE" nil))
;set model space
(setq I (dsv_vpidst E))
;recheck new status
(if (= (cadr I) 0)
(progn
(ds_command "_.-MVIEW" (list "ON" E ""))
;turn it on if possible
(setq I (dsv_vpidst E))
;recheck new status
)
)
(if (< (cadr I) 0)
(princ "\n[VpSet]Viewport is hidden")
;**** check zooming out to see the viewport *****
)
(if (and (> (car I) 1)(> (cadr I) 1))(setvar "CVPORT" (car I)))
(if (= (getvar "CVPORT")(car I))(setq RET T))
)
(setq RET nil)
)
RET
)
;(setq VPSET! (dsv_vpset (dsv_vpfind "PL01B")))
; --------------------------------------------------------------------------(defun C:VPSET (/ FLT E RET)
(dsv_pspset)
(setq FLT (list (cons 0 "VIEWPORT")))
(princ "Select viewport: ")
(if (setq E (ds_vfyent (ssget FLT)))
(setq RET (dsv_vpset E))
)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VPSET")
; }
;
; { <DSV_VPNAM>==============================================================
; Get name of an existing viewport.
|
; Given: ename
|
; Return: name (string)
|
; --------------------------------------------------------------------------(defun DSV_VPNAM (E / F$ ED LY& LYO ID IDR RET)
(setq F$ (func_in "DSV_VPNAM" "E"))
(if (setq ED (dsv_vpedata E))
(progn
(if (not (setq LYO (cdr (assoc 410 ED))))
(progn
(setq LY& (ds_strgdiv (cdr (assoc 8 ED)) "_"))
(if (> (length LY&) 1)
;if layer name has
a prefix
(setq LYO (car LY&))
;use it
(setq LYO "PSP")

)
)
)
(setq ID (cdr (assoc 69 ED)))
(setq IDR (if (= ID 1) "P:000" (strcat "M:" (dsk_fmtint (1- ID) 0 3))))
(setq RET (strcat LYO ":" IDR))
)
)
(func_ex F$ RET)
)
;(setq VPNAM$ (dsv_vpnam (dsv_vpcur)))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VPNAM")
; }
;
; { <DSV_VPMSNAMS>===========================================================
; Get names of all existing viewports in the current layout.
|
; Given: nothing
|
; Return: name and ename of all viewports (assoc list)
|
; --------------------------------------------------------------------------(defun DSV_VPMSNAMS (/ NAM E RET)
(foreach F_E (reverse (dsv_vpmsents (getvar "CTAB")))
(setq NAM (dsv_vpnam F_E))
(setq RET (cons (list NAM F_E) RET))
)
RET
)
;(setq VPMSNAMS& (dsv_vpmsnams))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VPMSNAMS")
; }
;
; { <DSV_VPFIND>=============================================================
; Return entity name list of viewport having the given layer name prefix. |
; --------------------------------------------------------------------------(defun DSV_VPFIND (NAM / RET)
(if (ds_isstr? NAM)(cadr (assoc NAM (dsv_vpmsnams))))
)
;(setq DSV_VPFIND& (dsv_vpfind "PL01A"))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VPFIND")
; }
;
; { <DSV_VPLOC>==============================================================
; Get diagonal corner points of an existing viewport.
|
; Given: ename
|
; Return: two points (list)
|
; --------------------------------------------------------------------------(defun DSV_VPLOC (E / F$ ED CP WD HT BL TR RET)
(setq F$ (func_in "DSV_VPLOC" "E"))
(if (setq ED (dsv_vpedata E))
(progn
(setq CP (cdr (assoc 10 ED)))
;paper space center point
(setq WD (/ (cdr (assoc 40 ED)) 2))
;half vport width
(setq HT (/ (cdr (assoc 41 ED)) 2))
;half vport height
(setq BL (ds_vfypoint2 (list (- (car CP) WD)(- (cadr CP) HT))))
(setq TR (ds_vfypoint2 (list (+ (car CP) WD)(+ (cadr CP) HT))))
(setq RET (list BL TR))
;diagonal corner poins
)
)
(func_ex F$ RET)
)
;(setq VPLOC& (dsv_vploc (dsv_vpcur)))
; ---------------------------------------------------------------------------

(setq DSEVMT@ "DSV_VPLOC")


; }
;
; { <DSV_VPMSLIST>===========================================================
; Find all viewports on current layout and return a vpinfo list for each. |
; --------------------------------------------------------------------------(defun DSV_VPMSLIST (LYO / RET)
(foreach F_L& (dsv_vpmsidst LYO)
(if (/= (car F_L&) 1)
(setq RET (cons (cdr (dsv_vpinfo (cadr F_L&))) RET))
)
)
RET
;(setq VPMSLIST& (dsv_vpmslist "*"))
)
;(setq VPMSLIST& (dsv_vpmslist (getvar "CTAB")))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VPMSLIST")
; }
;
; { <DSV_VPMSDWGLIST>========================================================
; Find all viewports on entire drawing and return a vpinfo list for each. |
; --------------------------------------------------------------------------(defun DSV_VPMSDWGLIST (/ SS N E ED ID ST VPI RET)
(if (setq SS (ssget "X" (list (cons 0 "VIEWPORT"))))
(progn
(setq N 0)
(repeat (sslength SS)
(setq E (ssname SS N) N (1+ N))
(setq VPI (dsv_vpinfo E))
(if (/= (car (cadddr VPI)) "P:001")
(setq RET (cons VPI RET))
)
)
(setq SS nil)(gc)
)
)
RET
)
;(setq VPMSDWGLIST& (dsv_vpmsdwglist))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VPMSDWGLIST")
; }
;
; { <DSV_VPINFO>=============================================================
; Get list of layout, entity name, name, id, status for a viewport entity. |
; Given: ename
|
; Return viewport info (list)
|
; --------------------------------------------------------------------------(defun DSV_VPINFO (E / ED LYO ID ST PF IDR STR)
(if (setq ED (dsv_vpedata E))
(progn
(setq LYO (dsv_lyonam E))
(setq ID (cdr (assoc 69 ED)))
(setq ST (cdr (assoc 68 ED)))
(setq PF (car (ds_strgdiv (cdr (assoc 8 ED)) "_")))
(setq IDR (if (= ID 1) "P:001" (strcat "M:" (dsk_fmtint ID 0 3))))
(cond
((= ST 0)(setq STR "OFF"))
((< ST 0)(setq STR "HID"))
(T (setq STR (dsk_fmtint ST 0 3)))

)
(list LYO E PF (list IDR STR))
)
)
)
;(setq VPINFO& (dsv_vpinfo (dsv_vpcur)))
; --------------------------------------------------------------------------;("Layout1" <Entity name: 4ba0c60> "PL01A" ("M05" "02")(5 2))
; --------------------------------------------------------------------------(defun C:VPINFO (/ FLT SS RET)
(dsv_pspset)
(setq FLT (list (cons 0 "VIEWPORT")))
(princ "Select viewport: ")
(if (setq SS (ssget FLT))
(setq RET (dsv_vpinfo (ds_vfyent SS)))
)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VPINFO")
; }
;
; { <DSV_VPLIST>=============================================================
; Find all viewports and return a vpinfo list by layout.
|
; --------------------------------------------------------------------------(defun DSV_VPLIST (/ SS N E VPI LYO LYO& ALL& RET)
(if (setq SS (ssget "X" (list (cons 0 "VIEWPORT"))))
(progn
(setq N 0)
(repeat (sslength SS)
(setq E (ssname SS N) N (1+ N))
(setq VPI (dsv_vpinfo E))
(setq LYO (car VPI) VPI (cdr VPI))
(if (setq LYO& (assoc LYO ALL&))
(setq ALL& (subst (append LYO& (list VPI)) LYO& ALL&))
(setq ALL& (cons (list LYO VPI) ALL&))
)
)
(foreach LYO& ALL&
(setq LYO (car LYO&) LYO& (cdr LYO&))
(setq LYO& (dsk_sortmtx LYO& 2))
(setq RET (cons (cons LYO LYO&) RET))
)
(setq SS nil)(gc)
)
)
(if RET (dsk_sortmtx RET 1))
)
;(setq VPLIST& (dsv_vplist))
; --------------------------------------------------------------------------;(
; ("Layout1"
; {
<ename>
ORDER TYPE {ID, STATUS}
; (<Entity name: 4007ff70> "01" "M05" (5 1))
; (<Entity name: 4007fed0> "02" "P01" (1 2))
; (<Entity name: 4007fee0> "03" "M02" (2 3))
; (<Entity name: 4007ff50> "HID" "M03" (3 -1))
; (<Entity name: 4007ff60> "OFF" "M04" (4 0))
; )
; ("Layout2"
; (<Entity name: 4007ff40> "02" "P01" (1 2))
; )

;)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VPLIST")
; }
;
; { <DSV_VPPSLIST>===========================================================
; Find all paper space viewports and return a vpinfo list by layout.
|
; --------------------------------------------------------------------------(defun DSV_VPPSLIST (/ FLT SS N E VPI RET)
(if (ds_verac 12)
(setq FLT (list (cons 0 "VIEWPORT")(cons 69 1)))
(setq FLT (list (cons 0 "VIEWPORT")))
)
(if (setq SS (ssget "X" FLT))
(progn
(setq N 0)
(repeat (sslength SS)
(setq E (ssname SS N) N (1+ N))
(setq VPI (dsv_vpinfo E))
(setq RET (cons VPI RET))
)
(setq SS nil)(gc)
)
)
(if RET (dsk_sortmtx RET 1))
)
;(setq VPPSLIST& (dsv_vppslist))
; --------------------------------------------------------------------------;(
; {Layout
<ename>
ORDER TYPE {ID, STATUS}
; ("Layout1" <Entity name: 4007fed0> "02" "PSP" (1 2))
; ("Layout2" <Entity name: 4007ff40> "02" "PSP" (1 2))
;)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VPPSLIST")
; }
;
; { <DSV_VPDEL>==============================================================
; Erase all model space viewports on current layout.
|
; --------------------------------------------------------------------------(defun DSV_VPDEL (/ VP& E&)
(dsv_pspset)
(if (setq VP& (dsv_vpmsidst (getvar "CTAB")))
(progn
(foreach F_VP VP&
;(setq F_VP (car VP&))
(if (/= (car F_VP) 1)(setq E& (cons (cadr F_VP) E&)))
)
(dse_entdel E&)
)
)
(princ)
)
;(dsv_vpdel)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VPDEL")
; }
;
; { <DSV_VPPROP>=============================================================
; Get properties of an existing viewport
|
; Given: ename
|
; Return: standard viewport properties list
|

; --------------------------------------------------------------------------(defun DSV_VPPROP (E / F$ ID ED LAY CP WD HT BL TR LYO TAG VWS SCL RET)


(setq F$ (func_in "DSV_VPPROP" "E"))
(if (setq ED (dsv_vpedata E))
(progn
(setq ID (cdr (assoc 69 ED)))
(setq LAY (cdr (assoc 8 ED)))
;layer name
(setq CP (cdr (assoc 10 ED)))
;paper space center point
(setq WD (/ (cdr (assoc 40 ED)) 2))
;half vport width
(setq HT (/ (cdr (assoc 41 ED)) 2))
;half vport height
(setq BL (ds_vfypoint2 (list (- (car CP) WD)(- (cadr CP) HT))))
(setq TR (ds_vfypoint2 (list (+ (car CP) WD)(+ (cadr CP) HT))))
(setq LYO (cdr (assoc 410 ED)))
;which layout
(if (null LYO)(setq LYO "PS"))
(setq TAG (car (ds_strgdiv LAY "_")))
;layer prefix
(setq VWS (dsv_viewinfo E))
;{{ViewHgt,'xScale'}{Ref, ViewPt}{ViewDir, Twist}}
(setq SCL nil)
(setq RET (list LYO ID TAG (list BL TR) LAY VWS SCL E));data list
;{LYO ID "BlLay" {VpLoc} "LyrPrp" {ViewInfo}{ReqScale} <Ename>}
;{"PS" 2 "1117Page01" {VpLoc} "Page01" {ViewInfo}{ReqScale} <Ename>}
)
)
(func_ex F$ RET)
)
;(setq VPE (car (entsel))) (dsv_vpprop VPE) (dsv_vpprop (dsv_vpcur))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VPPROP")
; }
;
; { <DSV_VPSIZE>=============================================================
; Calculate all size properties of the given viewport entity.
|
; Given: viewport entity (ename)
|
; Return: Assoc list of {Ht, Wd, CC, BL, BR, TR, TL} (list)
|
; Usage (setq DSV_VPSIZE& (dsv_vpsize VPE))
|
; --------------------------------------------------------------------------(defun DSV_VPSIZE (E / F$ ED CP WD HT BL BR TR TL RET)
(setq F$ (func_in "DSV_VPSIZE" "E"))
(if (setq ED (dsv_vpedata E))
(progn
(setq CP (cdr (assoc 10 ED)))
;paper space center point
(setq WD (/ (cdr (assoc 40 ED)) 2))
;half vport width
(setq HT (/ (cdr (assoc 41 ED)) 2))
;half vport height
(setq BL (ds_vfypoint2 (list (- (car CP) WD)(- (cadr CP) HT))))
(setq BR (ds_vfypoint2 (list (+ (car CP) WD)(- (cadr CP) HT))))
(setq TR (ds_vfypoint2 (list (+ (car CP) WD)(+ (cadr CP) HT))))
(setq TL (ds_vfypoint2 (list (- (car CP) WD)(+ (cadr CP) HT))))
(setq RET
(list
(list "WID" (* WD 2))(list "HGT" (* HT 2))(list "CP" CP)
(list "BL" BL)(list "BR" BR)(list "TR" TR)(list "TL" TL)
)
)
)
)
(func_ex F$ RET)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VPSIZE")
; }

;
; { <DSV_VPREQD>=============================================================
; Calculate the required viewport center and height from two given ms points|
; Given: 2 points in model space
|
; Return: Center point in WCS and height of display plane (list)
|
; --------------------------------------------------------------------------(defun DSV_VPREQD (P1 P2 / F$ MSP1 MSP2 WCS1 DCS1 WCS2 DCS2 X1 Y1 X2 Y2 X Y
HT WD CP WC UC)
(setq F$ (func_in "DSV_VPREQD" "P"))
(if (and (setq MSP1 (ds_vfypoint3 P1))(setq MSP2 (ds_vfypoint3 P2)))
(progn
(dsv_mspset)
(setq WCS1 (trans MSP1 1 0))
;UCS to WCS
(setq DCS1 (trans WCS1 0 2))
;WCS to model space display
(setq WCS2 (trans MSP2 1 0))
;UCS to WCS
(setq DCS2 (trans WCS2 0 2))
;WCS to model space display
(setq X1 (car DCS1) Y1 (cadr DCS1))
(setq X2 (car DCS2) Y2 (cadr DCS2))
(if (> Y2 Y1)(setq Y Y2 Y2 Y1 Y1 Y))
(if (> X2 X1)(setq X X2 X2 X1 X1 X))
(setq HT (- Y1 Y2))
(setq WD (- X1 X2))
(setq CP (list (+ X2 (* WD 0.5))(+ Y2 (* HT 0.5))))
(setq WC (trans CP 2 0))
;model space display to WCS
(if (/= (caddr WC) 0.0)(setq WC (dsv_ms0elev WC)))
;adjust to Z=0
(setq UC (trans WC 0 1))
;UCS to WCS
(if (/= (caddr UC) 0.0)(setq UC (dsv_ms0elev UC)))
;adjust to Z=0
)
)
(func_ex F$ (list UC HT))
)
; --------------------------------------------------------------------------(defun C:VPREQD (/ P1 P2 RET)
(dsv_mspset)
(if (setq P1 (getpoint))
(if (setq P2 (getpoint))
(setq RET (dsv_vpreqd P1 P2))
)
)
(princ "\n")(prin1 RET)
(prin1)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VPREQD")
; }
;
; { <DSV_VPDSPT>=============================================================
; Calculate the display point that appears to coincide with given point
|
; in model space.
|
; Given: point in model space
|
; Return: point in display plane
|
; --------------------------------------------------------------------------(defun DSV_VPDSPT (P / UP WP DP)
(setq F$ (func_in "DSV_VPDSPT" "P"))
(if (setq UP (ds_vfypoint3 P))
(progn
(dsv_mspset)
(setq WP (trans UP 1 0))
;UCS to WCS
(setq DP (trans WP 0 2))
;WCS to model space display

(setq DP (list (car DP)(cadr DP) 0.0))


)
)
(func_ex F$ DP)
)
; --------------------------------------------------------------------------(defun C:DSPT (/ P RET)
(dsv_mspset)
(if (setq P (getpoint))
(setq RET (dsv_vpdspt P))
)
(princ "\n")(prin1 RET)
(prin1)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VPDSPT")
; }
;
; { <DSV_PSPPNT>=============================================================
; Calculate the paper space point that appears to coincide with given point |
; in model space.
|
; Given: point in model space
|
; Return: point in paper space
|
; --------------------------------------------------------------------------(defun DSV_PSPPNT (P / F$ UP WP DP PP)
(setq F$ (func_in "DSV_PSPPNT" "P"))
(if (setq UP (ds_vfypoint3 P))
(progn
(dsv_mspset)
(setq WP (trans UP 1 0 nil))
;UCS to WCS
(setq DP (trans WP 0 2 nil))
;WCS to model space display
(setq PP (trans DP 2 3 nil));model space display to paper space display
(setq PP (list (car PP)(cadr PP) 0.0))
)
)
(func_ex F$ PP)
)
; --------------------------------------------------------------------------(defun C:PSPT (/ P RET)
(dsv_mspset)
(if (setq P (getpoint))
(setq RET (dsv_psppnt P))
)
(dsv_pspset)
(princ "\n")(prin1 RET)
(prin1)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_PSPPNT")
; }
;
; { <DSV_MSPPNT>=============================================================
; Calculate the model space point that appears to coincide with given point |
; in paper space.
|
; Given: point in paper space
|
; Return: point in model space
|
; --------------------------------------------------------------------------(defun DSV_MSPPNT (P / F$ PP DP WP UP)
(setq F$ (func_in "DSV_MSPPNT" "P"))
(if (setq PP (ds_vfypoint3 P))

(progn
(dsv_mspset)
(setq DP (trans PP
(setq WP (trans DP
(if (/= (caddr WP)
(setq UP (trans WP
(if (/= (caddr UP)
)

3 2))
;paper space display to model space display
2 0))
;model space display to WCS
0.0)(setq WP (dsv_msp0z WP)))
;adjust to Z=0
0 1))
;WCS to UCS
0.0)(setq UP (dsv_msp0z UP)))
;adjust to Z=0

)
(func_ex F$ UP)
)
; --------------------------------------------------------------------------(defun C:MSPT (/ P RET)
(dsv_pspset)
(if (setq P (getpoint))
(setq RET (dsv_msppnt P))
)
(dsv_mspset)
(princ "\n")(prin1 RET)
(prin1)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_MSPPNT")
; }
;
; { <DSV_VPCRNRS>============================================================
; Calculate the 4 paper space corner points of the given viewport entity. |
; Given: viewport entity
|
; Return: list of 4 points in paper space (clockwise starting at bottom lt) |
; --------------------------------------------------------------------------(defun DSV_VPCRNRS (E / ED CP WD HT X Y HW HH BL TL TR BR RET)
(if (and (setq ED (dsv_vpedata E))
(setq CP (cdr (assoc 10 ED)))
(setq WD (cdr (assoc 40 ED)))
(setq HT (cdr (assoc 41 ED)))
)
(progn
(setq X (car CP) Y (cadr CP) HW (* WD 0.5) HH (* HT 0.5))
(setq BL (list (- X HW)(- Y HH)))
(setq TL (list (- X HW)(+ Y HH)))
(setq TR (list (+ X HW)(+ Y HH)))
(setq BR (list (+ X HW)(- Y HH)))
(setq RET (list BL TL TR BR))
)
)
RET
)
;(setq PTS (dsv_vpcrnrs E))
; --------------------------------------------------------------------------(defun C:VPCRNRS (/ FLT SS RET)
(dsv_pspset)
(setq FLT (list (cons 0 "VIEWPORT")))
(princ "Select viewport: ")
(if (setq SS (ssget FLT))
(setq RET (dsv_vpcrnrs (ds_vfyent SS)))
)
)
;(c:vpcrnrs)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VPCRNRS")
; }
;

; { <DSV_VPMSPTS>============================================================
; Calculate the 4 model space points that appear to coincide with the
|
; corners of the given viewport entity.
|
; Given: viewport entity
|
; Return: list of 4 points in model space (clockwise starting at bottom lt) |
; --------------------------------------------------------------------------(defun DSV_VPMSPTS (E / ED CP WD HT VPE X Y HW HH BL TL TR BR RET)
(if (and (setq ED (dsv_vpedata E))
(setq CP (cdr (assoc 10 ED)))
(setq WD (cdr (assoc 40 ED)))
(setq HT (cdr (assoc 41 ED)))
(setq VPE (dsv_vpcur))
;("Layout1" <Ename> "01" "MSP" (5 1))
)
(progn
(dsv_vpset E)
(setq X (car CP) Y (cadr CP) HW (* WD 0.5) HH (* HT 0.5))
(setq BL (dsv_msppnt (list (- X HW)(- Y HH))))
(setq TL (dsv_msppnt (list (- X HW)(+ Y HH))))
(setq TR (dsv_msppnt (list (+ X HW)(+ Y HH))))
(setq BR (dsv_msppnt (list (+ X HW)(- Y HH))))
(dsv_vpset VPE)
(setq RET (list BL TL TR BR))
)
)
RET
)
; --------------------------------------------------------------------------(defun C:VPMSPTS (/ FLT SS RET)
(dsv_pspset)
(setq FLT (list (cons 0 "VIEWPORT")))
(princ "Select viewport: ")
(if (setq SS (ssget FLT))
(setq RET (dsv_vpmspts (ds_vfyent SS)))
)
)
;(c:vpmspts)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VPMSPTS")
; }
;
; { <DSV_MSP0Z>==============================================================
; Project a given WCS point to the WCS zero elevation point that appears
|
; the same in the viewport.
|
; Given: a model space point with a non-zero Z value
|
; Return: a model space point with a zero Z value
|
; --------------------------------------------------------------------------(defun DSV_MSP0Z (P / RF FC XX YY)
(setq
(setq
(setq
(setq
(list

RF
FC
XX
YY
(+

(getvar "VIEWDIR"))
(/ 1.0 (caddr RF)))
(* -1 FC (car RF)(caddr P)))
(* -1 FC (cadr RF)(caddr P)))
(car P) XX)(+ (cadr P) YY) 0.0)

)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_MSP0Z")
; }
;
; { <DSV_ISPTINVP>===========================================================
; Is the given model space point within the boundary of the given viewport |
; ---------------------------------------------------------------------------

(defun DSV_ISPTINVP (PT E / PTS RET)


(if (setq PTS (dsv_vpcrnrs E))
(if (ds_inprlgm (dsv_psppnt PT) PTS)(setq RET T))
)
RET
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_ISPTINVP")
; }
;
; { <DSV_VLYGETFRZ>==========================================================
; Get layers currently frozen in an existing viewport
|
; Given: viewport ename
|
; Return: list of frozen layer names
|
; --------------------------------------------------------------------------(defun DSV_VLYGETFRZ (E / F$ ED XD RET)
(setq F$ (func_in "DSV_VLYGETFRZ" "E"))
(if (setq ED (dsv_vpedata E))
(cond
((ds_verac 15)
(foreach D (reverse ED)
(if (= (car D) 341)
(if (setq XD (entget (cdr D)))
(setq RET (cons (cdr (assoc 2 XD)) RET))
;vp frozen layers
)
)
)
)
((ds_verac 13)
(if (setq XD (dse_xdataget E "ACAD"))
(setq RET (last (cadr XD)))
;vp frozen layers
)
)
)
)
(func_ex F$ RET)
;(setq VPE (car (car (dsv_vpmslist "*"))))
)
;(setq VPE (cadr (car (dsv_vppslist (getvar "CTAB")))))
; --------------------------------------------------------------------------(defun C:VPGFRZ (/ FLT VPE RET)
(dsv_pspset)
(setq FLT (list (cons 0 "VIEWPORT")))
(princ "Select viewport: ")
(if (setq VPE (ds_vfyent (ssget FLT)))
(setq RET (dsv_vlygetfrz VPE))
)
(princ RET)
(prin1)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VLYGETFRZ")
; }
;
; { <DSV_VLYGETTHW>==========================================================
; Get layers currently thawed in an existing viewport
|
; Given: viewport ename
|
; Return: list of thawed layer names
|
; --------------------------------------------------------------------------(defun DSV_VLYGETTHW (E / F$ ED XD RET)
(setq F$ (func_in "DSV_VLYGETTHW" "E"))
(if (and (setq E (ds_vfyent E))

(setq ED (entget E))


(= (cdr (assoc 0 ED)) "VIEWPORT")
)
(cond
((ds_verac 15)
(foreach D (reverse ED)
(if (= (car D) 331)
(if (setq XD (entget (cdr D)))
(setq RET (cons (cdr (assoc 2 XD)) RET))
)
)
)
(setq RET (dsv_lyrnot RET))
)
((ds_verac 13)
(if (setq XD (dse_xdataget E "ACAD"))
(setq RET (dsv_lyrnot (last (cadr XD))))
)
)
)

;vp thawed layers

)
(func_ex F$ RET)
)
; --------------------------------------------------------------------------(defun C:VPGTHW (/ FLT E RET)
(dsv_pspset)
(setq FLT (list (cons 0 "VIEWPORT")))
(princ "Select viewport: ")
(if (setq E (ds_vfyent (ssget FLT)))
(setq RET (dsv_vlygetthw E))
)
(princ RET)
(prin1)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VLYGETTHW")
; }
;
; { <DSV_VLYGETHID>==========================================================
; Get layers currently hidden in an existing viewport
|
; Given: ename
|
; Return: list of hidden layer names
|
; --------------------------------------------------------------------------(defun DSV_VLYGETHID (E / F$ RET)
(setq F$ (func_in "DSV_VLYGETHID" "E"))
(setq RET (dsv_vlygetfrz E))
(func_ex F$ RET)
)
; --------------------------------------------------------------------------(defun C:VPGHID (/ FLT E RET)
(dsv_pspset)
(setq FLT (list (cons 0 "VIEWPORT")))
(princ "Select viewport: ")
(if (setq E (ds_vfyent (ssget FLT)))
(setq RET (dsv_vlygethid E))
)
(princ RET)
(prin1)
)
; ---------------------------------------------------------------------------

(setq DSEVMT@ "DSV_VLYGETHID")


; }
;
; { <DSV_VLYGETVIS>==========================================================
; Get layers currently visible in an existing viewport
|
; Given: ename
|
; Return: list of valid layer names
|
; --------------------------------------------------------------------------(defun DSV_VLYGETVIS (E / F$ ED VIS& XD FLYRS& RET)
(setq F$ (func_in "DSV_VLYGETVIS" "E"))
(setq RET (dsv_vlygetthw E))
(func_ex F$ RET)
)
; --------------------------------------------------------------------------(defun C:VPGVIS (/ FLT E RET)
(dsv_pspset)
(setq FLT (list (cons 0 "VIEWPORT")))
(princ "Select viewport: ")
(if (setq E (ds_vfyent (ssget FLT)))
(setq RET (dsv_vlygetvis E))
)
(princ RET)
(prin1)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VLYGETVIS")
; }
;
; { <DSV_VLYADDFRZ>==========================================================
; Add a list of layers to the ones frozen in a viewport
|
; --------------------------------------------------------------------------(defun DSV_VLYADDFRZ (E LYRS& / F$ FRZ& FLYRS& OK!)
(setq F$ (func_in "DSV_VLYADDFRZ" (list "E" "LYRS&")))
(setq FRZ& (car (dsv_lyrdef LYRS&)))
;given layers are defined
(if FRZ& (dsv_vlysetvis E (list (list "F" FRZ&))))
(setq OK! T FLYRS& (dsv_vlygetfrz E))
;layers currently frozen in vp
(foreach F_LYR LYRS&
;layers to freeze if not already
(if (not (ds_membstr F_LYR FLYRS&))
;is this one already frozen
(setq OK! nil)
;was still not frozen
)
)
(func_ex F$ OK!)
)
; --------------------------------------------------------------------------(defun C:VPAFRZ (/ FLT REQ& E RET)
(dsv_pspset)
(setq FLT (list (cons 0 "VIEWPORT")))
(princ "Select viewport: ")
(setq REQ& (list "01" "L01" "SA01" "LSA01"))
(if (setq E (ds_vfyent (ssget FLT)))
(setq RET (dsv_vlyaddfrz E REQ&))
)
(if RET
(princ "\nViewport Layers changed.")
(progn
(princ "\nViewport Layers NOT correct.\n")
(princ "\nRequested: ")(prin1 REQ&)(princ "\nActual: ")
(prin1 (dsv_vlygetfrz E))
)
)

(prin1)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VLYADDFRZ")
; }
;
; { <DSV_VLYADDTHW>==========================================================
; Add a list of layers to the ones thawed in a viewport
|
; --------------------------------------------------------------------------(defun DSV_VLYADDTHW (E LYRS& / F$ THW& TLYRS& OK!)
(setq F$ (func_in "DSV_VLYADDTHW" (list "E" "LYRS&")))
(setq THW& (car (dsv_lyrsdef LYRS&)))
;given layers are defined
(if THW& (dsv_vlysetvis E (list (list "T" THW&))))
(setq OK! T TLYRS& (dsv_vlygetthw E))
;layers currently thawed in vp
(foreach F_LYR LYRS&
;layers to thaw if not already
(if (not (ds_membstr F_LYR TLYRS&))
;is this one already thawed
(setq OK! nil)
;was still not thawed
)
)
(func_ex F$ OK!)
)
; --------------------------------------------------------------------------(defun C:VPATHW (/ FLT REQ& E RET)
(dsv_pspset)
(setq FLT (list (cons 0 "VIEWPORT")))
(princ "Select viewport: ")
(setq REQ& (list "01" "L01" "SA01" "LSA01"))
(if (setq E (ds_vfyent (ssget FLT)))
(setq RET (dsv_vlyaddthw E REQ&))
)
(if RET
(princ "\nViewport Layers changed.")
(progn
(princ "\nViewport Layers NOT correct.\n")
(princ "\nRequested: ")(prin1 REQ&)(princ "\nActual: ")
(prin1 (dsv_vlygetfrz E))
)
)
(prin1)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VLYADDTHW")
; }
;
; { <DSV_VLYMAKFRZ>==========================================================
; Make a list of layers the only ones frozen in the given viewport entity |
; --------------------------------------------------------------------------(defun DSV_VLYMAKFRZ (E LYRS& / F$ FRZ& VPLYRS& THW& OK!)
(setq F$ (func_in "DSV_VLYMAKFRZ" (list "E" "LYRS&")))
(if (setq FRZ& (car (dsv_lyrsdef LYRS&)))
;given layers are defined
(setq VPLYRS& (cons (list "F" FRZ&) VPLYRS&))
)
(if (setq THW& (dsv_lyrnot FRZ&))
(setq VPLYRS& (cons (list "T" THW&) VPLYRS&))
)
(if VPLYRS& (setq OK! (dsv_vlysetvis E VPLYRS&)))
(func_ex F$ OK!)
)
; --------------------------------------------------------------------------(defun C:VPMFL (/ FLT REQ& E RET)

(dsv_pspset)
(setq FLT (list (cons 0 "VIEWPORT")))
(princ "Select viewport: ")
(setq REQ& (list "01" "L01" "SA01" "LSA01"))
(if (setq E (ds_vfyent (ssget FLT)))
(setq RET (dsv_vlymakfrz E REQ&))
)
(if RET
(princ "\nViewport Layers changed.")
(progn
(princ "\nViewport Layers NOT correct.\n")
(princ "\nRequested: ")(prin1 REQ&)(princ "\nActual: ")
(prin1 (dsv_vlygetfrz E))
)
)
(prin1)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VLYMAKFRZ")
; }
;
; { <DSV_VLYMAKTHW>==========================================================
; Make a list of layers the only ones visible in the given viewport
|
; --------------------------------------------------------------------------(defun DSV_VLYMAKTHW (E LYRS& / F$ FRZ& VPLYRS& THW& OK!)
(setq F$ (func_in "DSV_VLYMAKTHW" (list "E" "LYRS&")))
(if (setq THW& (car (dsv_lyrsdef LYRS&)))
;given layers are defined
(setq VPLYRS& (cons (list "T" THW&) VPLYRS&))
)
(if (setq FRZ& (dsv_lyrnot THW&))
(setq VPLYRS& (cons (list "F" FRZ&) VPLYRS&))
)
(if VPLYRS& (setq OK! (dsv_vlysetvis E VPLYRS&)))
(func_ex F$ OK!)
)
; --------------------------------------------------------------------------(defun C:VPMKTHW (/ FLT REQ& E RET)
(dsv_pspset)
(setq FLT (list (cons 0 "VIEWPORT")))
(princ "Select viewport: ")
(setq REQ& (list "0" "Layer1" "Layer3" "Layer5"))
(if (setq E (ds_vfyent (ssget FLT)))
(setq RET (dsv_vlymakthw E REQ&))
)
(if RET
(princ "\nViewport Layers changed.")
(progn
(princ "\nViewport Layers NOT correct.\n")
(princ "\nRequested: ")(prin1 REQ&)(princ "\nActual: ")
(prin1 (dsv_vlygetvis E))
)
)
(prin1)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VLYMAKTHW")
; }
;
; { <DSV_VLYSETVIS>==========================================================
; Utilize the VPLAYER command with a viewport but prevent screen messages |

; LYRS& is an assoc list of keywords and layers


|
; {{"T" {"0" "01" "L01"}}{"F" {"SA01" "LSA01"}}}
|
; ** at this time only handle freeze and thaw **
|
; --------------------------------------------------------------------------|
; Command line: vplayer
|
; Enter an option [?/Freeze/Thaw/Reset/Newfrz/Vpvisdflt]:
|
;
{Freeze} |
;
Freezes a layer or set of layers in one or more viewports.
|
; "F" - Enter layer name(s) to freeze:
|
; Enter an option [All/Select/Current] <Current>:
|
;
{Thaw} |
;
Thaws layers in specific viewports.
|
; "T" -- Enter layer name(s) to thaw:
|
; Enter an option [All/Select/Current] <Current>:
|
;
{Reset} |
;
Sets the visibility of layers in specified viewports to their
|
;
current default setting
|
; "R" -- Enter layer name(s) to reset:
|
; Enter an option [All/Select/Current] <Current>:
|
;
{Newfrz} (New Freeze) |
;
Creates new layers that are frozen in all viewports.
|
; Enter name(s) of new layers frozen in all viewports:
|
;
{Vpvisdflt} (Viewport Visibility Default)
|
;
Thaws or freezes specified layers in subsequently created viewports. |
; Enter layer name(s) to change viewport visibility:
|
; Enter a viewport visibility option [Frozen/Thawed] <current>:
|
; --------------------------------------------------------------------------(defun DSV_VLYSETVIS (E LYRS& / F$ ED GLB& GFRZ& GOFF& FLYRS& TLYRS& CMD& FZ&
DEF& FRZ& VPFZ& TH& THW& VPTH& GTH& GON& GLYS1& GLYS2& CE OK!)
(setq F$ (func_in "DSV_VLYSETVIS" (list "E" "LYRS&")))
(if (and (ds_verac 12)
(setq E (ds_vfyent E))
;valid entity name
(setq ED (entget E))
;not deleted
(= (cdr (assoc 0 ED)) "VIEWPORT")
;must be a viewport
(setq GLB& (cadr (dsv_lyrgetvis)))
;all layers by visibility
)
(progn
(setq GFRZ& (cadr GLB&))
;all globally frozen layers
(setq GOFF& (cadddr GLB&))
;all globally off layers
(setq FLYRS& (dsv_vlygetfrz E))
;layers currently frozen in vp
(setq TLYRS& (dsv_lyrnot FLYRS&))
;layers currently thawed in vp
(setq CMD& (list ""))
(if (and (setq FZ& (cadr (assoc "F" LYRS&)))
(setq DEF& (dsv_lyrdef FZ&))
;{{OK} {UNDEF}}
(setq FRZ& (car DEF&))
)
(progn
(foreach F_FRZ FRZ&
;layers to freeze if not already
(if (not (ds_membstr F_FRZ FLYRS&)) ;is this one already frozen
(setq VPFZ& (cons F_FRZ VPFZ&))
;still needs to be frozen
)
)
(if VPFZ&
(setq CMD& (cons "F" (cons (ds_strgjoin VPFZ& ",")(cons "" CMD&))))
)
)
)
(if (and (setq TH& (cadr (assoc "T" LYRS&)))
(setq DEF& (dsv_lyrdef TH&))
;{{OK} {UNDEF}}

(setq THW& (car DEF&))


)
(progn
(foreach F_THW THW&
;layers to thaw if not already
(if (not (ds_membstr F_THW TLYRS&)) ;is this one already thawed
(setq VPTH& (cons F_THW VPTH&))
;still needs to be thawed
)
)
(if VPTH&
(setq CMD& (cons "T" (cons (ds_strgjoin VPTH& ",")(cons "" CMD&))))
)
(setq GTH& nil GON& nil GLYS1& nil)
(foreach F_THW VPTH&
;layers to thaw in viewport
(progn
(if (ds_membstr F_THW GFRZ&)
;is this one globally frozen
(setq GTH& (cons F_THW GTH&))
;save name
)
(if (ds_membstr F_THW GOFF&)
;is this one globally off
(setq GON& (cons F_THW GON&))
;save name
)
)
)
(if GTH&
(setq GLYS1& (cons (list "T" VPTH&) GLYS1&) ;to temporarily thaw
GLYS2& (cons (list "F" VPTH&) GLYS2&) ;to temporarily thaw
)
)
(if GON&
(setq GLYS1& (cons (list "ON" VPTH&) GLYS1&) ;to temporarily on
GLYS2& (cons (list "OFF" VPTH&) GLYS2&) ;to turn off later
)
)
)
)
(if GLYS1& (dsv_lyrsetvis GLYS1&))
;make temporary changes
(if (setq CE (dsv_vpcur))
(progn
(if (/= E CE)(dsv_vpset E))
;current for vplayer cmd
(ds_ssv "CMDECHO" 0)
(if (/= (car CMD&) "")(ds_command "_.VPLAYER" CMD&))
(ds_rsv "CMDECHO")
(if (/= E CE)(dsv_vpset CE))
;reset vport that was current
(if GLYS2& (dsv_lyrsetvis GLYS2&))
;reset temporary changes
(setq FRZ& (dsv_vlygetfrz E))
;verify new frozen layers
)
)
(setq OK! T)
(if VPFZ&
(foreach F_LYR VPFZ&
(if (not (ds_membstr F_LYR FRZ&))(setq OK! nil))
)
)
(if VPTH&
(foreach F_LYR VPTH&
(if (ds_membstr F_LYR FRZ&)(setq OK! nil))
)
)
)
)
(func_ex F$ OK!)

)
; --------------------------------------------------------------------------(defun DSV_VLYSETVIS_TEST1 (/ LYRS1& LYRS2& E)
(setq LYRS1& (list "Layer1" "Layer3" "Layer5" "Layer7" "Layer9"))
(setq LYRS2& (list "Layer2" "Layer4" "Layer6" "Layer8" "Layer10"))
(if (setq E (dsv_vpcur))
(dsv_vlysetvis E (list (list "F" LYRS1&)(list "T" LYRS2&)))
)
)
;(dsv_vlysetvis_test1)
; --------------------------------------------------------------------------(defun DSV_VLYSETVIS_TEST2 (/ LYRS1& LYRS2& E)
(setq LYRS1& (list "Layer2" "Layer4" "Layer6" "Layer8" "Layer10"))
(setq LYRS2& (list "Layer1" "Layer3" "Layer5" "Layer7" "Layer9"))
(if (setq E (dsv_vpcur))
(dsv_vlysetvis E (list (list "F" LYRS2&)(list "T" LYRS1&)))
)
)
;(dsv_vlysetvis_test2)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VLYSETVIS")
; }
;
; { <DSV_VLYADDVIS>==========================================================
; Add a list of layers to the ones visible in a viewport
|
; --------------------------------------------------------------------------(defun DSV_VLYADDVIS (E LYRS& / F$ CLYRS& FLYRS& OK!)
(setq F$ (func_in "DSV_VLYADDVIS" (list "E" "LYRS&")))
(setq CLYRS& (dsv_vlygetvis E))
(foreach LYR LYRS&
(setq LYR (strcase LYR))
(if (not (member LYR CLYRS&))(setq CLYRS& (cons LYR CLYRS&)))
)
(setq FLYRS& (dsv_lyrnot CLYRS&))
(setq OK! (dsv_vlymakfrz E FLYRS&))
(func_ex F$ OK!)
)
; --------------------------------------------------------------------------(defun C:VPAVL (/ FLT REQ& E RET)
(dsv_pspset)
(setq FLT (list (cons 0 "VIEWPORT")))
(princ "Select viewport: ")
(setq REQ& (list "01" "L01" "SA01" "LSA01"))
(if (setq E (ds_vfyent (ssget FLT)))
(setq RET (dsv_vlyaddvis E REQ&))
)
(if RET
(princ "\nViewport Layers changed.")
(progn
(princ "\nViewport Layers NOT correct.\n")
(princ "\nRequested: ")(prin1 REQ&)(princ "\nActual: ")
(prin1 (dsv_vlygetvis E))
)
)
(prin1)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VLYADDVIS")
; }
;
; { <DSV_VLYWHRVIS>==========================================================
; Make a list of layouts and viewports where given layer(s) is/are visible. |

; --------------------------------------------------------------------------(defun DSV_VLYWHRVIS (LYR / LYRS PG PGLY E VIS VPLY RET)


(setq LYRS (ds_strgdiv LYR ","))
(foreach F_VP (reverse (dsv_vplist))
;all viewports in each layout
(setq PG (car F_VP))
;layout name
(setq PGLY nil)
(foreach F_V (cdr F_VP)
;each viewport
(setq E (car F_V))
(setq VIS (dsv_vlygetvis E))
;all layers visible
(setq VPLY nil)
(foreach F_LYR LYRS
(if (ds_membstr F_LYR VIS)(setq VPLY (cons F_LYR VPLY)))
)
(if VPLY (setq PGLY (cons (cons E VPLY) PGLY)))
)
(if PGLY (setq RET (cons (cons PG PGLY) RET)))
)
RET
;(dsv_vlywhrvis (dsv_lyrsdwg))
)
;(dsv_vlywhrvis "L01,01,0")(dsv_vlywhrvis "LZIP01,ZIP01,ZIP0")
; --------------------------------------------------------------------------;(
; ("Page01" (<Entity name: 402a4938> "L01"))
; ("Page03" (<Entity name: 402a5638> "LSA04" "LSA01"))
; ("Page04" (<Entity name: 402a5a78> "LSA03" "LSA02"))
;)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VLYWHRVIS")
; }
;
; { <DSV_VLYALLVIS>==========================================================
; Make a list of layouts and viewports where given layer(s) is/are visible. |
; If LY! is not null then return the vplayer instead of the vpname
|
; --------------------------------------------------------------------------(defun DSV_VLYALLVIS (LY! / LYRS VPNM E LY KY VIS DAT RET)
(setq LYRS (dsv_lyrsdwg))
(foreach F_VP (dsv_vpmslist (getvar "CTAB"))
;each viewport
;(setq F_VP (car (reverse (dsv_vpmslist (getvar "CTAB")))))
(setq VPNM (cadr F_VP))
;viewport name
(setq E (car F_VP))
(setq LY (cadr F_VP))
(setq KY (if LY! LY VPNM))
(setq VIS (dsv_vlygetthw E))
;all layers thawed
(foreach F_LYR LYRS
(if (ds_membstr F_LYR VIS)
(progn
(if (setq DAT (dsk_keyget (list F_LYR) RET))
(setq DAT (cons KY DAT))
(setq DAT (list KY))
)
(setq RET (dsk_keyupd DAT (list F_LYR) RET))
)
)
)
)
RET
)
;(setq LYRALL& (dsv_vlyallvis T))(setq LYRALL& (dsv_vlyallvis nil))
; --------------------------------------------------------------------------(defun DSV_VLYPGSVIS (LYR / LYRS LYRV LYD RET)
(setq LYRS (ds_strgdiv LYR ","))
(setq LYRV (dsv_vlyallvis T))

(foreach F_LY LYRS


(if (setq LYD (cdr (assoc F_LY LYRV)))
(progn
(if (= (car LYD) "0")(setq LYD (cdr LYD)))
(setq RET (cons (cons F_LY LYD) RET))
)
)
)
RET
)
;(dsv_vlypgsvis "01,ZIP01")
; --------------------------------------------------------------------------;(
; ("Page01" (<Entity name: 402a4938> "L01"))
; ("Page03" (<Entity name: 402a5638> "LSA04" "LSA01"))
; ("Page04" (<Entity name: 402a5a78> "LSA03" "LSA02"))
;)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VLYALLVIS")
; }
;}
;{{<_VIEWING_>***************************************************************
;
*
; Subroutines used to control viewing
*
;
*
; }**************************************************************************
;
; { <DSV_VIEWINFO>===========================================================
; Get view parameters of an existing viewport
|
; Given: ename
|
; Return: standard view parameters list
|
; {{ViewHgt,'xScale'}{Ref, ViewPt}{ViewDir, Twist}}
|
; --------------------------------------------------------------------------(defun DSV_VIEWINFO (E / F$ ID ED CP WD HT XD VWD VWT VWH VWC SCL RET)
(setq F$ (func_in "DSV_VIEWINFO" "E"))
(if (setq ID (cdr (assoc 69 (setq ED (entget E (list "*"))))))
(progn
(setq CP (cdr (assoc 10 ED)))
;paper space center point
(setq WD (cdr (assoc 40 ED)))
;vport pspace width
(setq HT (cdr (assoc 41 ED)))
;vport pspace height
(setq ID (cdr (assoc 69 ED)))
;vport id
(setq XD (cdr (cadr (dse_xdataget E "ACAD"))))
(setq VWD (cadr XD))
;view dir
(setq VWT (caddr XD))
;view twist ang
(setq VWH (cadddr XD))
;view height
(if (/= ID 1)
(setq VWC (ds_vfypoint (dsv_msppnt CP)))
;model space center point
(setq VWC nil)
)
(setq SCL (strcat "x" (ds_frcstr (/ VWH HT)))) ;Scale Factor as string
(setq RET (list (list VWH SCL)(list "CC" VWC)(list VWD VWT)));data list
;{{ViewHgt,'xScale'}{Ref, ViewPt}{ViewDir, Twist}}
;((42.0 "x4.0") ("CC" (21.5186 13.8439 0.0)) ((0.0 0.0 1.0) 0.0))
;((73.8929 "x7.209067")("CC" (2.96059 40.9283 0.0))((1.0 -1.0 1.0) 0.0))
)
)
(func_ex F$ RET)
)
;(setq E (dsv_vpcur))
(dsv_viewinfo (dsv_vpcur))
; --------------------------------------------------------------------------(defun C:VWINFO (/ FLT E RET)
(dsv_pspset)

(setq FLT (list (cons 0 "VIEWPORT")))


(princ "Select viewport: ")
(if (setq E (ds_vfyent (ssget FLT)))
(setq RET (dsv_viewinfo E))
)
(princ "\n{{ViewHgt 'xScale'} {Ref ViewPt} {{ViewDir} Twist}}\n")
(prin1 RET)
(prin1)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VIEWINFO")
; }
;
; { <DSV_VIEWGETSCALE>=======================================================
; Get view scale of an existing viewport
|
; Given: ename
|
; Return: scale factor (real) (1.0 if in paperspace)
|
; --------------------------------------------------------------------------(defun DSV_VIEWGETSCALE (E / F$ ID ED CP HT XD VWD VWT VWH VWC SCL RET)
(setq F$ (func_in "DSV_VIEWGETSCALE" "E"))
(if (and E (setq ID (cdr (assoc 69 (setq ED (entget E (list "*")))))))
(progn
(setq XD (cdr (cadr (dse_xdataget E "ACAD"))))
(setq RET (/ (cadddr XD)(cdr (assoc 41 ED))))
;Scale Factor as real
)
(setq RET 1.0)
)
(func_ex F$ RET)
)
;(dsv_viewgetscale (dsv_vpcur))
; --------------------------------------------------------------------------(defun DSV_CVPSCL ()(dsv_viewgetscale (dsv_vpcur)))
;(dsv_cvpscl)
; --------------------------------------------------------------------------(defun C:VWSCL (/ FLT E RET)
(dsv_pspset)
(setq FLT (list (cons 0 "VIEWPORT")))
(princ "Select viewport: ")
(if (setq E (ds_vfyent (ssget FLT)))
(setq RET (dsv_viewgetscale E))
)
(princ "Scale: ")(prin1 RET)
(prin1)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VIEWGETSCALE")
; }
;
; { <DSV_VIEWSETSCALE>=======================================================
; Set view scale of an existing viewport
|
; Given: ename, scale factor (real)
|
; Return: scale factor (real)
|
; --------------------------------------------------------------------------(defun DSV_VIEWSETSCALE (E SCL / F$ ID ED XD PSH HT CP MSH SCL)
(setq F$ (func_in "DSV_VIEWSETSCALE" (list "E" "SCL")))
(if (setq ID (cdr (assoc 69 (setq ED (entget E (list "*"))))))
(progn
(dsv_viewext E)
(setq XD (cdr (cdr (cdr (cdr (cadr (dse_xdataget E "ACAD")))))))
(setq PSH (cdr (assoc 41 ED)))
(setq HT (car XD))
;current Scale Factor as real
(setq CP (list (cadr XD)(caddr XD)))

(setq MSH (* PSH SCL))


;new required height
(if (> MSH HT)(ds_command "'ZOOM" (list "C" CP MSH)))
)
)
(func_ex F$ SCL)
)
;(setq E (dsv_vpcur))(dsv_viewsetscale E)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VIEWSETSCALE")
; }
;
; { <DSV_SCALE-CHK>==========================================================
; Set view scale of an existing viewport
|
; --------------------------------------------------------------------------(defun DSV_SCALE-CHK (SCL)(if (> (setq SCL (ds_frcreal SCL)) 0) SCL 1.0))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VIEWSETSCALE")
; }
;
; { <DSV_VIEWEXT>============================================================
; Zoom model space to extents with only the viewport layers.
|
; --------------------------------------------------------------------------(defun DSV_VIEWEXT (E / ED E NAM GLB& VTH& VFZ& VPLYS&)
(if (setq ED (dsv_vpedata E))
(progn
(dsv_vpset E)
(dsv_mspset)
(setq NAM (car (ds_strgdiv (cdr (assoc 8 ED)) "_")))
;layer prefix
(setq GLB& (cadr (dsv_lyrgetvis)))
;all layers by visibility
(setq VTH& (dsv_lyrsfind NAM))
;all layers for viewport
(setq VFZ& (dsv_lyrnot VTH&))
(setq VPLYS& (list (list "T" VTH&)(list "F" VFZ&)))
(if VPLYS& (dsv_lyrsetvis VPLYS&))
;make temp changes
(ds_command "_.ZOOM" (list "E"))
;center the drawing
(dsv_lyrsetvis GLB&)
;reset temporary changes
)
)
(princ)
)
; --------------------------------------------------------------------------(defun C:VIEWEXT (/ EP VP&)
(dsv_pspset)
(if (setq EP (entsel))(dsv_viewext (car EP)))
)
; --------------------------------------------------------------------------(defun C:CVIEWE (/ E)
(if (setq E (dsv_vpcur))(dsv_viewext E))
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VIEWEXT")
; }
;
; { <DSV_VIEWCMD>============================================================
; Commands for standard viewpoints.
|
;
|
; Uses GLOBAL variables: {DSV_VWPANGLE,DSV_VWPELEV}
|
;---------------------------------------------------------------------------(defun DSV_VIEWSET (AN EL)
(setq DSV_VWPANGLE AN DSV_VWPELEV EL)
(ds_command "_.VPOINT" (list "R" (itoa AN)(itoa EL)))
(ds_command "_.ZOOM" (list ".9x"))

)
; --------------------------------------------------------------------------(defun DSV_VIEWTP ()(dsv_viewset 0 90))
(defun C:VWTP ()(dsv_viewset 0 90))
(defun C:TOPVIEW ()(dsv_viewset 0 90))
; --------------------------------------------------------------------------(defun DSV_VIEWRS ()(dsv_viewset 0 0))
(defun C:VWRS ()(dsv_viewset 0 0))
(defun C:RTSIDEVIEW ()(dsv_viewset 0 0))
; --------------------------------------------------------------------------(defun DSV_VIEWBK ()(dsv_viewset 90 0))
(defun C:VWBK ()(dsv_viewset 90 0))
(defun C:BACKVIEW ()(dsv_viewset 90 0))
; --------------------------------------------------------------------------(defun DSV_VIEWLS ()(dsv_viewset 180 0))
(defun C:VWLS ()(dsv_viewset 180 0))
(defun C:LTSIDEVIEW ()(dsv_viewset 180 0))
; --------------------------------------------------------------------------(defun DSV_VIEWFT ()(dsv_viewset 270 0))
(defun C:VWFT ()(dsv_viewset 270 0))
(defun C:FRONTVIEW ()(dsv_viewset 270 0))
; --------------------------------------------------------------------------(defun DSV_VIEWEA ()(dsv_viewset 0 45))
(defun C:VWEA ()(dsv_viewset 0 45))
(defun C:VEA ()(dsv_viewset 0 30))
; --------------------------------------------------------------------------(defun DSV_VIEWNE ()(dsv_viewset 45 45))
(defun C:VWNE ()(dsv_viewset 45 45))
(defun C:VNE ()(dsv_viewset 55 30))
; --------------------------------------------------------------------------(defun DSV_VIEWNO ()(dsv_viewset 90 45))
(defun C:VWNO ()(dsv_viewset 90 45))
(defun C:VNO ()(dsv_viewset 90 30))
; --------------------------------------------------------------------------(defun DSV_VIEWNW ()(dsv_viewset 135 45))
(defun C:VWNW ()(dsv_viewset 135 45))
(defun C:VNE ()(dsv_viewset 125 30))
; --------------------------------------------------------------------------(defun DSV_VIEWWE ()(dsv_viewset 180 45))
(defun C:VWWE ()(dsv_viewset 180 45))
(defun C:VWE ()(dsv_viewset 180 30))
; --------------------------------------------------------------------------(defun DSV_VIEWSW ()(dsv_viewset 225 45))
(defun C:VWSW ()(dsv_viewset 225 45))
(defun C:VSW ()(dsv_viewset 235 30))
; --------------------------------------------------------------------------(defun DSV_VIEWSO ()(dsv_viewset 270 45))
(defun C:VWSO ()(dsv_viewset 270 45))
(defun C:VSO ()(dsv_viewset 270 30))
; --------------------------------------------------------------------------(defun DSV_VIEWSE ()(dsv_viewset 315 45))
(defun C:VWSE ()(dsv_viewset 315 45))
(defun C:VSE ()(dsv_viewset 305 30))
; --------------------------------------------------------------------------(defun DSV_ZOOMIN ()(ds_command "_.ZOOM" (list "1.1x")))
(defun C:ZOOMIN ()(dsv_zoomin))
(defun C:ZIN ()(dsv_zoomin))
; --------------------------------------------------------------------------(defun DSV_ZOOMOUT ()(ds_command "_.ZOOM" (list ".9x")))
(defun C:ZOOMOUT ()(dsv_zoomout))

(defun C:ZOUT ()(dsv_zoomout))


; --------------------------------------------------------------------------(defun DSV_VIEWUP ()(dsv_viewset DSV_VWPANGLE (+ DSV_VWPELEV 5)))
(defun C:VWUP ()(dsv_viewup))
(defun C:VUP ()(dsv_viewup))
; --------------------------------------------------------------------------(defun DSV_VIEWDN ()(dsv_viewset DSV_VWPANGLE (- DSV_VWPELEV 5)))
(defun C:VWDN ()(dsv_viewdn))
(defun C:VDN ()(dsv_viewdn))
; --------------------------------------------------------------------------(defun DSV_VIEWRT ()(dsv_viewset (+ DSV_VWPANGLE 5) DSV_VWPELEV))
(defun C:VWRT ()(dsv_viewrt))
(defun C:VRT ()(dsv_viewrt))
; --------------------------------------------------------------------------(defun DSV_VIEWLT ()(dsv_viewset (- DSV_VWPANGLE 5) DSV_VWPELEV))
(defun C:VWLT ()(dsv_viewlt))
(defun C:VLT ()(dsv_viewlt))
; --------------------------------------------------------------------------(defun DSV_VIEWASKEL ()(dsv_viewset DSV_VWPANGLE (ds_getint DSV_VWPELEV "Elevati
on")))
(defun C:VWELEV ()(dsv_viewaskel))
(defun C:VELEV ()(dsv_viewaskel))
; --------------------------------------------------------------------------(defun DSV_VIEWASKAN ()(dsv_viewset (ds_getint DSV_VWPANGLE "Angle of view") DSV
_VWPELEV))
(defun C:VWANGLE ()(dsv_viewaskan))
(defun C:VANGL ()(dsv_viewaskan))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VIEWCMD")
; }
;
; { <DSV_VIEWSTD>============================================================
; Convert standard view code to direction vector.
|
; Given:
|
; Direction vector [twist angle] (list or string)
|
; View angle, view elev [twist angle] (list or string)
|
; Standard viewpoints: N,NE,E,SE,S,SW,W,NW,TP,BT,LS,RS,FT,BK
|
; Return: view angle and view elevation (list)
|
; --------------------------------------------------------------------------(defun DSV_VIEWSTD (CODE / F$ RET)
(setq F$ (func_in "DSV_VIEWSTD" "CODE"))
(if (setq CODE (ds_isstrval?))
(cond
((ds_membstr CODE (list "TP" "TOP" "PLAN" "2D"))
(setq RET (list 0.0 0.0 1.0))
)
((ds_membstr CODE (list "BT" "BOT" "BOTTOM" "UNDER"))
(setq RET (list 0.0 0.0 -1.0))
)
((ds_membstr CODE (list "RS" "RTSD" "RTSIDE" "RIGHT" "RT" "R"))
(setq RET (list 1.0 0.0 0.0))
)
((ds_membstr CODE (list "BK" "BACK" "BCK" "B"))
(setq RET (list 0.0 1.0 0.0))
)
((ds_membstr CODE (list "LS" "LTSD" "LTSIDE" "LEFT" "LFT" "LT" "L"))
(setq RET (list -1.0 0.0 0.0))
)
((ds_membstr CODE (list "FT" "FRONT" "FRT" "FR" "F"))
(setq RET (list 0.0 -1.0 0.0))

)
((ds_membstr CODE (list "E" "EAST"))
(setq RET (list 0.707107 0.0 0.707107))
)
((ds_membstr CODE (list "NE" "NORTHEAST"))
(setq RET (list 0.5 0.5 0.707107))
)
((ds_membstr CODE (list "N" "NORTH"))
(setq RET (list 0.0 0.707107 0.707107))
)
((ds_membstr CODE (list "NW" "NORTHWEST"))
(setq RET (list -0.5 0.5 0.707107))
)
((ds_membstr CODE (list "WEST" "W"))
(setq RET (list -0.707107 0.0 0.707107))
)
((ds_membstr CODE (list "SW" "SOUTHWEST"))
(setq RET (list -0.5 -0.5 0.707107))
)
((ds_membstr CODE (list "S" "SOUTH"))
(setq RET (list 0.0 -0.707107 0.707107))
)
((ds_membstr CODE (list "SE" "SOUTHEAST"))
(setq RET (list 0.5 -0.5 0.707107 0.0))
)
(T (setq RET (list 0.0 0.0 1.0)))
)
)
(func_ex F$ RET)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VIEWSTD")
; }
;
; { <DSV_VIEWANEL>===========================================================
; Convert direction vector to orientation and elevation.
|
; Given:
|
; Direction vector with optional fourth value for twist (list)
|
; Return: list containing
|
; Orientation angle in degrees (real)
|
; Elevation angle in degrees (real)
|
; --------------------------------------------------------------------------(defun DSV_VIEWANEL (VCT / F$ EL L Y TW ANG RET)
(setq F$ (func_in "DSV_VIEWANEL" "VCT"))
(setq EL (ds_asin (caddr VCT)))
;angle of elevation
(setq L (ds_cos EL))
;length of XY
(setq Y (cadr VCT) TW (cadddr VCT))
(if (/= L 0)(setq Y (/ Y L)))
(setq ANG (ds_rtd (ds_asin Y)) EL (ds_rtd EL))
(setq RET (list ANG EL))
(func_ex F$ RET)
)
; --------------------------------------------------------------------------(defun C:VIEWTEST (/ A&E)
(princ "\n0 0 -> ")(prin1 (setq A&E (dsv_viewanel (dsv_viewvect 0 0))))
(princ "\n0 90 -> ")(prin1 (setq A&E (dsv_viewanel (dsv_viewvect 0 90))))
(princ "\n0 45 -> ")(prin1 (setq A&E (dsv_viewanel (dsv_viewvect 0 45))))
(princ "\n45 45 -> ")(prin1 (setq A&E (dsv_viewanel (dsv_viewvect 45 45))))
(princ "\n90 45 -> ")(prin1 (setq A&E (dsv_viewanel (dsv_viewvect 90 45))))
(princ "\n135 45 -> ")(prin1 (setq A&E (dsv_viewanel (dsv_viewvect 135 45))))

)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VIEWANEL")
; }
;
; { <DSV_VIEWVECT>===========================================================
; Convert orientation and elevation to a direction vector.
|
; Given:
|
; Orientation angle in degrees (real)
|
; Elevation angle in degrees (real)
|
; Return: direction vector (list)
|
; --------------------------------------------------------------------------(defun DSV_VIEWVECT (ANG EL / F$ Z L X Y RET)
(setq F$ (func_in "DSV_VIEWVECT" (list "ANG" "EL")))
(setq Z (ds_sin (ds_dtr EL)))
(setq L (ds_cos (ds_dtr EL)))
(setq X (* L (ds_cos (ds_dtr ANG))))
(setq Y (* L (ds_sin (ds_dtr ANG))))
(if (< (abs X) 0.000001)(setq X 0.0))
(if (< (abs Y) 0.000001)(setq Y 0.0))
(setq RET (list X Y Z))
(func_ex F$ RET)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VIEWVECT")
; }
;
; { <DSV_VIEWDIR>============================================================
; Convert given value to 3d directon vector if possible.
|
; Given:
|
; Direction vector [twist angle] (list or string)
|
; Standard viewpoints: N,NE,E,SE,S,SW,W,NW,TP,BT,LS,RS,FT,BK
|
; Return: view angle and view elevation (list)
|
; --------------------------------------------------------------------------(defun DSV_VIEWDIR (VPNT / F$ VLL RET)
(setq F$ (func_in "DSV_VIEWDIR" "VPNT"))
(if (ds_isstrval? VPNT)(setq VPNT (ds_strgdiv VPNT ","))) ;comma delimited
(if (ds_islist? VPNT)
(progn
(setq VLL (length VPNT))
(if (and (= VLL 2)(ds_islist? (car VPNT))
(member (length (car VPNT))(list 2 3))
(ds_isnum? (cadr VPNT))
)
(setq VPNT (car VPNT) VLL (length VPNT))
)
(cond
((= VLL 1)
(setq RET (dsv_viewstd VPNT))
;resolve std view code
)
((= VLL 2)
(setq VPNT (ds_vfypoint2 VPNT))
;change to list of reals
(setq RET (dsv_viewvect (car VPNT)(cadr VPNT)))
;ang, elev
)
((= VLL 3)(setq RET (ds_vfypoint3 VPNT)))
)
)
(progn (princ "\nCan not resolve view direction ")(prin1 VPNT))
)
(func_ex F$ RET)

)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VIEWDIR")
; }
;
; { <DSV_VIEWMAKE>===========================================================
; Adjust model space view in viewport as specified. If any values are nil |
; or invalid, the existing values will be used.
|
; Given: Viewport Ename, View CtrPt, View Direction, and Viewport Scale.
|
;
;{<Ename>{x,y,z}{1,1,-1,0}{67.456,"x48"}}
|
; ViewCtrPt is the model space point to align with center of vport.
|
; ViewDir can be a 3d direction vector {1,-1,1}
|
;
or ViewAng, ViewElev (list or string)
|
;
or std N,NE,E,SE,S,SW,W,NW,TP,BT,LS,RS,FT,BK (string)
|
; VpScale consists of a list of {SclTyp and SclFct}
|
;
SclTyp is one of "A","E","M"
|
;
SclFct is ether a scale factor (real) or the word "<Fit>"
|
;
or a single numeric string with a prefix of x "x48"
|
;
or a single real number {ViewHgt}
|
; Return: T or nil to indicate success or failure.
|
; Uses: Viewpoint command, Zoom command
|
; --------------------------------------------------------------------------(defun DSV_VIEWMAKE (VPE NVP& / F$)
(setq F$ (func_in "DSV_VIEWMAKE" (list "VPE" "NVP&")))
;{{ViewHgt,'xScale'}{Ref, ViewPt}{ViewDir, Twist}}
;((73.8929 "x7.209067")("CC" (2.96059 40.9283 0.0))((1.0 -1.0 1.0) 0.0))
(if (and (ds_islist? NVP&)
;valid data list
(setq VPE (ds_vfyent VPE))
;valid viewport entity
(dsv_vpset VPE)
;make viewport current
)
(progn
(dsv_viewpnt VPE (caddr NVP&))
;change to specified view direction
(dsv_viewsiz VPE (cadr NVP&)(car NVP&))
;adjust magnification
)
)
;write code to verify the changes
(func_ex F$ (prin1))
)
; --------------------------------------------------------------------------;(dsv_viewmake VPE '((nil "x10")(0.0 0)((0.5 -0.5 0.707107) 0)))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VIEWMAKE")
; }
;
; { <DSV_VIEWPNT>============================================================
; Changes the display direction
|
; --------------------------------------------------------------------------(defun DSV_VIEWPNT (VPE NVD / F$ EV& EVD EVT NVT)
(setq F$ (func_in "DSV_VIEWPNT" (list "VPE" "NVD")))
(if (and (ds_islist? NVD)
;{{1,1,-1} 0}
(setq VPE (ds_vfyent VPE))
;valid viewport entity
(dsv_vpset VPE)
;make viewport current
(setq EV& (dsv_viewinfo VPE))
;{{ViewHgt,'xScale'}{Ref, ViewPt}{ViewDir, Twist}}
;((73.8929 "x7.209067")("CC" (2.96059 40.9283 0.0))((1.0 -1.0 1.0) 0.0))
(setq EVD (caddr EV&))
;existing view direction, twist
)
(progn
(setq EVT (cadr EVD) EVD (car EVD))
;existing view twist

(setq NVT (ds_frcreal (cadr NVD)) NVD (car NVD))


;new view twist
(setq NVD (dsv_viewdir NVD))
;resolve alternate formats
(if (not (equal NVD EVD))
;view direction is different
(ds_command "_.VPOINT" (list NVD))
;change it in viewport
)
;figure out how to rotate the view if twist is specified in NVT
)
)
;write code to verify the changes
(func_ex F$ (prin1))
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VIEWPNT")
; }
;
; { <DSV_VIEWSIZ>============================================================
; Changes the display center and magnification
|
; Given a reference pt, and a list with view height, and scale factor
|
; ViewPt, {ViewHgt,'xScale'}
|
; SclFct is ether a scale factor (real) or the word "<Fit>"
|
; or a single numeric string with a prefix of x "x48"
|
; --------------------------------------------------------------------------(defun DSV_VIEWSIZ (VPE NRPT NSIZ / F$ EV& ERPT ECTR ESIZ NVH NVS NCTR NVC)
(setq F$ (func_in "DSV_VIEWSIZ" (list "VPE" "NRPT" "NSIZ")))
(if (and (setq VPE (ds_vfyent VPE))
;viewport entity
(ds_islist? NSIZ)
(dsv_vpset VPE)
;make viewport current
(setq EV& (dsv_viewinfo VPE))
;{{ViewHgt,'xScale'}{Ref, ViewPt}{ViewDir, Twist}}
;((73.8929 "x7.209067")("CC" (2.96059 40.9283 0.0))((1.0 -1.0 1.0) 0.0))
(setq ERPT (cadr EV&))
;exst refpt ("CC" (2.9606 40.9283 0.0))
(setq ECPT (cadr ERPT))
;existing ctrpt (2.9606 40.9283 0.0)
(setq ESIZ (caddr EV&)) ;existing view size (73.8929 "x7.209067")
)
(progn
(setq NVH (car NSIZ))
(setq NVS (cadr NSIZ))
(if (ds_isval? NVS)
;scale factor is present
(setq I (dsv_viewhgt VPE NVS)
;convert scale to height
NVH (car I) NVS (cadr I)
)
)
(if (= (car NCTR) "CC")
(progn
(setq NCTR (cadr NRPT))
(if (null (ds_ispoint? NCTR))(setq NCTR ECTR))
;no ctr use exist
(if NVH (ds_command "'ZOOM" (list "C" NCTR NVH)))
)
(progn
(setq ED (entget VPE (list "*")))
(setq WD (* NVS (cdr (assoc 40 ED))))
;vport mspace width
(setq HT (* NVS (cdr (assoc 41 ED))))
;vport mspace height
(setq PTS& (ds_keybound NRPT (list WD HT)))
;resolve tag pts
(ds_command "'ZOOM" (list "W" (car PTS&)(cadr PTS&)))
)
)
)
)
;write code to verify the changes

(func_ex F$ (prin1))
);(setq DSV_VPSIZE& (dsv_vpsize VPE))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VIEWSIZ")
; }
;
; { <DSV_VIEWCHGSIZ>=========================================================
; Changes the display center and magnification
|
; Given a center pt, and a view height
|
; ViewPt, {ViewHgt,'xScale'}
|
; SclFct is ether a scale factor (real) or the word "<Fit>"
|
; or a single numeric string with a prefix of x "x48"
|
; --------------------------------------------------------------------------(defun DSV_VIEWCHGSIZ (VPE NRPT NSIZ / F$ EV& ERPT ECPT ESIZ NVH NVS NCPT NVC
ED WD HT PTS&)
(setq F$ (func_in "DSV_VIEWCHGSIZ" (list "VPE" "NRPT" "NSIZ")))
(if (and (setq VPE (ds_vfyent VPE))
;viewport entity
(ds_islist? NSIZ)
(dsv_vpset VPE)
;make viewport current
(setq EV& (dsv_viewinfo VPE))
;{{ViewHgt,'xScale'}{Ref, ViewPt}{ViewDir, Twist}}
;((73.8929 "x7.209067")("CC" (2.96059 40.9283 0.0))((1.0 -1.0 1.0) 0.0))
(setq ERPT (cadr EV&))
;exst refpt ("CC" (2.9606 40.9283 0.0))
(setq ECPT (cadr ERPT))
;existing ctrpt (2.9606 40.9283 0.0)
(setq ESIZ (caddr EV&)) ;existing view size (73.8929 "x7.209067")
)
(progn
(setq NVH (car NSIZ))
(setq NVS (cadr NSIZ))
(if (ds_isval? NVS)
;scale factor is present
(setq I (dsv_viewhgt VPE NVS)
;convert scale to height
NVH (car I) NVS (cadr I)
)
)
(if (= (car NCPT) "CC")
(progn
(setq NCPT (cadr NRPT))
(if (null (ds_ispoint? NCPT))(setq NCPT ECPT))
;no ctr use exist
(if NVH (ds_command "'ZOOM" (list "C" NCPT NVH)))
)
(progn
(setq ED (entget VPE (list "*")))
(setq WD (* NVS (cdr (assoc 40 ED))))
;vport mspace width
(setq HT (* NVS (cdr (assoc 41 ED))))
;vport mspace height
(setq PTS& (ds_keypts NRPT (list WD HT))) ;resolve tag points BL0,0
(ds_command "'ZOOM" (list "W" (car PTS&)(cadr PTS&)))
)
)
)
)
;write code to verify the changes
(func_ex F$ (prin1))
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VIEWCHGSIZ")
; }
;
; { <DSV_VIEWHGT>============================================================
; Calculates the viewport height required to display the view at the given |

; scale.
|
;
SclFct is ether a scale factor (real) or the word "<Fit>"
|
;
or a single numeric string with a prefix of x like "x48".
|
; --------------------------------------------------------------------------(defun DSV_VIEWHGT (VPE VPSC / F$ VS ES NVH ESCL)
(setq F$ (func_in "DSV_VIEWHGT" (list "VPE" "VPSC")))
(setq VS VPSC)
(if (ds_isstrval? VPSC)
;if viewport scale is given as a string
(if (not (ds_eqstr (substr VPSC 1 2) "<F"))
;"<Fit>"
(progn
(if (member (ascii VPSC)(list 88 120))
;x or X
(setq VPSC (ds_frcreal (substr VPSC 2)))
;remove "x"
)
)
)
)
(if (and (dsv_vpset VPE)
;make viewport current
(setq ES (car (dsv_viewinfo VPE)))
;{ViewHgt,'xScale'}
(setq ESCL (ds_frcreal (substr (cadr ES) 2)))
;remove "x"
(setq VPSC (ds_frcreal VPSC))
;change to real
(/= VPSC 0)
;can not be 0
)
(setq NVH (/ (* (car ES) VPSC) ESCL))
;calc hgt from exist
(func_msg F$ "Can not resolve VP scale " (list "VPSC" "VS"))
)
(func_ex F$ (list NVH VPSC))
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_VIEWHGT")
; }
;
; { <DS_NORMAL>==============================================================
; Return extrusion directions for each of the standard views.
|
; --------------------------------------------------------------------------(defun DS_NORMAL-PLAN () "0,0,1")
; --------------------------------------------------------------------------(defun DS_NORMAL-TP () "0,0,1")
; --------------------------------------------------------------------------(defun DS_NORMAL-BT () "0,0,-1")
; --------------------------------------------------------------------------(defun DS_NORMAL-FT () "0,-1,0")
; --------------------------------------------------------------------------(defun DS_NORMAL-BK () "0,1,0")
; --------------------------------------------------------------------------(defun DS_NORMAL-LS () "-1,0,0")
; --------------------------------------------------------------------------(defun DS_NORMAL-RS () "1,0,0")
; --------------------------------------------------------------------------(defun DS_NORMAL-EA () "0.707107,0,0.707107")
; --------------------------------------------------------------------------(defun DS_NORMAL-NE () "0.5,0.5,0.707107")
; --------------------------------------------------------------------------(defun DS_NORMAL-NO () "0.707107,0,0.707107")
; --------------------------------------------------------------------------(defun DS_NORMAL-NW () "-0.5,0.5,0.707107")
; --------------------------------------------------------------------------(defun DS_NORMAL-WE () "-0.707107,0,0.707107")
; --------------------------------------------------------------------------(defun DS_NORMAL-SW () "-0.5,-0.5,0.707107")
; ---------------------------------------------------------------------------

(defun DS_NORMAL-SO () "0,-0.707107,0.707107")


; --------------------------------------------------------------------------(defun DS_NORMAL-SE () "0.5,-0.5,0.707107")
; --------------------------------------------------------------------------(defun DS_NORMAL2D () "0,0,1")
; --------------------------------------------------------------------------(setq DSEVMT@ "DS_NORMAL")
; }
;
; { <DS_UCS2OCS>=============================================================
; Convert points from WCS to OCS using the specified extrusion direction. |
; --------------------------------------------------------------------------(defun DS_UCS2OCS (PTS& EXV / <NM> <PT> <OPT> PT RET)
(setq <NM> (vlax-3D-point (ds_frcpoint3 EXV)))
(if (ds_ispoint? PTS&)
(progn
(setq <PT> (vlax-3D-point (ds_frcpoint3 F_PT)))
;RetVal = object.TranslateCoordinates (OriginalPoint, From, To, Disp[, OCS
Normal])
(setq <OPT> (vla-TranslateCoordinates (dsv_<Util>) <PT> acUCS acOCS :vlaxfalse <NM>))
(setq RET (vlax-safearray->list <OPT>))
)
(if (ds_ispoints? PTS&)
(foreach F_PT (reverse PTS&)
(setq <PT> (vlax-3D-point (ds_frcpoint3 F_PT)))
;RetVal = object.TranslateCoordinates (OriginalPoint, From, To, Disp[, O
CSNormal])
(setq <OPT> (vla-TranslateCoordinates (dsv_<Util>) <PT> acUCS acOCS :vla
x-false <NM>))
(setq PT (vlax-safearray->list (vlax-variant-value <OPT>)))
(setq RET (cons PT RET))
)
)
)
RET
)
; --------------------------------------------------------------------------;(setq PTS (list (list 10.0 0.0 0.0)(list 10.0 10.0 0.0)(list 20.0 10.0 0.0)(lis
t 20.0 0.0 0.0)))
;(setq OCS (ds_ucs2ocs PTS (ds_normal-tp)))
;(setq PTS (list (list 10.0 0.0 0.0)(list 20.0 0.0 0.0)(list 20.0 0.0 10.0)(list
10.0 0.0 10.0)))
;(setq OCS (ds_ucs2ocs PTS (ds_normal-ft)))
;(setq PTS (list (list 10.0 0.0 0.0)(list 10.0 10.0 0.0)(list 10.0 10.0 10.0)(li
st 10.0 0.0 10.0)))
;(setq OCS (ds_ucs2ocs PTS (ds_normal-rs)))
; --------------------------------------------------------------------------(setq DSEVMT@ "DS_UCS2OCS")
; }
;}
;{{<_GROUPS_>****************************************************************
;
*
; Subroutines used to control groups
*
;
*
; }**************************************************************************
;
; { <DSV_GRPNAMS>============================================================
; Returns the all the names of groups defined as an ACAD_GROUP
|

; --------------------------------------------------------------------------(defun DSV_GRPNAMS (/ DED NAM NAM&)


(setq DED (dictsearch (namedobjdict) "ACAD_GROUP"))
(foreach I DED
(if (= (car I) 3)(setq NAM (cdr I)))
(if (= (car I) 350)(setq NAM& (cons (list NAM (cdr I)) NAM&)))
)
NAM&
)
; --------------------------------------------------------------------------(defun C:DSGRPNAMS ()(dsv_grpnams))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_GRPNAMS")
; }
;
; { <DSV_GRPNEXT>============================================================
; Returns the data of the next (or first) group defined as an ACAD_GROUP
|
; RW=Rewind to beginning of table
|
; Global vars: {DSV_GRPNEXT_NUM}
|
; --------------------------------------------------------------------------(defun DSV_GRPNEXT (RW / NM I)
(if (setq NM (dsv_grpnams))
(progn
(if (or RW (null DSV_GRPNEXT_NUM)(>= DSV_GRPNEXT_NUM (length NM)))
(setq DSV_GRPNEXT_NUM 0)
)
(if (setq I (nth DSV_GRPNEXT_NUM NM))
(entget (cadr I)(list "*"))
)
)
)
)
; --------------------------------------------------------------------------(defun C:DSGRPNEXT ()(dsv_grpnext nil))
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_GRPNEXT")
; }
;
; { <DSV_GRPSEARCH>==========================================================
; Returns the data of the requested group if it is defined as an ACAD_GROUP |
; NAM=Group name
|
; --------------------------------------------------------------------------(defun DSV_GRPSEARCH (NAM / I)
(if (setq I (assoc (strcase (ds_frcstr NAM))(dsv_grpnams)))
(entget (cadr I)(list "*"))
)
)
; --------------------------------------------------------------------------(defun C:DSGRPSEARCH (/ NM)
(if (and (setq NM (getstring))(/= NM ""))(dsv_grpsearch "SOLID"))
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_GRPSEARCH")
; }
;
; { <DSV_GRPMAKE>============================================================
; Creates a new ACAD_GROUP named NAM# and puts the named entities into it |
; SS=Selection set, NAM=Group name, DSC=Description
|
; --------------------------------------------------------------------------(defun DSV_GRPMAKE (SS NAM DSC / E& N NM)

(if (setq E& (dse_sset SS))


(progn
(setq N 1)
(while (member (strcat NAM (ds_frcstr N))(dsv_grpnams))(setq N (1+ N)))
(setq NM (strcat NAM (ds_frcstr N)))
(ds_command "-GROUP" (list "C" NM DSC SS ""))
)
)
NM
)
; --------------------------------------------------------------------------(defun C:DSGRPMAKE (/ NAM SS)
(if (and (setq NAM (getstring "\nLABEL: "))(setq SS (ssget)))
(ds_grpmake SS NAM "Command")
)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_GRPMAKE")
; }
;}
;{{<_DICTIONARY_>************************************************************
;
*
; Query functions to obtain data contained in dictionaries
*
;
*
; }**************************************************************************
;
; { <DS_<VLADICTSCOLLECT>>===================================================
; Return the vla object for the dictionaries collection.
|
; --------------------------------------------------------------------------(defun DS_<VLADICTSCOLLECT> (/ <activeDwg>)
(if (ds_verac 15)
(progn
(vl-load-com)
(if (setq <activeDwg> (dsv_<DwgActv>))
(vlax-get-property <activeDwg> 'Dictionaries)
)
)
)
)
;(setq <dictsTable> (ds_<vladictscollect>))
; --------------------------------------------------------------------------(setq DSEVMT@ "DS_<VLADICTSCOLLECT>")(loadrpt)
; }
;
; { <DS_DICTNAMES>===========================================================
; Return the names and enames of all defined dictionaries.
|
; --------------------------------------------------------------------------(defun DS_DICTNAMES (/ DED NAM RET)
(if (setq DED (entget (namedobjdict)(list "*")))
(progn
(foreach I DED
(if (= (car I) 3)(setq NAM (cdr I)))
(if (and NAM (= (car I) 350))
(setq RET (cons (list NAM (cdr I)) RET) NAM nil)
)
)
(setq RET (reverse RET))
)
)
RET
)
;(setq DictNames (ds_dictnames))

; --------------------------------------------------------------------------(setq DSEVMT@ "DS_DICTNAMES")(loadrpt)


; }
;
; { <DS_DICTGET>=============================================================
; Return the ename of the specified dictionary. If not found, create.
|
; --------------------------------------------------------------------------(defun DS_DICTGET (NAM / RET)
(setq NAMES (ds_dictnames))
(if (not (setq RET (cadr (assoc NAM NAMES))))
(progn
(setq RET (entmakex (list '(0 . "DICTIONARY") '(100 . "AcDbDictionary"))))
(setq RET (dictadd (namedobjdict) NAM RET))
)
)
RET
)
;(setq DICT (ds_dictget "DSBOM"))
; --------------------------------------------------------------------------(setq DSEVMT@ "DS_DICTGET")(loadrpt)
; }
;
; { <DS_DICTPUT>=============================================================
; Add the data in L& with the tag TAG to the specified dictionary.
|
; --------------------------------------------------------------------------(defun DS_DICTPUT (TAG L& NAM / A& XREC DICTD OREC DE)
(setq A& (list (cons 0 "XRECORD")(cons 100 "AcDbXrecord")))
(setq TAG (strcase TAG))
(if (setq XREC (entmakex (append A& L&)))
(progn
(setq DICTD (ds_dictget NAM))
(if (setq OREC (assoc TAG (ds_dictidx NAM)))(dictremove DICTD TAG))
(setq DE (dictadd DICTD TAG XREC))
)
(princ "\nData was not saved")
)
(if (and DE (equal DE XREC))
TAG
)
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DS_DICTPUT")(loadrpt)
; }
;
; { <DS_DICTIDX>=============================================================
; get tag and ename list of all records in specified dictionary.
|
; Usage: (setq DSP_IDX (ds_dictidx "DSPAG"))
|
; Usage: (setq DSB_IDX (ds_dictidx "DSBOM"))
|
; --------------------------------------------------------------------------(defun DS_DICTIDX (NAM / ED E TR RET)
(setq ED (entget (setq E (ds_dictget NAM))))
(foreach I ED
(if (= (car I) 3)(setq TR (cdr I)))
(if (= (car I) 350)
(if TR (setq RET (cons (list TR (cdr I)) RET) TR nil))
)
)
(if RET (reverse RET))
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DS_DICTIDX")

; }
;
; { <DS_DICTKEYS>============================================================
; get key of all records in specified dictionary.
|
; Usage: (setq DSP_IDX (ds_dictkeys "DSPAG"))
|
; Usage: (setq DSB_IDX (ds_dictkeys "DSBOM"))
|
; --------------------------------------------------------------------------(defun DS_DICTKEYS (NAM / ED E TR RET)
(if (setq ED (entget (setq E (ds_dictget NAM))))
(foreach I ED
(if (= (car I) 3)(setq TR (cdr I)))
(if (= (car I) 350)(if TR (setq RET (cons TR RET) TR nil)))
)
)
(if RET (reverse RET))
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DS_DICTIDX")
; }
;
; { <DS_DICTDATA>============================================================
; get actual data from a specified xrecord entity in a dictionary.
|
; Usage: (setq DATA& (ds_dictdata ENAME))
|
; --------------------------------------------------------------------------(defun DS_DICTDATA (E / ED RET)
(if (ds_isent? E)
(progn
(setq ED (entget E))
(foreach F_PR (reverse ED)
(if (not (member (car F_PR)(list -1 0 5 100 102 330 280)))
(setq RET (cons F_PR RET))
)
)
)
)
RET
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DS_DICTIDX")
; }
;
; { <DSV_DICTCODES>==========================================================
; Guide through dictionary object data to see format codes
|
; --------------------------------------------------------------------------(defun C:DICTCODES (/ DE DED NAM DICT& DICT N N$ Q ED X)
(if (and (setq DE (namedobjdict))
(setq DED (entget DE (list "*")))
)
(progn
(foreach I DED
(if (= (car I) 3)(setq NAM (cdr I)))
(if (and NAM (= (car I) 350))
(setq DICT& (cons (list NAM (cdr I)) DICT&) NAM nil)
)
)
(setq DICT (reverse DICT&))
(setq N 1)
(foreach I DICT&
(setq N$ (itoa N))
(princ "\n")(princ N$)(princ "> ")

(princ (car I))


(setq N (1+ N))
)
(setq Q (getint "\nEnter the number of the dictionary to examine: "))
(princ "\nDICT&=")(prin1 DICT&)
(if (<= Q (length DICT&))
(progn
(setq DE (cadr (nth (1- Q) DICT&)))
(setq DED (entget DE (list "*")))
(setq DED (dictnext DE T))
(while (setq ED (dictnext DE nil))
(setq X nil)
)
)
)
)
)
(princ)
)
;(c:dictdata)
; --------------------------------------------------------------------------(defun MULTI-ED-ASSOC (ED CK NUMS& / Q I OK WK S L WK& RET)
(if (ds_islist? NUMS&)(setq Q (length NUMS&)))
(if (and Q (listp ED))
(progn
(foreach I ED
(if CK (if (= (car I) CK)(setq OK T))(setq OK T)) ;passed checkpoint
(if OK
(if (setq WK (member (car I) NUMS&))
;this one is on list
(progn
(setq S (- (1+ Q)(length WK))) ;sequence in NUM& of item found
(setq L (length WK&))
;how many so far
(while (< (1+ L) S)(setq WK& (cons nil WK&)))
(setq WK& (cons (cdr I) WK&))
(if (= S Q)(setq RET (cons (reverse WK&) RET) WK& nil))
)
)
)
)
(if WK&
(progn
(setq L (length WK&))
;how many so far
(while (< (1+ L) Q)(setq WK& (cons nil WK&)))
(setq WK& (cons (cdr I) WK&))
(if (= S Q)(setq RET (cons (reverse WK&) RET) WK& nil))
)
)
)
)
(if RET (reverse RET))
)
; --------------------------------------------------------------------------(defun DSV_GRPDATA (NAM / DE DED DICT& DLE DLED LYO& EE RET)
(if (and (setq DE (namedobjdict))
(setq DED (entget DE (list "*")))
)
(progn
(setq DICT& (multi-ed-assoc DED 100 (list 3 350)))
(setq DLE (cadr (assoc "ACAD_GROUP" DICT&)))
(setq DLED (entget DLE (list "*")))
(setq LYO& (multi-ed-assoc DLED 100 (list 3 350)))

(if (setq EE (cadr (assoc NAM LYO&)))


(setq RET (entget EE (list "*")))
(progn (princ "\n[GrpData]Group ")(prin1 NAM)(princ " is not defined\n")
)
)
)
)
RET
)
; --------------------------------------------------------------------------(setq DSEVMT@ "DSV_DICTDATA")
; }
;}
;
; --------------------------------------------------------------------------(setq DSEVMT@ "DSEVMT")
(prin1)