;;;------------------------------------------------------------------------------------------------
;;;------------------------------------------------------------------------------------------------
;;;------------------------------------------------------------------------------------------------
;;
;; Modifies the last dynamic block inserted into the drawing.
;; ____________________________________________________________________________
;;
;; Parameters:
;; lstProp - a list of parameters and values
;;
;; Examples:
;; (ModifyBlock (list "DynamicBlockParmatername" DynamicBlockValue))
;; (ModifyBlock (list "Angle" 1.5708 "Length" 0.2))
;;
;;;(ModifyBlock (list "HASH STYLE" "4 HOT"))
(defun ModifyBlock
(lstProp
/ ename selset index oBkRef sProp oProps i j
) (setPropValue oProps sProp
(nth (1+ j
) lstProp
)) )
)
)
;;
;; Sets the new property of a dynamic block.
;;
(defun setPropValue
(oProps sProp Val
/ i oSBReferenceProperty sPName iFound
) (setq sPName
(vla
-get
-PropertyName oSBReferenceProperty
)) (vla-put-value
oSBReferenceProperty
Val
)
)
)
)
)
)
;;;------------------------------------------------------------------------------------------------
(defun GetDynamicBlockParameters
(LastEntitiyName
/ ParameterCount oSBReferenceProperty
) ;;; (SETQ LastEntitiyName (CAR (ENTSEL)))
(vla-GetDynamicBlockProperties
0)
);setq
(setq ParameterName
(vla
-get
-propertyname oSBReferenceProperty
))
(while (/= ParameterName
(LM:GetVisibilityParameterName
(vlax
-ename
->vla-object LastEntitiyName
))) (vla-GetDynamicBlockProperties
cnt)
);setq
(setq ParameterName
(vla
-get
-propertyname oSBReferenceProperty
)) )
)
(setq ParameterValueList
nil) (vla-get-allowedvalues oSBReferenceProperty))
1))
(while (> ParameterCount
-1) (vla-get-allowedvalues oSBReferenceProperty))
ParameterCount))
);setq gets elements of a safearray
(setq ParameterValueList
(cons ParameterValue ParameterValueList
)) (setq ParameterCount
(1- ParameterCount
)) )
);defun
;;;------------------------------------------------------------------------------------------------
;;-----------=={ Get Visibility Parameter Name }==------------;;
;; ;;
;; Returns the name of the Visibility Parameter of a ;;
;; Dynamic Block (if present). ;;
;;------------------------------------------------------------;;
;; Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;;
;;------------------------------------------------------------;;
;; Arguments: ;;
;; block - VLA (Dynamic) Block Reference Object ;;
;;------------------------------------------------------------;;
;; Returns: Name of Visibility Parameter, else nil ;;
;;------------------------------------------------------------;;
(defun LM:GetVisibilityParameterName
( block
/ visib
) (vla-get-effectivename block)
)
)
(eq :vlax-true (vla
-get
-isdynamicblock block
)) )
)
)
)
"ACAD_ENHANCEDBLOCK"
)
)
)
)
)
)
;;;------------------------------------------------------------------------------------------------
;;;Only looks for blocks that start with a number
(defun _BLOCKLIST
( / lst
) );and
);if
);vlax-for
);defun
;;;------------------------------------------------------------------------------------------------
(defun c:IB
(/ ZoomCenter ZoomViewSize Block2Insert Block2InsertObject Block2InsertEntity
) (setq Block2Insert
(car (listbox
"Choose block to insert: " (append '
("<PICK BLOCK FROM SCREEN>") (_BLOCKLIST
)) nil))) ZoomViewSize
(getvar "viewsize")) ((= nil Block2Insert
) (exit)) ((= "<PICK BLOCK FROM SCREEN>" Block2Insert)
(setq Block2InsertEntity
(car (entsel "\nPick Block to insert: \n"))) (setq Block2Insert
(vla
-get
-effectivename
(setq Block2InsertObject
(vlax
-ename
->vla-object Block2InsertEntity
)))) (command "_Zoom" "C" ZoomCenter ZoomViewSize
) );if
);end test
(command "insert" Block2Insert
"\\" 1 "\\") (command "insert" Block2Insert
"\\" 1 1 "\\") );if
);T
);cond
);defun
;;;------------------------------------------------------------------------------------------------
(if (not Command_Ending_Reactor
) (setq Command_Ending_Reactor
(vlr-command-reactor nil '
((:vlr-commandended . Command_Ended_Command
))) ;_ end of vlr-command-reactor ) ;_ end of setq
() ;_ the reactor is already loaded
) ;_ end of if you use this first portion of code to make sure the reactor is loaded, the reactor should only be loaded once otherwise you could see some unpleasant consequences
(defun Command_Ended_Command
(In_ReactorName In_Command
/ ModList
); then you need to define the callback function (the simpler the name the better) (alert (car In_Command
)) ;; <-- Remove this line, it shows all incomming command (cond; my current version checks for several different input commands to decide which programs to run, it may not be the most efficient, but it works for now (I am open to suggestions to improve my code structure) I have eliminated additional sections for simplicity sake. (= (car In_Command
) "INSERT") (= (car In_Command
) "-INSERT") (= (car In_Command
) "PASTECLIP") (= (car In_Command
) "DROPGEOM") (= (car In_Command
) "ACDCINSERTBLOCK") (= (car In_Command
) "EXECUTETOOL") (= (car In_Command
) "COPY") (= (car In_Command
) "-COPY") ) ;_ end of or finally the commands that are executed when a tool is selected from the tool palette, or even when it is inserted from the original block.
ParameterSetinitget nil
ParameterSetmessage nil)
(GetDynamicBlockParameters
(entlast)) (setq MyKeyWords ParameterValueList
) (while (> ParameterCount
-1) (setq ParameterSetTemp
(nth ParameterCount ModList
)) (if (not ParameterSetinitget
) (setq ParameterSetinitget ParameterSetTemp
) (setq ParameterSetinitget
(strcat ParameterSetTemp
" " ParameterSetinitget
))) (if (not ParameterSetmessage
) (setq ParameterSetmessage ParameterSetTemp
) (setq ParameterSetmessage
(strcat ParameterSetTemp
"/" ParameterSetmessage
))) (setq ParameterCount
(1- ParameterCount
)) );while
;;;!!!!HERE'S WHERE IT ALL COLLAPSES!!!!
(t ": ")))))
(ModifyBlock
(list ParameterName ParameterType
)) );progn
);if
) ;_ end cond4
) ;_ end of cond
) ;_ end of defun