Hi all,
Does anyone have or know of a lisp that will check a complete drawing to check if the solids in said drawing are 'valid ShapeManager solid'
Thanking you in advance
JohnB
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
What you mean by Valid Shape Manager ?
Can you post a simple drawing ?
_Tharwat,
When working with solids there is a command for checking whether a solid is a valid 3d solid or not.
This command only works on one solid at a time. I have a drawing with over 300 solids and using this command
I have to pick each solid individually and restart the command after each pick. I would like to be able to run the
command to check all the solids in one go.
JohnB
_Tharwat,
When working with solids there is a command for checking whether a solid is a valid 3d solid or not.
This command only works on one solid at a time. I have a drawing with over 300 solids and when using this command
I have to pick each solid individually and restart the command after each pick. I would like to be able to run the
command to check all the solids in one go and if possible to have invalid solids highlighted or identified in someway..
JohnB
Hi,
I am thinking that if a solid is invalid, it will throw an error
when trying to extract one of it's solid properties.
The following lisp highlights all solids with invalid
volume and/or moment of inertia properties.
You could expand it to check other solid properties and
ammend it to do what you want with the list of invalid solids.
(defun prop-test (obj prop)
(and
(setq obj (vlax-ename->vla-object obj))
(vlax-property-available-p obj prop)
(vl-catch-all-error-p
(vl-catch-all-apply
'vlax-get-property
(list obj prop)
)
)
)
)
(defun c:sol-check ( / ss1 count ent elist)
(if (setq ss1 (ssget "X" (list (cons 0 "3DSOLID"))))
(setq count (sslength ss1))
(setq count 0)
)
(repeat count
(setq ent (ssname ss1 (setq count (1- count))))
(if (or
(prop-test ent 'volume)
(prop-test ent 'momentofinertia)
)
(setq elist (cons ent elist))
)
)
(foreach n elist
(redraw n 3)
)
(princ)
)
Regards Ian
It looks like your assumptions are incorrect.
When doing a region/mass properties on an invalid solid it still gives the expected results - no error reports.
I have attached a drawing with invalid solids.
I know why they are invalid, because they are so far away from the origin.
This was done deliberately for this example but on a lot of my drawings this happens because I have to work in real world coordinates.
Thanks for trying
Regards
Johnb
Hi,
as I said you can expand it to account for other invalid properties.
Adding the line
(prop-test ent 'position)
finds the invalid solids in the dwg you attached.
You can use
(vlax-dump-object (vlax-ename->vla-object (car (entsel)))
to inspect the available properties for a selected object.
Ian
Ian,
Once again thanks for your efforts.
BUT the addition you have suggested highlights all the solids in a drawing, invalid or not.
See attached drawing.
Regards
Johnb
Hi,
yes you are right, the position property
also throws an error with valid solid extrusions.
I guess my thinking was bad.
Ian
The solids seem fine, more likely the problem exists within the SolidEdit-Check function. Or, to be more precise, with that functions ability to maintain tolerance at such extreme unit offsets.
Some of the solids shown in your drawing are flagged as invalid; but if you readdress the working units – from millimeters to Meters – and scale everything by 0.001, the solids check out as valid.
With regard to sensible modeling:
A Unit should be chosen that allows the model to be set within a 10000, 10000, 10000 cube centered on the WCS origin. An Xref-ing scheme should be employed if the model needs to be set in extreme real world coordinates.
For example, even when I scaled the attached model as stated, the solids are still 10000000+ Meters from WCS origin.
I think your function might be to rewrite witn NOT statement:
(defun prop-test (obj prop) (and (setq obj (vlax-ename->vla-object obj)) (vlax-property-available-p obj prop) (not (vl-catch-all-error-p (vl-catch-all-apply 'vlax-get-property (list obj prop)) ) ) ) )
then it will show which one of the property isn't available correct,
Regarrs,
Oleg
seant61,
Doing as you suggest gives unpredictable results, some become valid & others that were valid become invalid.
oleg,
Your code gives an error: too few arguments.
Thanks for your replies anyway.
Regards
JohnB
Here is the file that was attached to the AutoCAD 2011 posting.
In one, I just scaled by .001, from WCS origin. All the solids are listed as Valid ShapeManager Solids.
I think the second file, I both scaled and relocated. I think this is the safest setup for further modeling. Once compleded the model can be Xreffed into the big picture.
seant61,
You are correct - the scaling & moving turned all the solids valid.
BUT this is not answering my original question - I would like to be
able to check for invalid solids without having to pick each solid individually
& have the invalid solids highlighted in some way.
Thanking you for your efforts
JohnB
You wrote
>oleg,
>Your code gives an error: too few arguments.
>Thanks for your replies anyway.
Ok try attached instead, I just checked Position property,
you can change it on whatever you want, bad solids
will be red colored
john-B wrote:
... BUT this is not answering my original question - I would like to be
able to check for invalid solids without having to pick each solid individually
& have the invalid solids highlighted in some way.
Thanking you for your efforts
JohnB
---
Ok, this code, may not be written in the most correct way...
But, will do the trick.
(defun C:SolTest (/ old-lgfm old-lgfm itm num hnd sol myl) (vl-load-com) ;;;Posted by John Uhden ;;;forums.autodesk.com - Discussion Groups ;;;Visual LISP, AutoLISP and General Customization ;;;06-11-2002 (defun @get_log (# / file fp i) (setq file (getvar "logfilename") i 0 ) (if (setq fp (open file "r")) (progn (while (setq line (read-line fp)) (if (> (strlen line) 0) (setq lines (cons line lines)) ) ) (close fp) ) ) (setq lines (reverse lines)) (while (> (length lines) #) (setq lines (cdr lines)) ) ) (setq sset (ssget '((0 . "3DSOLID")))) (if sset (progn (setq old-lgfm (getvar "LOGFILEMODE")) (setvar "LOGFILEMODE" 1) (setq old-echo (getvar "CMDECHO")) (setq itm 0 num (sslength sset) ) (while (< itm num) (setq hnd (ssname sset itm)) (command "COPY" hnd "" "0,0,0" "0,0,0") (command "ERASE" "p" "") (setq sol (entlast)) (setvar "CMDECHO" old-echo) (command "Solidedit" "_b" "_c" "_l" "" "") (setvar "CMDECHO" 0) (setq myl (car (@get_log 5))) (setq myl (vl-string-left-trim "Select a 3D solid: _l " myl) ) (if (= "This object is a valid ShapeManager solid." myl) (princ) (redraw sol 3) ) (setq itm (1+ itm)) ) ) ) (setvar "LOGFILEMODE" old-lgfm) (setvar "CMDECHO" old-echo) )
Cheers
Henrique
Hallex,
Sorry but your routine turns all solids red - valid or invalid.
It looks like you have the same problem as me & many others in
knowing what turns a solid from valid to invalid.
Thanks for your efforts.
Regards
JohnB
Sorry I have disagreed, I drawn few solids on your drawing
and all of your solids were red, but mine were not
I'm using A2010 for test
Sadly for me though, sorry