- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello Everyone,
I have code that retrieves blocks from the master drawing. I added wipeout to all my blocks in the master file and sent it back using draworder command. Now in the current drawing when I call any block wipeout is at the top and hiding all the entities behind it.
So I have been trying to figure this out with several approaches and need some help.
I would like to send all Wipeouts back when the block is getting retrieved from the master file.
Can anyone look into the code and guide what lines need to be added so that every time I place the block in the current drawing wipeout is back.
=========================Get Device.lsp=========================
(defun c:GetBlock (/ *error* dbx doc dwg userpath)
(vl-load-com)
;; Error handling function
(defun *error* (msg)
(if (and (= 'vla-object (type dbx)) (not (vlax-object-released-p dbx)))
(vlax-release-object dbx)
)
(if (and msg (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")))
(princ (strcat "\nError: " msg))
)
(princ)
)
;; Get the current user's profile path
(setq userpath (getenv "USERPROFILE"))
;; Construct the dynamic path to the source file
(setq dwg (strcat userpath "\\AppData\\Roaming\\Autodesk\\ApplicationPlugins\\Master.dwg"))
;; Debugging: Print constructed path
(princ (strcat "\nConstructed Path: " dwg))
;; Check if the file exists
(if (not (findfile dwg))
(progn
(princ (strcat "\nFile not found: " dwg))
(exit) ; Exit the function if file not found
)
)
;; Proceed if file exists
(cond
((not (setq dbx (LM:GetDocumentObject dwg)))
(princ "\nUnable to interface with the selected drawing.")
)
(t
(prompt "\nEnter block name to insert from source drawing: ")
(setq blockName (getstring "\nBlock Name: "))
(if (not (LM:InsertBlockFromSource dbx blockName))
(princ (strcat "\nBlock \"" blockName "\" not found in the source drawing."))
(princ (strcat "\nBlock \"" blockName "\" inserted successfully."))
)
)
)
(princ)
)
;; Get Document Object - Lee Mac
(defun LM:GetDocumentObject (dwg / app dbx dwl vrs)
(cond
((not (setq dwg (findfile dwg)))
(princ (strcat "\nFile not found in LM:GetDocumentObject: " dwg))
nil
)
((cdr
(assoc (strcase dwg)
(vlax-for doc (vla-get-documents (setq app (vlax-get-acad-object)))
(setq dwl (cons (cons (strcase (vla-get-fullname doc)) doc) dwl))
)
)
)
)
((progn
(setq dbx
(vl-catch-all-apply 'vla-getinterfaceobject
(list app
(if (< (setq vrs (atoi (getvar 'acadver))) 16)
"objectdbx.axdbdocument" (strcat "objectdbx.axdbdocument." (itoa vrs))
)
)
)
)
(or (null dbx) (vl-catch-all-error-p dbx))
)
(prompt "\nUnable to interface with ObjectDBX.")
)
((not (vl-catch-all-error-p (vl-catch-all-apply 'vla-open (list dbx dwg))))
dbx
)
)
)
;; Function to insert block from source drawing
(defun LM:InsertBlockFromSource (dbx blockName)
(if (not (LM:getitem (vla-get-blocks dbx) blockName))
nil
(progn
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(if (not (vl-catch-all-error-p
(vl-catch-all-apply 'vlax-invoke
(list dbx 'copyobjects
(list (LM:getitem (vla-get-blocks dbx) blockName))
(vla-get-blocks doc)
)
)
)
)
(progn
(if (LM:getitem (vla-get-blocks doc) blockName)
(LM:InsertBlockAtPoint doc blockName)
nil
)
)
nil
)
)
)
)
;; Function to insert block at a user-specified insertion point
(defun LM:InsertBlockAtPoint (doc blockName)
(while (setq insPt (getpoint "\nSpecify insertion point: "))
(vla-insertblock
(vlax-get-property doc (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace))
(vlax-3D-point insPt)
blockName
1.0 1.0 1.0
0
)
)
)
;; VLA-Collection: Get Item - Lee Mac
(defun LM:getitem (col idx / obj)
(if (not (vl-catch-all-error-p (setq obj (vl-catch-all-apply 'vla-item (list col idx)))))
obj
)
)
(princ)
Solved! Go to Solution.