Jump to content

Recommended Posts

Posted

I have a lisp to calculate Area (this lisp for lee mac)

And I want to upgrade the field to calculate the volume.

 

(setq fmt "%lu2%pr2%ps[, m2]%ct8[1.000000000000000E-006]")


(setq pnl (/ (getreal "\nWhat is Panel Thickness? ") 1000 ))
(setq ins (/ (getreal "\nWhat is insulation Thickness? ") 1000 ))

(setq strArea (strcat "%<\\AcObjProp Object(%<\\_ObjId " (LM:ObjectID objVL) ">%).Area \\f \"" fmt "\">% " ))
(setq strAll (strArea * pnl))            ;;<<<--- This formula 
(setq strins (strArea * (- pnl ins)))    ;;<<<--- This formula 

(setq str (strcat strArea "\n x" (rtos pnl) strAll "\n x" (rtos (- pnl ins)) strins  ))

(defun LM:ObjectID ( obj )
    (eval
        (list 'defun 'LM:ObjectID '( obj )xl v xl v 
            (if
                (and
                    (vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE"))
                    (vlax-method-applicable-p (vla-get-utility (LM:acdoc)) 'getobjectidstring)
                )
                (list 'vla-getobjectidstring (vla-get-utility (LM:acdoc)) 'obj ':vlax-false)
               '(itoa (vla-get-objectid obj))
            )
        )
    )
    (LM:ObjectID obj)
)

 

Posted
4 hours ago, asos2000 said:

And I want to upgrade the field to calculate the volume

@asos2000 Please ulpoad your sample.dwg

 

Posted (edited)

Google help about using formula in fields. You can do a * multiply to a field. If you only had one height it would be easy as you could make your pline with a thickness and read that. 

 

Thinking more you may have a problem as you want 2 values, and each slab is different, you may need to look at XDATA attached to the slab or a little hidden block say at a corner and read the 2 attributes. The attributes set to invisible. 

 

The other way is to draw the pline twice with thickness set to the 2 values, select both plines in your field calcs.

 

You can do lots of things with Fields but you sometimes have to build a string bit by bit running field and copy paste result to a lisp code then use the VL put string to update. 

 

2 plines with 2 thickness. 

image.png.699ce41c40dc83d1e0497f5dce964712.png

 

Something like this NOT TESTED cut from other code adding fields.

 

(setq str (strcat "%<\\AcExpr "
 "%<\AcObjProp Object(%<\_ObjId 765163296>%).Thickness>%" 
" * "
%<\AcObjProp Object(%<\_ObjId 765225056>%).Area>%
 ">%"
)
)
(Vla-put-textstring objtxt str)

So to work need to rethink how slabs are done.

 

Thinking more just make plines into 2 solids with correct height.  %<\AcObjProp Object(%<\_ObjId 772315888>%).Volume>% 

Edited by BIGAL
Posted (edited)
16 hours ago, devitg said:

@asos2000 Please ulpoad your sample.dwg

 

We Are drafting Precast concrete sandwich panel.
Layer 1 & 3 are concrete and layer 2 is insulation.

So we calculate 2 volumes.

- Full volume  concrete + insulation Layer 1, 2  & 3

- Concrete only.Layer 1 & 3

 

Sample.dwgimage.thumb.png.baec51f3b692fda9fe3af74fd8a53bb6.png

Edited by asos2000
Posted (edited)

I understand what your doing but if you have say a sandwich construction  you need the Cyan pline to have extra properties you can not change shape and expect the volume to reflect the change. You are changing thickness so makes field calc redundant.

 

Are you confused and using wrong terminology in that you just want a text answer given a pline area and enter values of sandwich thickness involved that is easy. That is just get area of pline and multiply by a thickness.

 

Look at my true 3d image. Yes can get different material thickness and use in a MTEXT field.

 

You could use this 6 vertice shape in a Field but it would use only the preset thicknesses multipliers. eg 100  when you want 50.

Edited by BIGAL
Posted

I am sure that 3D makes it easier, but I can't create 3D for each panel.

I was trying to get use the lisp instead of using the calculator.

To make it easier I am thinking to make the volume to be calculated in field.

I'll try to make solve this issue without field.

Posted

The main issue for me is how to convert 

this (normal field for an object)

%<\AcObjProp.16.2 Object(%<\_ObjId 2324458739744>%).Area \f "%lu2%pr2%ps[, m2]%ct8[1.000000000000000E-006]">%

to this (Formula)

%<\AcExpr (%<\_FldPtr 2323697368832>%*300*.000000001) \f "%lu2%pr2">%

 

Posted

Still think it would be easier when making the shapes to duplicate them at say different Z levels and with a thickness. Then can select all 3 and get say by layer the relevant thickness to be used in the field.

 

If you need a lisp to take a pline and copy it vertically changing layer and adding thickness can be done pretty easy. Put on layers set to no plot.

Posted (edited)

Perhaps this?

(vl-load-com)
(defun make_field (ent# / nw_obj)
  (initget 1)
  (setq nw_obj
    (vla-addMtext Space
      (vlax-3d-point (getpoint "\nInsert point of Field: "))
      0.0
      (strcat
        "{\\fArial Narrow|b0|i0|c0|p34;"
        "%<\\AcObjProp.16.2 Object(%<\\_ObjId "
        (itoa (vla-get-ObjectID (vlax-ename->vla-object ent#)))
        ">%).Area \\f \"%lu2%pr2%ps[, m²]%ct8[1E-06]\">%"
        "\\P"
        "%<\\AcExpr ("
        "%<\\AcObjProp.16.2 Object(%<\\_ObjId "
        (itoa (vla-get-ObjectID (vlax-ename->vla-object ent#)))
        ">%).Area \\f \"%lu2%ct8[1E-06]\">%"
        "*"
        "%<\\AcDiesel $(getvar,\"USERR1\")>%)"
        " \\f \"%lu2%pr2%ps[, m\\\U+00B3]%ct8[1E-09]\">%"
        "\\P"
        "%<\\AcExpr ("
        "%<\\AcObjProp.16.2 Object(%<\\_ObjId "
        (itoa (vla-get-ObjectID (vlax-ename->vla-object ent#)))
        ">%).Area \\f \"%lu2%ct8[1E-06]\">%"
        "*"
        "%<\\AcDiesel $(getvar,\"USERR1\")>%"
        "-"
        "%<\\AcObjProp.16.2 Object(%<\\_ObjId "
        (itoa (vla-get-ObjectID (vlax-ename->vla-object ent#)))
        ">%).Area \\f \"%lu2%ct8[1E-06]\">%"
        "*"
        "%<\\AcDiesel $(getvar,\"USERR2\")>%)"
        " \\f \"%lu2%pr2%ps[, m\\\U+00B3]%ct8[1E-09]\">%"
        "}"
      )
    )
  )
  (mapcar
    '(lambda (pr val)
      (vlax-put nw_obj pr val)
    )
    (list 'AttachmentPoint 'Height 'DrawingDirection 'Rotation)
    (list 1 (getvar "TEXTSIZE") 5 rtx)
  )
)
(defun c:vol_field ( / htx rtx AcDoc Space ent thick1 thick2)
  (initget 6)
  (setq htx (getdist (getvar "VIEWCTR") (strcat "\nSpecify the height of the field <" (rtos (getvar "TEXTSIZE")) ">: ")))
  (if htx (setvar "TEXTSIZE" htx))
  (if (not (setq rtx (getorient (getvar "VIEWCTR") "\nSpecify field orientation <0.0>: "))) (setq rtx 0.0))
  (setq
    AcDoc (vla-get-ActiveDocument (vlax-get-acad-object))
    Space
    (if (= 1 (getvar "CVPORT"))
      (vla-get-PaperSpace AcDoc)
      (vla-get-ModelSpace AcDoc)
    )
  )
  (while (setq ent (entsel))
    (if ent
      (cond
        ((eq (cdr (assoc 0 (entget (car ent)))) "LWPOLYLINE")
          (if (zerop (getvar "USERR1")) (setvar "USERR1" 300.0))
          (initget 6)
          (setq thick1 (getdist (strcat "\nFirst thickness in mm? <" (rtos (getvar "USERR1") 2 0) ">: ")))
          (if thick1 (setvar "USERR1" thick1))
          (if (zerop (getvar "USERR2")) (setvar "USERR2" 50.0))
          (initget 6)
          (setq thick2 (getdist (strcat "\nSecond thickness in mm? <" (rtos (getvar "USERR2") 2 0) ">: ")))
          (if thick2 (setvar "USERR2" thick2))
          (make_field (car ent))
        )
        (T (princ (strcat "\n" (cdr (assoc 0 (entget (car ent)))) " is an invalid object")))
      )
    )
  )
  (prin1)
)

 

Edited by Tsuky
Posted

Interesting example Tsuky of using multiple field values, the only problem I see is referring to the comment by Asos2000 "We Are drafting Precast concrete sandwich panel." Well concrete tilt panels can vary in thickness so how do you relate the field to the correct thickness for that object ?  That is why I am pushing multiple objects or Xdata or LDATA or hidden block with attributes.

 

If you have to enter the thickness each time it defeats the automation, way better is draw the panel with the thickness attached. Tilt panels have been around for a long time, there is lisp code out there to draw them say starting with 10 basic shapes just enter values and the panel is drawn. Stuff like centroid and weight calculated. The simplest shape is a rectang so start with this.

 

image.png.a05ab729fb8012e5bb9eba67bfd032fe.png

 

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...