Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Using Centroid point for complex solids

edited March 31 in BricsCAD BIM

Is there a way to snap to or use the centroid point of a complex body.
I want a make a (semi automatic) routine for placing a sphere on it for calculation purposes.
How to do this?

«1

Comments

  • Dear Hans
    Here is a workaround. The coordinates of the centroid can be found in the Mass/Centroid property in the Properties panel. The problem is that there is a space after the commas that separate the X,Y,Z values. When pasted in the command line you get three 'Unable to recognize entry. Please try again.' prompts. The solution is to remove these spaces in e.g. Notepad, then copy/paste the coordinates from Notepad into the command line.

  • Hi Hans,
    just type the following code in the command line, then select a 3Dsolid.
    A sphere with 5 units Radius will be created at the centroid of the selected solid.
    (vl-cmdf "_SPHERE" (vlax-get (vlax-ename->vla-object (car(entsel))) 'Centroid) 5)

  • edited March 31

    Works perfect!!
    Manythanks

  • Can this vlax-get method be used for .volume also?
  • Yes of course...
    (vlax-get (vlax-ename->vla-object (car(entsel))) 'Volume)

    You can use the following code in the command line to get a list of Properties and functions of ANY entity in Bricscad
    (vlax-dump-object (vlax-ename->vla-object (car (entsel ))) T)

    You can also look at the following links for more informations

    https://knowledge.autodesk.com/de/support/autocad/learn-explore/caas/CloudHelp/cloudhelp/2016/DEU/AutoCAD-AutoLISP/files/GUID-BCE56B30-54A6-42F9-8910-81AF2B7B9AA8-htm.html

    https://documentation.help/AutoCAD-ALISP-VLISP/WS73099cc142f4875516d84be10ebc87a53f-7c00.htm
    https://documentation.help/AutoCAD-ALISP-VLISP/WSfacf1429558a55de185c428100849a0ab7-7c71.htm

    https://www.bricsys.com/bricscad/help/en_US/CurVer/DevRef/index.html?page=source/LISP_OverView.htm

    The code provided is Lisp code and you can automate your projects, by specifying tasks and targets in detail !

    As you can see Centroid and Volume are just 2 of 34 properties
    Just substitute the required property in the following code

    (vlax-get (vlax-ename->vla-object (car(entsel))) 'Required Property )

    In the case of a 3Dsolid you get the following Informations :

    : (vlax-dump-object (vlax-ename->vla-object (car(entsel))) T)
    Select entity: 
    ; IAcad3DSolid 58df56f0 : TeighaX Interface of a solid object with free-form surface support
    ;
    ; Property values :
    ;
    ;   Application (RO) = #<VLA-OBJECT IAcadApplication 00000000241A4CF0>
    ;   Centroid (RO) = (-400.0 1340.0 30.0)
    ;   Color = 256
    ;   Database (RO) = #<VLA-OBJECT IAcadDatabase 000000005958CB58>
    ;   Document (RO) = #<VLA-OBJECT IAcadDocument 0000000024D9B8A8>
    ;   EntityName (RO) = "AcDb3dSolid"
    ;   EntityTransparency = "ByLayer"
    ;   EntityType (RO) = NIL
    ;   Handle (RO) = "D9"
    ;   HasExtensionDictionary (RO) = 0
    ;   History = 0
    ;   Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 00000000593B7018>
    ;   Layer = "0"
    ;   Linetype = "ByLayer"
    ;   LinetypeScale = 1.0
    ;   Lineweight = -1
    ;   Material = "ByLayer"
    ;   MomentOfInertia (RO) = (154677248000000.0 47691776000000.0 202166272000000.0)
    ;   ObjectID (RO) = 794695296
    ;   ObjectID32 (RO) = 794695296
    ;   ObjectName (RO) = "AcDb3dSolid"
    ;   OwnerID (RO) = 786921184
    ;   OwnerID32 (RO) = 786921184
    ;   PlotStyleName = "ByLayer"
    ;   Position = (-400.0 1340.0 0.0)
    ;   PrincipalDirections (RO) = (1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0)
    ;   PrincipalMoments (RO) = (2908928000000.0 34098944000000.0 36957184000000.0)
    ;   ProductOfInertia (RO) = (-45281280000000.0 3396096000000.0 -1013760000000.0)
    ;   RadiiOfGyration (RO) = (1353.11985179929 751.354332744101 1546.95399629939)
    ;   ShowHistory = 0
    ;   SolidType (RO) = NIL
    ;   TrueColor = #<VLA-OBJECT IAcadAcCmColor 000000005957D9F8>
    ;   Visible = -1
    ;   Volume (RO) = 84480000.0
    ;
    ; Methods supported :
    ;
    ;   ArrayPolar (3)
    ;   ArrayRectangular (6)
    ;   Boolean (2)
    ;   CheckInterference (2)
    ;   Copy ()
    ;   Delete ()
    ;   Erase ()
    ;   Explode ()
    ;   GetBoundingBox (2)
    ;   GetExtensionDictionary ()
    ;   GetXData (3)
    ;   Highlight (1)
    ;   IntersectWith (2)
    ;   Mirror (2)
    ;   Mirror3D (3)
    ;   Move (2)
    ;   Rotate (2)
    ;   Rotate3D (3)
    ;   ScaleEntity (2)
    ;   SectionSolid (3)
    ;   SetXData (2)
    ;   SliceSolid (4)
    ;   TransformBy (1)
    ;   Update ()
    
  • edited March 29

    I would like to use this code in combination with Lee Mac QuickField routine
    http://www.lee-mac.com/lisp/html/QuickFieldV1-3.html

    This runs to some extends but i am facing 2 challenges.

    1. In the call for the making of the centroid entlast or last point will not work.
      I tried different other things but, like passing the use of ENT of Lee Mac routines, to no avail

    2. Somehow the text in QuickField seems hardcoded to come out as 0.2 and non annotative.
      I cannot figure out how this is set.

    (defun c:test1 ( / ent ) (LM:QuickField "Volume" "%lu2%pr3%ps[Volume: ,]%ct8[1E-9]" 2)  ; works!
    (vl-cmdf "_SPHERE" (vlax-get (vlax-ename->vla-object (car(entsel))) 'Centroid) 75)) ; needs another selection from user

    The second line would be something like (car(entlast))

  • just specify what should be your result ?
    To place the field with the Volume AND the Sphere at the centroid of the 3Dsolid ?

  • Yes. The idea is to place this tag on the spot of determined point of the Centroid.

    Knipsel.JPG
    836 x 581 - 63K
  • This code will place the required Field (Volume Text) and a SPHERE at the Centroid of a 3D Solid.
    The textsize can be configured using the command TEXTSIZE, before you run the command FCS shown below.

    (defun c:FCS  ( / solEnt solCentroid QF) 
      ; get the 3D solid entity and its Centroid 
      (setq solEnt       (car(entsel))  ;select the solid entity
            solCentroid  (vlax-get (vlax-ename->vla-object solEnt) 'Centroid)  ;find the centroid
      )
    
      ; Draw the SPHERE at Centroid....
      (vl-cmdf "_SPHERE" solCentroid 75)
    
      ; define locally the Lee-Mac function as a command !        
      (defun c:QF () (LM:QuickField "Volume" "%lu2%pr3%ps[Volume: ,]%ct8[1E-9]" 2))
    
      ;call the QF command with the 2 arguments !
      (vl-cmdf "QF" solEnt solCentroid)
      )
    
  • I have changed the formating of the field and seems to work properly now .
    (defun c:QF () (LM:QuickField "Volume" "%lu2%ps[VOLUME: ,]" 2))

    (defun c:FCS ( / solEnt solCentroid QF) 
      ; get the 3D solid entity and its Centroid 
      (setq solEnt       (car(entsel))  ;select the solid entity
            solCentroid  (vlax-get (vlax-ename->vla-object solEnt) 'Centroid)  ;find the centroid
      )
    
      ; Draw the SPHERE at Centroid....
      (vl-cmdf "_SPHERE" solCentroid 30)
    
      ; define locally the Lee-Mac function as a command !        
      (defun c:QF () (LM:QuickField "Volume" "%lu2%ps[VOLUME: ,]" 2))
    
      ;call the QF command with the 2 arguments !
      (vl-cmdf "QF" solEnt solCentroid)
      )
    
  • just a screenshot

    image.png
    966 x 467 - 29K
  • That is amazing!

  • here is my last version of this program ...
    You can loop through a selection set of solids and place a field and Sphere at the centroid !
    You get also the SUM of the Volumes at the command line.
    Enjoy...

    (defun c:FCS ( / idx ssol solEnt solCentroid solVolSum QF)
    
      ; define locally the Lee-Mac function as a command !        
      (defun c:QF () (LM:QuickField "Volume" "%lu2%ps[VOLUME: ,]" 2))
    
      ; create a selection set of 3D solids...
      (prompt "Select 3D Solids \n")
      (setq ssol (ssget '((0 . "3DSOLID")))
            idx   0   ;set the index to the first entity in the selection set
            solVolSum 0
            ) 
    
      ;loop through the selection set.....>
      (while (< idx (sslength ssol))
    
          ; get the 3D solid entity and its Centroid 
          (setq solEnt       (ssname ssol idx)            ;select the solid 
                solCentroid  (vlax-get (vlax-ename->vla-object solEnt) 'Centroid)  ;find its centroid
                solVol       (vlax-get (vlax-ename->vla-object solEnt) 'Volume)         ;find its volume
          )
    
          ; Draw the SPHERE at Centroid....
          (vl-cmdf "_SPHERE" solCentroid 1)
    
          ;call the QF command with the 2 arguments !
          (vl-cmdf "QF" solEnt solCentroid)
    
          (setq idx       (1+ idx)      ;get next solid in the selection set...
                solVolSum (+ solVolSum solVol) ;add to the SUM of volumes
          )
      )
      (prompt "\n")
      solVolSum
    )
    

    image

    Fields_Volumes_Centroids.png
    1011 x 488 - 75K
  • Thanks for sharing !
    A real timesaver!

  • This happpens for some reason i do not understand.
    One solid is recognized, the other is not.

    dwg
    dwg
    BricsCAD support.dwg
    254K
    Knipsel.JPG
    1099 x 608 - 61K
  • edited April 1

    They are there, just very small. Looks like you scaled your original objects up?

    The original LISP creates the sphere at a fixed radius (1.0) & the Lee Mac routine uses the current value of TEXTSIZE to set the size of the text.
    Also the command call to SPHERE didn't take the current ESNAP status into account, meaning the sphere could end up not at the centroid.

    Option would be to use the current CANNOSCALE to set the size of the objects.

    ; Requires Lee Mac's QuickField
    ; http://www.lee-mac.com/quickfield.html
    ; (load "QuickFieldV1-3.lsp")
    
    (defun c:FCS ( / idx ssol solEnt solCentroid solVolSum QF scalefactor)
        (setq scalefactor (/ 1.0 (getvar 'cannoscalevalue))) ; set scalefactor to use with objects
    
        (acet-error-init '(nil 1 nil)) ; set error handler, undo on error, no special cleanup
        ; save and set system vars.
        (acet-sysvar-set (list "CMDECHO" 0 "OSMODE" 0 "TEXTSIZE" (* (getvar "TEXTSIZE") scalefactor)))
      ; define locally the Lee-Mac function as a command !        
      (defun c:QF () (LM:QuickField "Volume" "%lu2%ps[VOLUME: ,]" 3))
    
      ; create a selection set of 3D solids...
      (prompt "Select 3D Solids \n")
      (setq ssol (ssget '((0 . "3DSOLID")))
            idx   0   ;set the index to the first entity in the selection set
            solVolSum 0
            ) 
    
      ;loop through the selection set.....>
      (while (< idx (sslength ssol))
    
          ; get the 3D solid entity and its Centroid 
          (setq solEnt       (ssname ssol idx)            ;select the solid 
                solCentroid  (vlax-get (vlax-ename->vla-object solEnt) 'Centroid)  ;find its centroid
                solVol       (vlax-get (vlax-ename->vla-object solEnt) 'Volume)         ;find its volume
          )
    
          ; Draw the SPHERE at Centroid....
          (vl-cmdf "_SPHERE" "_non" solCentroid (* 1.0 scalefactor))
    
          ;call the QF command with the 2 arguments !
          (vl-cmdf "QF" solEnt solCentroid)
    
          (setq idx       (1+ idx)      ;get next solid in the selection set...
                solVolSum (+ solVolSum solVol) ;add to the SUM of volumes
          )
      )
      (acet-sysvar-restore)
      (acet-error-restore) ; restore environment
      (prompt "\n")
      solVolSum
    )
    

    Regards,
    Jason Bourhill
    BricsCAD V20 Ultimate
    CAD Concepts

    lsp
    lsp
    FCS.lsp
    2K
    dwg
    dwg
    BricsCAD support.dwg
    225K
  • edited April 1

    Mtext and Annotative, that is very nice.
    I still get strange object errors whit the solids in the previous uploaded dwg.

    "%%).Volume "

    I will check for a trans function for placing centroid and text when WCS not active.

  • Used the last code from Jason with (LM:QuickField "Volume" "%lu2%ps[VOLUME: ,]%ct8[1E-9]" 3)

    dwg
    dwg
    testfile.dwg
    415K
    tmENJo1S1B.gif
    1057 x 735 - 3M
  • I used your testfile.dwg and the changed lisp file from Jason ( thanks Jason for the kind additions ! ).
    Funny enough, no spheres and Mtexts are created and i don't know why .....
    I get an error concerning the insert point of the Mtext as well ?

    Select 3D Solids
    Select entities:
    Opposite Corner:
    Entities in set: 15
    Select entities:
    Specify point for mtext:
    Specify point for mtext:
    Specify point for mtext:
    Specify point for mtext:
    Specify point for mtext:
    Specify point for mtext:
    Specify point for mtext:
    Specify point for mtext:
    Specify point for mtext:
    Specify point for mtext:
    Specify point for mtext:
    Specify point for mtext:
    Specify point for mtext:
    Specify point for mtext:
    Specify point for mtext:
    400.718839982009

    The workaround was to copy-paste the entities from your file to a new file , which you find in the attachment.
    The TEXTSIZE i set to 0.5
    I assume that your and my errors have to do with the file and not the lisp routine...some variables or other configuration..
    I had similar problems trying a file created by Acad and the solution was the above workaround !

    image

    dwg
    dwg
    Centroid_Volume_testfile_3.dwg
    263K
    Fields_Volumes_Centroids_3.png
    1011 x 488 - 72K
  • the correct screenshot...but i see that the volumes of the red steel elements are different ????image

    Fields_Volumes_Centroids_4.png
    1011 x 488 - 81K
  • I used your file
    scaled it 1000x
    loaded anno scales
    set annoscale
    FCS works fine.
    downloaded and used the file i uploaded before.
    Things seem to do fine now. Strange, sometimes restarting a program helps.

    For the transformation i suggest.

    (SETQ ucs_solCentroid (TRANS solCentroid 1 0)
    (vl-cmdf "_SPHERE" "_non" ucs_solCentroid (* 1.0 scalefactor))
    (vl-cmdf "QF" solEnt ucs_solCentroid)

    But .., this does not do the trick, so something likewise needs to be done.

  • The Solcentroid property is a variant, not a list of coords. Because of this you can't use TRANS. Instead I think it is simpler and better to avoid making command calls all together by using vla-addsphere & vla-addmtext. This allows you to use properties like Solcentroid directly without conversion.

    Revised version looks like this

    (defun C:FCS2 ( / odoc scalefactor ssol solEnt solCentroid solVolSum currspace solVol omtxt )
        (setq odoc (vla-get-activedocument (vlax-get-acad-object)))     
        (vla-endundomark odoc)
        (vla-startundomark odoc)
        (setq scalefactor (/ 1.0 (getvar 'cannoscalevalue))) ; set scalefactor to use with objects
        ; create a selection set of 3D solids...
      (Princ "\nSelect 3D Solids to place a centroid marker: ")
      (setq ssol (ssget '((0 . "3DSOLID"))))
      (cond (ssol
                    (setq solVolSum 0) 
                    (setq currspace
                            (vlax-get-property odoc
                                    (if (= 1 (getvar 'CVPORT))
                                                    'PaperSpace
                                                    'ModelSpace
                                    )
                            )
                        )
                         ;loop through the selection set.....>
                        (foreach solent (vle-selectionset->list ssol)
                    ; get the 3D solid entity and its Centroid 
                    (setq solCentroid (vlax-get-property (vlax-ename->vla-object solEnt) 'Centroid))  ;find its centroid
                    (setq solVol  (vlax-get-property (vlax-ename->vla-object solEnt) 'Volume))        ;find its volume
                      ; Draw the SPHERE at Centroid....
                      (vla-addsphere currspace solCentroid (* 1.0 scalefactor))
                      ;Place ordinary MTEXT
                      (setq omtxt (vla-addmtext currspace solCentroid 0.0 (rtos solvol)))       
                      (vla-put-Height omtxt (* (getvar 'TEXTSIZE) scalefactor))
                      (setq solVolSum (+ solVolSum solVol)) ;add to the SUM of volumes
                    )
                )
      )
        (vla-endundomark odoc)
        (princ (strcat "\nTotal volume of all 3DSOLIDS: " (rtos solVolSum)))
        (prin1)
    )
    

    Avoiding command calls makes it an order of magnitude faster too. In the revised version I just used plain MTEXT rather than the Lee Mac Quickfield. Again this was to avoid using a command call (I'm kind of surprised this worked in the first place as you're re-entering LISP). The quickfield program would need to be modified to have a function that allowed you to pass it a pre-selected entity.

    Regards,
    Jason Bourhill
    BricsCAD V20 Ultimate
    CAD Concepts

    lsp
    lsp
    FCS2.lsp
    2K
  • Yes, i was also surprised to see that re-entering LISP works !
    The same call doesn't work in acad 2020 either as (vl-cmdf "QF" solEnt solCentroid) or (vl-cmdf (c:QF) solEnt solCentroid)
    So its in any case interesting from a programmer's point of view.....
    I just wanted to avoid changing the quickfield program and i tried the re-entering LISP way.
    The only advantage with fields in this case, is that you can update them with the UPDATEFIELD command if the geometry changes.

    The Solcentroid property is a list of coords, and not a variant in BC V20 and in acad 2020 as well.

    (vlax-get (vlax-ename->vla-object (car(entsel))) 'Centroid)
    Select entity: (106.782883871549 50.8733917131498 31.7053907595897)
    (type(vlax-get (vlax-ename->vla-object (car(entsel))) 'Centroid))
    Select entity: LIST

    Thanks for your changes !

  • I did thought there would be something about the Centroid call i didn't know about.
    Glad for sorting that out so fast!! This is a becoming great routine with more possibilities.
    You can TAG whatever you want at this centroid point in one stroke!

  • edited April 3

    I put in Layers for Sphere and the Tag
    Precision m / m3 and mm/m3 , use for construction.
    However, this layer mechanism makes it a lot slower with the palette open
    Could use a faster method
    I'll come back on it.

    The problem with this code beneith is that is seems to do exactly the same.
    It swithes current layer. Thats what i want to avoid.

          ;(vla-put-layer (vla-addsphere currspace solCentroid (* 1.0 scalefactor))"TAG_Centroid")
    

    Need to check a sollution that is deep, like Lee Mac code..
    https://www.cadtutor.net/forum/topic/60312-change-layer-and-create-new-layer-if-needed-lisp/?do=findComment&comment=498601

    NOT USED MK_LAYER

    ;; mk_layer by CAB at TheSwamp.org   (Optionnal Arguments by ymg)             ;                                 
    ;; Routine to ENTAKE a LAYER entity.                                          ;   
    ;; If the layer already exist, it will be: thawed                             ;
    ;;                                         set on                             ;
    ;;                                         unlocked                           ;
    ;;                                         set as the current layer.          ;
    ;;  
    
    (defun mk_layer (argl / ent lay Color ltype)
      (setq lay (car argl) color (cadr argl) ltype (caddr argl))
      (if (tblsearch "LAYER" lay)
        (progn
          (if color (setq ent (entget (tblobjname "LAYER" lay))
                          ent (subst (cons 62 color) (assoc 62 ent) ent)
                          ent (entmod ent)
                    )
          )
          (if ltype (setq ent (entget (tblobjname "LAYER" lay))
                          ent (subst (cons 6 ltype) (assoc 6 ent) ent)
                          ent (entmod ent)
                    )
          )
          (vl-cmdf "._Layer" "_Thaw" lay "_On" lay "_UnLock" lay "_Set" lay "")
        )
        (entmakex
          (list (cons 0 "LAYER")
                (cons 100 "AcDbSymbolTableRecord")
                (cons 100 "AcDbLayerTableRecord")
                (cons 2 lay)
                (cons 70 0)
                (cons 62 (if (or (null color) (= Color "")) 7 Color))
                (cons 6 (if (or (null ltype) (= ltype "")) "Continuous" ltype))
                (cons 290 1)
                (cons 370 -3)
          )
        )
      )
      (setvar 'CLAYER lay)
    )
    

    REVISION OF CODE

    (defun C:FCS (/ odoc scalefactor ssol solEnt solCentroid solVolSum currspace solVol omtxt)
      (setq odoc (vla-get-activedocument (vlax-get-acad-object)))
      (vla-endundomark odoc)
      (vla-startundomark odoc)
      (setq scalefactor (/ 1.0 (getvar 'cannoscalevalue)))  ; set scalefactor to use with objects
        ; create a selection set of 3D solids...
      (Princ "\nSelect 3D Solids to place a centroid marker: ")
      (setq ssol (ssget '((0 . "3DSOLID"))))
      (setq oLay (vla-get-layers odoc))  ; get the layers object
      (vla-add oLay "TAG_Centroid")      ; Make sure the layer exists
      (vla-add oLay "TAG_Volume_text")   ; Make sure the layer exists
    
    
      (cond
        (ssol
          (setq solVolSum 0)
          (setq currspace
                (vlax-get-property odoc
                  (if (= 1 (getvar 'CVPORT))
                    'PaperSpace
                    'ModelSpace
                  )
                )
          )
          ;loop through the selection set.....>
          (foreach solent (vle-selectionset->list ssol)
            ; get the 3D solid entity and its Centroid 
            (setq solCentroid (vlax-get-property (vlax-ename->vla-object solEnt) 'Centroid))  ;find its centroid
            (setq solVol (vlax-get-property (vlax-ename->vla-object solEnt) 'Volume))         ;find its volume for m and unitless
            ; Draw the SPHERE at Centroid....
            (setq osphere (vla-addsphere currspace solCentroid (* 1.0 scalefactor)))
            (vla-put-layer osphere "TAG_Centroid")   ; put the sphere object on the desired layer
            ;Place ordinary MTEXT
            (if (= (getvar "insunits") 4)
              ; m3 for mm  
              (setq omtxt (vla-addmtext currspace solCentroid 0.0 (strcat " " (rtos (* solvol 1E-9) 2 2) " m" (chr 179))))
              ; else times 1
              (setq omtxt (vla-addmtext currspace solCentroid 0.0 (strcat " " (rtos (* solvol 1)) " m" (chr 179))))
            )
            (vla-put-layer omtxt "TAG_Volume_text")  ; put the Volume text on the desired layer
            (vla-put-Height omtxt (* (getvar 'TEXTSIZE) scalefactor))
            (setq solVolSum (+ solVolSum solVol))    ;add to the SUM of volumes
          )
        )
      )
     ;(vla-put-LayerON "TAG_Centroid" 1)
     ;(vla-put-LayerON "TAG_Volume_text" 1)
      (command "layer" "on" "TAG_Volume_text" "TAG_Centroid" "")
      (vla-endundomark odoc)
      (princ (strcat "\nTotal volume of all 3DSOLIDS: " (rtos solVolSum)))
      (prin1)
    )
    

    units.JPG
    1322 x 539 - 126K
    pieces of formwork.JPG
    657 x 562 - 33K
  • @Konstantin Sakellaris said:

    The Solcentroid property is a list of coords, and not a variant in BC V20 and in acad 2020 as well.

    (vlax-get (vlax-ename->vla-object (car(entsel))) 'Centroid)
    Select entity: (106.782883871549 50.8733917131498 31.7053907595897)
    (type(vlax-get (vlax-ename->vla-object (car(entsel))) 'Centroid))
    Select entity: LIST

    You're using vlax-get. I changed this to vlax-get-property, which does return a variant.

    (vlax-get-property (vlax-ename->vla-object (car(entsel))) 'Centroid)
    Select entity: #<variant 8197 ...>
    
    (type (vlax-get-property (vlax-ename->vla-object (car(entsel))) 'Centroid))
    Select entity: VARIANT
    

    This was convenient as you need in this form to put back into vla-addsphere

    I've not seen vlax-get before. Is there some documentation somewhere on it?

    Regards,
    Jason Bourhill
    BricsCAD V20 Ultimate
    CAD Concepts

  • @Hans Lammerts said:
    I put in Layers for Sphere and the Tag
    Precision m / m3 and mm/m3 , use for construction.
    However, this layer mechanism makes it a lot slower with the palette open

    Since the function already has retrieved the active document object, you can simply use this to make sure your target layers exist.

    e.g.

    (setq oLay (vla-get-layers odoc)) ; get the layers object
    (vla-add oLay "TAG_Centroid"); Make sure the layer exists

    Having done this you can put your created object onto the layer.

    e.g.

    (setq osphere (vla-addsphere currspace solCentroid (* 1.0 scalefactor))) ; create the sphere object
     (vla-put-layer osphere "TAG_Centroid") ; put the sphere object on the desired layer

    Your layer function is using a command call. This might be why it is slower. Or it could be that you have a drawing with a lot of layers?

    You can use -TOOLPANEL to hide a panel. Unfortunately for the layers panel I don't see an option to find its current state. Other panels have a system variable you can check e.g. The Mechanical Browser is open if MBSTATE = 1

    With the Volume text you could suffix the desired units onto the end.
    e.g.
    (setq omtxt (vla-addmtext currspace solCentroid 0.0 (strcat (rtos solvol) "mm" (chr 179))))

    Is there are reason that you want to mark the centroids of 3DSOLIDS like this?

    Regards,
    Jason Bourhill
    BricsCAD V20 Ultimate
    CAD Concepts

  • Dear Jason,

    there are indeed "undocumented" vlax functions in AutoLISP like (and few more) :
    (vlax-get)
    (vlax-put)
    (vlax-invoke)

    the difference is, that these "short" versions try to use/return "flat" (or exploded) data, instead of COM types ...
    In latest "Lisp Developer Support Package" those "undocumented" functions are all documented : "Vlax Functions" => "Vlax Hidden Functions" :-)

    many greetings !

  • edited April 3
    "Is there are reason that you want to mark the centroids of 3DSOLIDS like this?"

    Two reasons. For stuctural calculations and making analytical model this point needs to be extracted. This is also a logical point to have a related text. Volume for material costs
  • edited April 3

    Revised my code above.
    The formatted text and layers work much faster!
    Many thanks. I also but in a picture of EPS formwork where is has use for

     ;(vla-put-LayerON "TAG_Centroid" 1)  ; this of :vlax-true has no succes
     ;(vla-put-LayerON "TAG_Volume_text" 1) ; this of :vlax-true has no succes
     (command "layer" "on" "TAG_Volume_text" "TAG_Centroid" "")
    
Sign In or Register to comment.
Origami
Origami is the Japanese word for paper folding. ORI means to fold and KAMI means paper and involves the creation of paper forms usually entirely by folding.

Powered by VanillaForums, Designed by Steam