ActiveX error

ActiveX error

franciscovHWABV
Contributor Contributor
3,675 Views
7 Replies
Message 1 of 8

ActiveX error

franciscovHWABV
Contributor
Contributor

Good morning all.

I have a question about the program mentioned on link below, but as this is a completely new trouble I think the best was to create anoter post. I hope there is no problem.

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/modify-value-of-parameter-on-existin...

 

I have been working on this program again in the last few days with no trouble, but suddenly once it stopped working with no change added to the code. The error message was: 

 

ActiveX Server returned the error: unknown name: <GETDYNAMICBLOCKPROPERTIES>

Autolisp marked the error on the (vlax-invoke blk 'getdynamicblockproperties) line on code below. I have been reading the possible causes of this message but I do not quite understand it, mostly as this part was working nice and smooth for a while, as well as the error started after no change made on the code. 

 

(defun c:slats()
(setq lst1 '())
(setq nslat 1)

(setq olddim (getvar "dimzin"))
(setvar "dimzin" 0)

(if (setq fid(open "C:\\Users\\Andrés\\Downloads\\Book1.csv" "r"))
(progn
(while (setq lineData(read-line fid));excel
(setq len (1+ (strlen ",")))
(while (setq pos (vl-string-search "," lineData));list
(setq lst1 (cons (substr lineData 1 pos) lst1)
lineData (substr lineData (+ pos len))
)
);while list

(setq lst1 (reverse lst1))
(set (read (strcat "long" (itoa nslat))) (read(car lst1)))
(set (read (strcat "wide" (itoa nslat))) (read(cadr lst1)))
(set (read (strcat "insertpointx" (itoa nslat))) (caddr lst1))
(set (read (strcat "insertpointy" (itoa nslat))) (cadddr lst1))
(set (read (strcat "insertpoint" (itoa nslat))) (list (eval (read (strcat "insertpointx" (itoa nslat)))) (eval (read (strcat "insertpointy" (itoa nslat))))))
(setq xscale (read (cadddr (cdr lst1))))
(setq yscale (read (cadddr (cddr lst1))))
(setq rotation (read (cadddr (cdddr lst1))))
(setq inches (cadddr (cddddr lst1)))
(setq name (cadddr (cddddr (cdr lst1))))
(setq project (cadddr (cddddr (cddr lst1))))
(setq contractor (cadddr (cddddr (cdddr lst1))))
(setq designer (cadddr (cddddr (cddddr lst1))))
(setq client (cadddr (cddddr (cddddr (cdr lst1)))))
(setq promanager (cadddr (cddddr (cddddr (cddr lst1)))))
(setq drawn (cadddr (cddddr (cddddr (cdddr lst1)))))
(setq checked (cadddr (cddddr (cddddr (cddddr lst1)))))
(setq approved (cadddr (cddddr (cddddr (cddddr (cdr lst1))))))
(setq projectno (cadddr (cddddr (cddddr (cddddr (cddr lst1))))))
(setq drawingno (cadddr (cddddr (cddddr (cddddr (cdddr lst1))))))
(setq date (cadddr (cddddr (cddddr (cddddr (cddddr lst1))))))

(if (= name "Break")
()
(progn
(command "_-insert" "slat" (eval (read (strcat "insertpoint" (itoa nslat)))) xscale yscale rotation)
(set (read (strcat "slat" (itoa nslat))) (entlast))
)
)

(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)
)
)

(if (= name "Break")
()
(progn
(LM:setdynpropvalue (vlax-ename->vla-object (eval (read (strcat "slat" (itoa nslat))))) "long" (eval (read (strcat "long" (itoa nslat)))))
(LM:setdynpropvalue (vlax-ename->vla-object (eval (read (strcat "slat" (itoa nslat))))) "wide" (eval (read (strcat "wide" (itoa nslat)))))

(setq intextpoint (list (+ (car (eval (read (strcat "insertpoint" (itoa nslat))))) (/ (eval (read (strcat "long" (itoa nslat)))) 2)) (+ (cadr (eval (read (strcat "insertpoint" (itoa nslat))))) (/ (eval (read (strcat "wide" (itoa nslat)))) 2))))
(setq widetext (rtos (/ (eval (read (strcat "wide" (itoa nslat)))) 1000.0) 2 1))

(command "_mtext" intextpoint "_j" "_mc" intextpoint (strcat name " slat") (strcat (read inches) "''" "x" widetext "m") "")
(command "_Laymch" "_L" "" "_n" "DIM" "")
(command "_scaletext" "_l" "" "_mc" 100)
)
)

(setq lst1 '())
(setq nslat (1+ nslat))
);while excel
(close fid)

);progn
);if

(setq hannopoint1 (list insertpointx1 (+ insertpointy1 wide1)))
(setq hannopoint2 (list (+ (eval (read (strcat "insertpointx" (itoa (- nslat 1))))) (eval (read (strcat "long" (itoa (- nslat 1)))))) (cadr hannopoint1)))
(setq hannopoint3 (list (car hannopoint1) (+ (cadr hannopoint1)250)))

(setq xdimension1 (/ (- (car hannopoint2) (car hannopoint1)) 1000.0000))
(setq xdimension2 (/ xdimension1 0.0254))
(setq xdimension3 (/ xdimension2 12.0000))
(setq xdimension4 (fix xdimension3))
(setq xdimensioninch (rtos (- xdimension2 (* 12 xdimension4)) 5 1))
(setq xdimensionft (itoa xdimension4))

(command "_dimlinear" hannopoint1 hannopoint2 "_t" (strcat xdimensionft "' " xdimensioninch "''") hannopoint3 "")

(setq yannopoint1 (list (+ (eval (read (strcat "insertpointx" (itoa (- nslat 1))))) (eval (read (strcat "long" (itoa (- nslat 1)))))) (+ (eval (read (strcat "insertpointy" (itoa (- nslat 1))))))))
(setq yannopoint2 (list (car yannopoint1) (+ (cadr insertpoint1) wide1)))
(setq yannopoint3 (list (+ (car yannopoint1)250) (cadr hannopoint1)))

(setq ydimension (rtos (/ (- (cadr yannopoint2) (cadr yannopoint1)) 1000.00) 2 2))

(command "_dimlinear" yannopoint1 yannopoint2 "_t" (strcat ydimension "m") yannopoint3 "")

(setvar "dimzin" olddim)

(setq nslat 0)

(defun LM:SetAttributeValues ( blk lst / enx itm )
(if (= "ATTRIB" (cdr (assoc 0 (setq enx (entget (setq blk (entnext blk)))))))
(if (setq itm (assoc (strcase (cdr (assoc 2 enx))) lst))
(progn
(if (entmod (subst (cons 1 (cdr itm)) (assoc 1 enx) enx))
(entupd blk)
)
(LM:SetAttributeValues blk lst)
)
(LM:SetAttributeValues blk lst)
)
)
)

(if ;; If we can retrieve a set of attributed blocks
(setq s ;; Assign the selection set pointer to variable 's'
(ssget "_X" ;; Search entire database (see http://bit.ly/137NmOJ for more info)
'(
(0 . "INSERT") ;; Block References
(66 . 1) ;;Attributed
(2 . "tb2020") ;; with name tb2020 (this assumes block is non-dynamic)
)
) ;; end SSGET
) ;; end SETQ
(progn
;; Evaluate the following expressions and return the result
;; of the last expression evaluated. PROGN is used as a
;; wrapper function so that we can pass multiple expressions
;; to the IF function as a single argument constituting the
;; 'then' parameter.
(setq l
(list

(cons "PROJECT1" project)
(cons "CONTRACTOR" contractor)
(cons "DESIGNER" designer)
(cons "CLIENT" client)
(cons "PROJECTMANAGER" promanager)
(cons "DRAWNBY" drawn)
(cons "CHECKEDBY" checked)
(cons "APPROVEDBY" approved)
(cons "PROJ.NO." projectno)
(cons "DRG.NO." project)
)
)




;; end SETQ

;; The resulting list might look like this:
;; l = (("RUNGFIRST" . "2") ("RUNGCNT" . "20") ("RUNGDIST" . "1"))

;; Repeat the following expressions a number of times
;; equal to the number of items in the selection set.
;; Note that the numerical argument for the repeat function
;; is only evaluated once and hence the integer index variable 'i'
;; will only be assigned a value once.
(repeat (setq i (sslength s))
;; Call the LM:setattributevalues function with the block entity name
;; and association list of attribute tags/values to be set.
(LM:SetAttributeValues (ssname s (setq i (1- i))) l)
) ;; end REPEAT
) ;; end PROGN

;; Else no blocks were found...
(princ "\nNo \"tb2020\" blocks were found.")
)

 

 

(princ)
)

 

 

 

 

 

0 Likes
Accepted solutions (3)
3,676 Views
7 Replies
Replies (7)
Message 2 of 8

pbejse
Mentor
Mentor
Accepted solution

@franciscovHWABV wrote:

 

I have been working on this program again in the last few days with no trouble, but suddenly once it stopped working with no change added to the code. The error message was: 

 

ActiveX Server returned the error: unknown name: <GETDYNAMICBLOCKPROPERTIES>

Simply put, the  argument you supplied to LM:setdynpropvalue function is NOT a block @franciscovHWABV 

 

All those caddr makes my head hurt 😄 

 

...
(setq name (cadddr (cddddr (cdr lst1))))
...
...
(setq date (cadddr (cddddr (cddddr (cddddr (cddddr lst1))))))
...

 

Do you need help with this ?

 

0 Likes
Message 3 of 8

Sea-Haven
Mentor
Mentor

cddddddr use (nth x lst) just remember that (nth 0 lst) is first item.

 

(nth x (nth y (nth k (nth J and so on

 

 

Message 4 of 8

franciscovHWABV
Contributor
Contributor

Sorry, do you mean that in the drawing there should be an existing block in order to follow the code? On the dwg file I am using there is the same block as before. Also if there is something wrong in the code I do not know what can it be as nothing has been modified since the program worked. 

 

Thanks @Sea-Haven ! As you can see I am new on Autolisp but always great to learn!

0 Likes
Message 5 of 8

pbejse
Mentor
Mentor
Accepted solution

@franciscovHWABV wrote:

Sorry, do you mean that in the drawing there should be an existing block in order to follow the code?


I'm only saying is the cause for that error message to appear is when the subfunction is supplied an vlax-object other than a block object. 

 

You should guarantee this line is succesful @franciscovHWABV 

(command "_-insert" "slat"
		     (eval (read (strcat "insertpoint" (itoa nslat))))
		     xscale  yscale  rotation
	    )
(set (read (strcat "slat" (itoa nslat))) (entlast))

as value for this  item

(eval (read (strcat "slat" (itoa nslat))))

will depend on the type of object the program will pass on the the sub LM:setdynpropvalue

 

HTH

 

0 Likes
Message 6 of 8

franciscovHWABV
Contributor
Contributor

Hi all.

 

I have solved it finally. The problem was on both lines below, which were lacking a "read" before (caddr lst1) and (cadddr lst1):

 

(set (read (strcat "insertpointx" (itoa nslat))) (caddr lst1))
(set (read (strcat "insertpointy" (itoa nslat))) (cadddr lst1))

 

Which still surprises me is that those two lines have been like that since early states of the code, so I do not know how it was working before...

 

Thank you for the answers!

0 Likes
Message 7 of 8

Sea-Haven
Mentor
Mentor

(caddr lst1)  = (nth 2 lst1)

(cadddr lst1) = (nth 3 lst1) 

Much easier than remembering position in a list just count 1 2 3 4 etc then subtract 1.

0 Likes
Message 8 of 8

RachelGomez161999
Contributor
Contributor
Accepted solution

When you use Microsoft Access, you receive the following error message:

ActiveX component can't create object

This article describes some common causes for this error message and offers methods that you can use to resolve the issue.

Cause
This behavior can occur if any of the following conditions are true:

Data Access Objects (DAO) is not properly registered.
One or more references are missing.
There is a utility database reference that is not valid.
You do not have the required permissions for required libraries.
There is a damaged wizard file.

 

This may help you,

Rachel Gomez