get and set property of objects

Hi All
I am learning LISP in BricsCAD (quite new) and I am having trouble with the section of the code (getpropertyvalue) that seems simple (autolisp) but BricsCAD does not recognize it. It gives me the error (; error : no function definition ; expected FUNCTION at [eval])
Thanks for the help

(defun C:dC ()
(setq zH (getreal "Enter Z of Circle Center:"))
(setq circCenter (list 0.0 0.0 zH))
(setq radius (getreal "Enter Radius:"))

                 (command "circle" circCenter radius)

                 (getpropertyvalue (entlast) "radius")
                 (prompt (strcat "\nRadius: " (rtos (getpropertyvalue circ "radius"))))
                 (princ)

)
Rahul

Comments

  • The LISP fails because the function "GetPropertyValue" doesn't exist. Perhaps you followed a code example that referenced, or had defined this function.

    Here are a few ways to retrieve the radius value from your circle

    Using LISP you can retrieve the property by looking up its related DXF code. The DXF code is 40 in the case of radius.
    (cdr (assoc 40 (entget (entlast))))

    In BricsCAD you can simplify this by taking advantage of VLE functions
    (vle-entget 40 (entlast))

    Using visual lisp you can also extract available properties from objects. First, you need to retrieve the object for the selected entity, then extract. Either by:
    (vla-get-radius (vlax-ename->vla-object (entlast)))
    or
    (vlax-get-property (vlax-ename->vla-object (entlast)) 'radius)

    To learn LISP I recommend visiting AfraLisp. This will provide all the help you need to get started.

    To find out more about LISP tools specific to BricsCAD check out the LISP Developers Support Package (LDSP). The LDSP includes help on VLE, ACET express tools, BIM API, Sheetmetal API.

    Regards,
    Jason Bourhill
    CAD Concepts

  • The getpropertyvalue function does exist in AutoCAD. I believe it was introduced primarily for the Mac version of AC, which does not support Visual Lisp functions such as vlax-get-property.

  • @Roy Klein Gebbinck said:
    The getpropertyvalue function does exist in AutoCAD. I believe it was introduced primarily for the Mac version of AC, which does not support Visual Lisp functions such as vlax-get-property.

    Yes

    https://hyperpics.blogs.com/beyond_the_ui/2011/08/new-autolisp-functions-in-autocad-2012-for-mac.html

  • Hi All
    Thanks for your response.

    @Jason - The link you provided is very useful as I am a new user of LISP and was going by documentation in autoCAD.

    Rahul

  • rbharadw
    edited December 2018

    Hi Jason
    Code works well, thanks a ton.
    Rahul

  • All

    An extension to my question: Can you control the properties of a 3D object created using the loft command?

    Its all easy to change a 2D object like circle and most examples cover that. However, I am trying to create a 3D Object using the loft command and then trying to modify this. These are my steps:

    • Create a 2D circle
    • Create a 2D rectangle
    • Create a loft surface between these two. This gives a 3D object.
    • Now I want to modify the circle radius or rectangle size of this above object and want everything to be redrawn and modified.
      questions:
      Should I be deleting the old object and creating everything from scratch?
      Should I be working with a set or a list first (like create the circle, rectangle and the loft, put them in list or set or something else and then modify the circle and rectangle and redraw?)

    Any guidance would be great. Thanks.

  • Modifying the source entities will not result in an updated solid. The 'standard' approach would be to delete and recreate from scratch.

  • What you tried would be a History Based Modeling Like in Vectorworks.
    Or procedural modeling (in Modo, 3DSMax, Cinema4D, ..) or parmetric.
    There you can go back into the Edit Mode for either Path or Profile
    to update the resulting 3D Object. Or Boolean Operations and such.

    Bricscad or Microstation have Destructive Modeling approaches.
    If you cut something away - it's gone. You have to keep duplicates of
    your initial Geometry when you need to do variations or changes.

    Both have their pro and cons. History Based Modeling needs more
    system resources. Therefore you can dump your complex Objects to
    "Generic Solids" in Vectorworks or simple Mesh Objects in Modo,
    at any point later but will lose history.

    When I switched from 3DSMax to Modo, which was a destructive only
    modeler at that time, I thought it must be a pain without any parametric
    history. But I quickly realized that this is no problem and can be even
    faster - when it offers adequate manipulation tools and allows to edit
    multiple (different !) objects at a time.

    Like in your example, in Microstation you also can't (?) edit the Path,
    but you could change the Radius (=Profile) of your Solid with the
    PushPull Tool.
    Which does not work in Vectorworks and I think in Bricscad either.

  • Michael - Thanks for the info,learnt something new here. I think the point is that as long as I can recreate the object it is ok, dont have a preference the way it is done, either modifying the source and doing the loft again. I thought there could be smarter way. Sounds like bricsCAD might not be the best for what I am trying here (not sure as yet!)

    @Roy - thanks. I thought so as well, but as I am new to CAD development, I thought there could be a better way. I mean, think of it as a design engineer and you want to try 10 things, imagine spending time in drawing this again-and-again. For example, think of a conical funnel, it can be governed by slant height, angle, raddii of top and bottom. Every time you need to change one of these, imagine the commands you need to repeat. This gets much more complex when you have multiple objects.

  • Perhaps this will make it more clear as to what I want to do with Bricscad

    What I want to do:
    -Create a list of different geometries (3D objects)
    -Each geometry in a list can be created by its parameters and also modified. For example, a cone: I can create one using the radius, slant height, height or angle (they are all related) as user input. So I can give the math depending on what the user chooses
    -I want each of these geometry objects to have methods of their own (so I think I need a parent class with all the methods the sub-class inherits the methods and I can modify them). For example, each geometry (object) has a - add, modify, mate with upper, mate with lower or any other method
    -Each of these objects I create in the drawing will need to know and point out to each other (I think this is the entity names in a drawing). I am thinking like a linked list in C.

  • Michael Mayer
    edited December 2018

    Sounds like bricsCAD might not be the best for what I am trying here (not sure as yet!)

    I'm not sure as I don't have enough experience with Bricscad Modeling and
    don't know much of the hidden bad documented workflows, which I learned
    for VW after 5 years.
    I think you need about 3 years with a CAD to really feel comfortable.
    Every CAD has its strengths and weaknesses. Some always work besser in
    one or other tasks. You need to compare the whole package in your specific
    workflow and projects. And that takes much time and experience to conclude.

    To be honest, I don't feel any disadvantages with VW's history based Tools in
    my projects. In contrary for me it is very easy and flexible to use and the
    parametric workflow and familiar logic fits my brain and makes me fast.

    I think in your case it is about Bricscad's 3D Constraint Options
    (which I find a bit overwhelming and complicated)
    but there I don't have enough experience of what is possible and where are
    the limits.
    3D Constraints are used in BIM Insertion Objects like current Windows and
    Doors, but could be anything else like (missing) Stairs, Columns, ...
    Also there are the Parametric Arrays which also look much more capable
    than they seem at a first sight.

    Although there are so many basic tasks that I find so more tedious in Bricscad
    versus VW, there is a complete different feature approach in Bricscad with its
    kind of "artificial intelligence" that circumference some of such issues in a
    even more elegant and modern way already. And I expect much more to come.

  • Roy Klein Gebbinck
    edited December 2018

    @rbharadw If you want to use OOP then the Lisp API is not the right choice. Although the Visual Lisp part of the API is governed by an object model, you cannot create custom objects in Lisp. You can attach data to objects and have your application treat them in a special manner, and automate certain things using reactors, but that is about it.

  • @Roy, I am making objects in bricsCAD,so I am not making my own. I just want to have control over this object and add my own methods. I presume this is possible from what your saying?

  • Roy Klein Gebbinck
    edited December 2018

    Strictly speaking you cannot add methods or properties to existing objects either. But you can create functions to emulate OOP.
    For example, if you want to handle pyramids and cones in your application you might create functions with these signatures:

    (MyApp-Get-Top <object>)
    (MyApp-Put-Top <object> <3d point>)
    (MyApp-MoveTop <object> <3d vector>)
    
This discussion has been closed.