Lisp code for inserting the Block
inserting the block is very difficult i need to choose only coordinate not scale or orientation that as to default scale 1 and rotation 0
(defun c:Drawinginsert (/ dcl_id)
(defun c:Drawinginsert (/ dcl_id)
;; Load and display the dialog
(setq dcl_id (load_dialog "D:\\Boobathy\\My Doc\\Brisk Cad automation\\input_dialog.dcl"))
(if (not dcl_id)
(progn
(princ "\nError: Failed to load DCL file.")
(exit)
)
)
(if (not (new_dialog "input_dialog" dcl_id))
(progn
(princ "\nError: Failed to create new dialog.")
(exit)
)
)
;; Set up action for OK button
(action_tile "accept" "(adaptorinsert)(done_dialog 1)")
;; Set up action for Cancel button
(action_tile "cancel" "(done_dialog 0)")
;; Start the dialog and get user inputs
(start_dialog)
(unload_dialog dcl_id)
(princ)
)
(defun adaptorinsert (/ spindle shank oal path filename drawingpath)
;; Retrieve values from dialog
(setq spindle (get_tile "spindle"))
(setq shank (get_tile "shank"))
(setq oal (get_tile "oal"))
(princ (strcat "\nSpindle: " spindle))
(princ (strcat "\nShank: " shank))
(princ (strcat "\nOAL: " oal))
;; Construct file path and filename
(setq path "D:\\Boobathy\\adaptors\\")
(setq filename (strcat spindle "-" shank "-" oal))
(setq drawingpath (strcat path filename ".dwg"))
;; Debugging output
(princ (strcat "\nLooking for file: " drawingpath))
;; Check if the drawing file exists
(if (findfile drawingpath)
(progn
;; Insert the drawing
(command "_.insert" drawingpath pause "1" "0" "" )
)
(princ "\nError: Drawing file not found.")
;princ "(done_dialog 1)")
)
;; End the function
(princ)
)
0
Comments
-
Hello.
Although it is more verbose, it is safer to use the (vla-) approach.
Like this:
<pre>
(vl-load-com)
(defun ...
...
(setq app (vlax-get-acad-object)
doc (vla-get-activedocument app)
model (vla-get-modelspace doc)
)
(setq insPnt (getpoint "\nInsertion point: "))
(if insPnt (setq blkObj (vla-InsertBlock model insPnt drawingpath 1 1 1 0)))
...
)
</pre>
With the (command) approach, there should be another "1" inserted, for the Y scale:
<pre>
(command "_.insert" drawingpath pause "1" "1" "0" "" )
</pre>
(command) and (vla-) work differently.
0 -
A couple more suggestions.
(command "_.insert" drawingpath "S" 1 pause "0" )
Attreq will set whether to allow for attributes to be added also.
(command "_.insert" drawingpath "S" 1 pause "0" att1 att2 )
Also look at Attdia.
I normally use -insert with command.
1 -
thank you very much, i just trying to inset some Standard items using that specification and Item No. this will be used for all our collogues....0
-
For Standard items I use pop menu's, a lot of people use Tool palettes.
1 -
I always use:
(setvar "attreq" 0)
(command "-insert" drawingpath "S" 1 pause "0" )
(setvar "attreq" 1)
0