Hi everyone,
I need help finishing this program. I can't figure out how to get this to scale the xref file by one over the dimscale when it inserts it into the drawing file.
Code:
(defun c:ZDTL ( / xrefLayer osnapMode originalOsnapMode xrefFile insertPoint scaleFactor xrefDoc xrefBlock)
;; Load COM libraries
(vl-load-com)
;; Set the desired settings
(setq xrefLayer "XREF")
(setq osnapMode 4)
;; Get the current osmode value
(setq originalOsnapMode (getvar "osmode"))
;; Turn on osnap mode
(setvar "osmode" osnapMode)
;; Prompt the user to select the file to Xref
(setq xrefFile (getfiled "Select Xref file" "" "dwg" 1))
;; If a valid file path is selected, proceed
(if xrefFile
(progn
;; Open the Xref file in the background to get DIMSCALE
(setq xrefDoc (vla-open (vla-get-documents (vlax-get-acad-object)) xrefFile :vlax-false))
;; Retrieve the DIMSCALE value from the Xref file
(setq scaleFactor (vla-getvariable xrefDoc "DIMSCALE"))
;; Close the document
(vla-close xrefDoc)
;; Prompt the user to select the insertion point
(setq insertPoint (getpoint "\nEnter insertion point for Xref: "))
;; Convert the insertion point to a 3D point for ActiveX
(setq insertPoint (vlax-3d-point insertPoint))
;; Insert the Xref as an overlay with ActiveX
(setq xrefBlock
(vla-attachexternalreference
(vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))
xrefFile ;; File path of the Xref
(vl-filename-base xrefFile) ;; Block name (using file name without extension)
insertPoint ;; Insertion point
scaleFactor ;; X scale factor
scaleFactor ;; Y scale factor
scaleFactor ;; Z scale factor
0 ;; Rotation angle
:vlax-false ;; Overlay (not bound)
))
;; Set the Xref layer
(vla-put-layer xrefBlock xrefLayer)
(princ "\nXref inserted and scaled successfully.")
)
(princ "\nInvalid Xref file selected.")
)
;; Reset osnap mode
(setvar "osmode" originalOsnapMode)
(princ)
)
Thanks,
Cadd4la