Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Solid checking

19 REPLIES 19
SOLVED
Reply
Message 1 of 20
john-B
1709 Views, 19 Replies

Solid checking

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

19 REPLIES 19
Message 2 of 20
_Tharwat
in reply to: john-B

What you mean by Valid Shape Manager ?

Can you post a simple drawing ?

Message 3 of 20
john-B
in reply to: _Tharwat

_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

Message 4 of 20
john-B
in reply to: john-B

_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

Message 5 of 20
hgasty1001
in reply to: john-B

Hi,

 

Can you post a dwg with invalid solids ?

 

Gaston Nunez

Message 6 of 20
john-B
in reply to: john-B

At this time all my 3d drawings have been corrected therefore I don't have one with invalid objects.

Message 7 of 20
Ian_Bryant
in reply to: john-B

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

Message 8 of 20
john-B
in reply to: john-B

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

Message 9 of 20
Ian_Bryant
in reply to: john-B

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

 

Message 10 of 20
john-B
in reply to: Ian_Bryant

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

Message 11 of 20
Ian_Bryant
in reply to: john-B

Hi,

yes you are right, the position property

also throws an error with valid solid extrusions.

I guess my thinking was bad.

 

Ian

 

 

Message 12 of 20
SEANT61
in reply to: john-B

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.


************************************************************
May your cursor always snap to the location intended.
Message 13 of 20
Hallex
in reply to: Ian_Bryant

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

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 14 of 20
john-B
in reply to: Hallex

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

Message 15 of 20
SEANT61
in reply to: Ian_Bryant

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.


************************************************************
May your cursor always snap to the location intended.
Message 16 of 20
john-B
in reply to: SEANT61

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

Message 17 of 20
Hallex
in reply to: john-B

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

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 18 of 20
hmsilva
in reply to: john-B

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

EESignature

Message 19 of 20
john-B
in reply to: Hallex

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

Message 20 of 20
Hallex
in reply to: john-B

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

_____________________________________
C6309D9E0751D165D0934D0621DFF27919

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost