Error - too few actual parameters.

Error - too few actual parameters.

mradula88
Explorer Explorer
1,489 Views
9 Replies
Message 1 of 10

Error - too few actual parameters.

mradula88
Explorer
Explorer

Hi,  As a part of my work, I have to highlight all the dimensions that are below 5 feet in a drawing. This is the code I have, can some one help me with this lisp- (also, what if I need to highlight the selected ones in a different color?)


(defun c:qcdim ()
(setq ss (ssget "_X" '((0 . "DIMENSION")))) ; Select all entities with DXF code 0 equal to "DIMENSION"
(if (/= (sslength ss) 0) ; If there are dimensions in the selection set
(progn
(setq doc (vla-get-activedocument (vlax-get-acad-object))) ; Get the active document
(vla-startundomark doc) ; Start an undo mark
(repeat (sslength ss) ; Loop through each entity in the selection set
(setq obj (vlax-ename->vla-object (ssname ss 0))) ; Get the ActiveX object of the entity
; Check if the object is a dimension
(if (= "AcDbDimension" (vla-get-objectname obj))
(progn
(setq dim_value (vla-get-dimtextoverride obj)) ; Get the dimension value
(setq dim_value_inch (vla-converttodouble dim_value acFeet acInches)) ; Convert dimension value to inches
; Check if the dimension value is less than 60 inches (5 feet)
(if (< dim_value_inch 60)
(vla-put-isselected obj :vlax-true) ; Select the dimension
(vla-put-isselected obj :vlax-false)
)
)
)
(setq ss (ssdel (ssname ss 0) ss)) ; Remove the entity from the selection set
)
(vla-regen doc) ; Regenerate the drawing
(vla-endundomark doc) ; End the undo mark
(princ "\nAll dimensions less than 5 feet selected.")
)
(princ "\nNo dimensions found.")
)
(princ)
)

0 Likes
Accepted solutions (1)
1,490 Views
9 Replies
Replies (9)
Message 2 of 10

Kent1Cooper
Consultant
Consultant

@mradula88 wrote:

....

(setq dim_value (vla-get-dimtextoverride obj)) ; Get the dimension value
....


Two problems I see there:

 

(vla-get-textoverride [without the 'dim'] is the valid function I assume you want.

 

And for a Dimension that does not have an override, but simply uses the measured value, that will return just "" [an empty text string, i.e. no override], which will give you trouble comparing it to 60.  Is it your intent to compare the actual measured value?  If so, use (vla-get-Measurement .

Kent Cooper, AIA
0 Likes
Message 3 of 10

mradula88
Explorer
Explorer
Hi Kent,
Thank you so much for your time. I am fairly new to this and trying to learn it bit by bit.
My purpose here is to compare the actual measured value and see if its less that 5' (60") and highlight that may be in a circle or a different color.
0 Likes
Message 4 of 10

ronjonp
Mentor
Mentor

@mradula88 Don't forget to localize your variables:

ronjonp_0-1682454314208.png

 

 

0 Likes
Message 5 of 10

Kent1Cooper
Consultant
Consultant

Is the drawing unit a foot?  I see no reason to convert the value to inches and compare that to 60 -- you can just compare the original to 5.

Kent Cooper, AIA
0 Likes
Message 6 of 10

mradula88
Explorer
Explorer

Hi Kent,

 

The drawing units is inches. I tried localizing the variable but it still says "too few actual parameters".

 

Thanks!

0 Likes
Message 7 of 10

mradula88
Explorer
Explorer
Thanks Ronjonp,

I tried localizing the variable, still getting the same error. "too few actual parameters"

Thanks!
0 Likes
Message 8 of 10

Kent1Cooper
Consultant
Consultant

@mradula88 wrote:

.... My purpose here is to compare the actual measured value .... The drawing units is inches. I tried localizing the variable but it still says "too few actual parameters". ....


You don't say whether you changed the function to (vla-get-Measurement) [see Message 2].

Kent Cooper, AIA
0 Likes
Message 9 of 10

mradula88
Explorer
Explorer

Sorry for not mentioning it earlier, I did try with (vla-get-Measurement) - same error- "too few actual parameters)

 

Thanks!

0 Likes
Message 10 of 10

Kent1Cooper
Consultant
Consultant
Accepted solution

@mradula88 wrote:
.... My purpose here is to compare the actual measured value and see if its less that 5' (60") and highlight that may be in a circle or a different color.

A much simpler approach using >relational testing< [the (-4) entry]:

 

(sssetfirst nil (ssget "_X" '((0 . "DIMENSION") (-4 . "<") (42 . 60.0))))

 

That will select/grip/highlight those under 5'.  It could be made to instead put them into a selection set to do with as you choose, etc.  [It will also grab any angular Dimensions, because the DXF-code 42 entry for them holds their angular measurement in radians, so they will all be less than 2pi and therefore much less than 60.  So should it filter for only linear Dimensions?]

Kent Cooper, AIA
0 Likes