Current settings: Object conversion=Delete

Current settings: Object conversion=Delete

zakkie
Contributor Contributor
482 Views
4 Replies
Message 1 of 5

Current settings: Object conversion=Delete

zakkie
Contributor
Contributor

Good day, 
Can't wrap my head around this one.

Clean drawing works first time, no error

Save the drawing and reopen, only on first insert it gives an error
NB: Then after first use the error goes away.
Close and reopen drawing produces the same cycle.

 

Command: TESTWIN

Pick insertion point:

Enter Window size <500.0>: 750

Window size set to: 750.0000

Inserted the block and it set dynamic properties correctly

But displays the following:

Command:

Current settings: Object conversion=Delete

Enter name of output file:

Enter name of existing block or

[= (block=output file)/* (whole drawing)] <define new drawing>:

Any assistance will be appreciated
Thanks Zakkie
Using Autocad 2026

0 Likes
Accepted solutions (1)
483 Views
4 Replies
Replies (4)
Message 2 of 5

komondormrex
Mentor
Mentor

hey,

maybe that helps

_.insert->_.-insert

0 Likes
Message 3 of 5

zakkie
Contributor
Contributor

Hi komondormrex
I tried every possible variance of vl-cmdf "_.insert"
When removing the dynamic function, no error and no stretch. 
When i delete the block and purge it works perfectly so something else is up.

0 Likes
Message 4 of 5

komondormrex
Mentor
Mentor
Accepted solution

then i would recommend replacing command method for inserting block with vla one.

(vl-load-com)

(defun LM:setdynpropvalue (blk prp val)
    (setq prp (strcase prp))
    (vl-some
       '(lambda (x)
            (if (= prp (strcase (vla-get-propertyname x)))
                (progn
                    (vla-put-value x (vlax-make-variant val (vlax-variant-type (vla-get-value x))))
                    (cond (val) (t))
                )
            )
        )
        (vlax-invoke blk 'getdynamicblockproperties)
    )
)

(defun c:Testwin (/ blo sfw inpt rot blkobj blockExists)
    (setq blo "Win2")
    (if (not (tblsearch "BLOCK" blo)) ;if block exists
        (progn
            (princ "\nBlock 'Win2' not found in drawing.")
            (setq blo (getfiled "Select Window Block File" "c:\\Blocks\\" "dwg" 0)) ;if not then search
            (if (not blo)
                (progn
                    (princ "\nOperation cancelled - no file selected.")
                    (exit)
                )
            )
        )
        (princ "\nBlock found in drawing.")
    )
  (if (not (setq inpt (getpoint "\nPick insertion point: ")))  ;insertion point
        (progn (princ "\nOperation cancelled.") (exit))
    )
    (setq sfw (getreal "\nEnter Window size <500.0>: ")) ;window size
    (if (null sfw) (setq sfw 500.0))
    (setq rot 0.0)
;   (vl-cmdf "_.insert" blo "_non" inpt 1 1 rot)  
	(setq blkobj (vla-insertblock (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
						 		  (vlax-3d-point inpt) blo 1 1 1 0
				 )
	)
    (if (and ;(setq blkobj (vlax-ename->vla-object (entlast)))
			 blkobj
             ;(vlax-property-available-p blkobj 'IsDynamicBlock)
             (= :vlax-true (vla-get-IsDynamicBlock blkobj)))
        (progn
            (if (not (LM:setdynpropvalue blkobj "DISTANCE1" sfw))
                (princ "\nWarning: 'DISTANCE1' property not found.")
            )
            (princ (strcat "\nWindow size set to: " (rtos sfw)))
        )
        (princ "\nError: Failed to insert dynamic block.")
    )
    (princ)
)

aamof, i had experienced no issue with your original code.

Message 5 of 5

zakkie
Contributor
Contributor
This did the trick!
(setq blkobj (vla-insertblock (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
  (vlax-3d-point inpt) blo 1 1 1 0
)
)
Thank you so very much!!!!
0 Likes