Recent Posts

Pages: 1 [2] 3 4 ... 10
11
AutoLISP (Vanilla / Visual) / help: Create block from file - explode it - and exit
« Last post by mhy3sx on July 14, 2024, 04:32:44 PM »
Hi, I download some dxf from gov webpage. I don't know why but all this files can not allow me to copy anything to clipboard. The only thing I can do to fix this problem is to create all the dxf file to block and then explode it. To do my job faster I try to do it with lisp but I have some problems

1) I don't know how to keep the coodinates to original coordinate after block created.
2) After zoom extent I want to explode again the block but I can not do it.

Code - Auto/Visual Lisp: [Select]
  1. (defun c:foo (/)
  2.   (setvar "OSMODE" 0)
  3.   (setvar "clayer" "0")
  4.   (command "PURGE" "BLOCKS" "*" "n")
  5.   (command "-view" "o" "top")
  6.   (command "ucs" "w")
  7.   (setq name (vl-filename-base (getvar "dwgname")))
  8.   (setq point (list 0 0 0))
  9.   (setq selectionset (ssget "_X" '((0 . "text,*polyline"))))
  10.   (command "_.-BLOCK" name point selectionset "")
  11.   (command "_.-insert" name "X" "1" "y" "1" "z" "1" point "") ; I WANT TO INSERT IN ORIGINAL COORDINATES
  12.   (command "zoom" "extent") ; Zoom extents before saving
  13.  
  14.   ; Explode the BLOCK before save the file and exit
  15.   (if selectionset
  16.     (progn
  17.       (command "_.explode" selectionset "")
  18.       (princ "\nEntities exploded successfully.")
  19.     )
  20.     (princ "\nNo INSERT entities found to explode.")
  21.   )
  22.  
  23.   (command "_.close" "_N")
  24.   (princ)
  25. )
  26.  
  27.  

Thanks
12
You can via lisp say get plines, then use a SSGET "CP" to get the block contained inside. You can then get area and update block. The hatch is a little more difficult as you need to get its boundary for use with the CP.

Do you have a Hatch Boundary lisp ?

Need a sample dwg to comment properly.
13
A new Beta is available, now also for BricsCAD with all necessary Lisp functions exported from the separate namespace of the CADCAL application. Just do a test:
(xdata-get (car  (entsel)) "CALSCRIPT")
and pick an object in one of the demo dwg files.

Maybe a week or so, and the final release will be available.


Edit: the BricsCAD feature "separate namespace" is implemented in a very poor way and can't be used for CADCAL. So a modified CADCAL.DES which is working in the global namespace is integrated in the new CADCAL.ZIP.


14
Ähhh ... I leave the topic here, because I started it here and "my" math is not different from any other peoples math. When somebody does not understand what we are talking about, then he/she should not reply, or should ask about the meaning. In your intended target forum nobody knows about CADCAL.

Now for your question: I don't understand it. Why do you wish to convert your code to a script file? I don't know what your code is good for. It is neither Lisp nor any CAD command.

The CADCAL scripts are as any other CAD script, which can also be run by the original ._SCRIPT command of AutoCAD or BricsCAD. Everything in the CADCAL scripts must comply with the rules of AutoCAD scripts.

Tell me which geometry entity your code produces, then I can tell you how to integrate it in a script. In AutoCAD or BricsCAD there is no FACET command and there is no FACET object type.

Do you mean the 3DFACE object? The CADCAL demo contains a script file ./demo/gabelroofhouse.scr, and there 3DFACE entities are created by a CAL command:
CAL 3DFACE(dp1,dp2,fp2,fp1)

But these CAL command for entity creation have been made before I developed the CALSCRIPT part and translated script commands to Lisp too. I don't think that I will leave that commands (i.e. 3DFACE, PLINE, LINE ...) as CAL commands in the final version. You better should use the normal script syntax
._3DFACE !dp1 !dp2 !fp2 !fp1
Please regard the empty space at the end of that line after !fp1. This (or an empty line following that line) is neccessary. Every space is the equivalent to entering <ENTER> at the command prompt, and you need an extra <ENTER> to finish the ._3DFACE command on the command line. Script lines must be constructed the very same way as you use these commands on the AutoCAD command line.


I have two queestion/s  for you=
a) How to convert these lines to CadCal.Src as script files?
Code: [Select]
facet normal 1 0 0
outer loop
vertex 141.48280334472656 0.5000000000000344 -155.3981475830078
vertex 141.48280334472656 0.5000000000000349 -157.79815673828125
vertex 141.48280334472656 3.5000000000000346 -157.79815673828125
endloop
endfacet

b) Please you move your Topic to this link/,s because too many user/sLisp do not understand  your math-calculation/s?
You move your-topic to this page bellow.
You move your-topic to this page bellow.
You move your-topic to this page bellow.
Code: [Select]
https://www.theswamp.org/index.php?board=11.0
click-here..after copy&paste

cleanup
15
AutoLISP (Vanilla / Visual) / Re: new CADCAL beta: Let there be light ...
« Last post by d2010 on July 13, 2024, 12:55:28 AM »
I have two queestion/s  for you=
a) How to convert these lines to CadCal.Src as script files?
Code: [Select]
facet normal 1 0 0
outer loop
vertex 141.48280334472656 0.5000000000000344 -155.3981475830078
vertex 141.48280334472656 0.5000000000000349 -157.79815673828125
vertex 141.48280334472656 3.5000000000000346 -157.79815673828125
endloop
endfacet

b) Please you move your Topic to this link/,s because too many user/sLisp do not understand  your math-calculation/s?
You move your-topic to this page bellow.
You move your-topic to this page bellow.
You move your-topic to this page bellow.
Code: [Select]
https://www.theswamp.org/index.php?board=11.0
click-here..after copy&paste

cleanup
16
CAD General / Re: Integrating AutoCAD with ERP Software (Epicor)
« Last post by DeeGeeCees_V.2.0 on July 12, 2024, 03:00:48 PM »
Hi Swampers.

I just did a search for AutoCad to Epicor and this thread popped up.

I know this is an old thread and theSwamp traffic has been sparse, but has anyone gone through the process of connecting AutoCad to Epicor?

I created a VBA app for use with Access many years ago, so I'm relearning things. Right now I'm looking into CadLink from QBuild to see if maybe a third party app can help this along. I'm basically at square one.

Any help would be very much appreciated.
17
AutoLISP (Vanilla / Visual) / new CADCAL beta: Let there be light ...
« Last post by berger@archtools.de on July 12, 2024, 10:13:37 AM »
A new beta of CADCAL is available, all you need is attatched to this post. Simply extract the ZIP to any directory, and - if not already done so - add this to the search path of AutoCAD or BricsCAD. In AutoCAD load the CADCAL VLX, in BricsCAD load the CADCAL.DES.

When CADCAL is loaded you can test the sample files in the ./demo subdirectory.

This new beta now supports object communication, which allows the user to create simple simulations. A very simple sample ist defined by the switch.scr and lamp.scr. Both use blocks, and these are available in the switch-and-lamp.dwg file. You need to do this sample in this dwg file.

The syntax and structure of CADCAL objects have changed significantly and are adapted to most object oriented languages. So simply setting in a script
(setq SELF.LAYER "MyNewLayer")
will cause that the object is placed on that layer.

The Lisp which is created by (setq myfun (C:CALSCRIPT->LISP)) now has an additional argument SELF. SELF can either be the entity name of a CALSCRIPT object, and then this object is modified according to the other arguments, i.e. a NICKSHOUSE object with ename EN can get new properties WIDTH and HEIGHT this way:
(apply myfun (list width height EN)). The ./demo/NICKSHOUSE.LSP shows how you can create your own apps using automatically created CALSRIPT Lisp code.
A new object can be created at insertionpoint and insertionangle this way:
(apply myfun (list width height (list insertionpoint insertionangle))
The insertion angle must be given in radians.

The communication between CALSCRIPT objects is created by the user with the command CC-CONNECT. One single master object can communicate to many slave objects. Every slave can only have one master. A slave object can also be a master to other slaves. Caution: at the moment the beta version does not check for recursions. Don't create communication circles which will never end.

A slave object reads all the properties of the master object, and can use these for calculations, or to overwrite it's own properties. See the local variables in the LAMBDA created by command CALSCRIPT->LISP from the lamp.scr for a list of properties, which can be changed:
Code - Auto/Visual Lisp: [Select]
  1. (LAMBDA (POWER            SELF             /
  2.          SELF.ENAME       SELF.DATA        SELF.ORIGIN
  3.          SELF.ANGLE       SELF.SCALE       SELF.XSCALE
  4.          SELF.YSCALE      SELF.ZSCALE      SELF.LAYER
  5.          SELF.OCS         SELF.COLOR       SELF.LINETYPE
  6.          SELF.LINEWEIGHT  SELF.PROPERTIES  SELF.NAME
  7.          SELF.POWER       MASTER.DATA      MASTER.ORIGIN
  8.          MASTER.ANGLE     MASTER.SCALE     MASTER.XSCALE
  9.          MASTER.YSCALE    MASTER.ZSCALE    MASTER.LAYER
  10.          MASTER.OCS       MASTER.COLOR     MASTER.LINETYPE
  11.          MASTER.LINEWEIGHT                 MASTER.PROPERTIES
  12.          MASTER.NAME      MASTER.ENAME
  13. ...
  14. ))
  15.  

The lamp.scr ist really very simple:
Code - Python: [Select]
  1. (setq self.name "LAMP")
  2. ;;
  3. cc-import power,0
  4. cc-overwrite power
  5. ;;
  6. (if (zerop power) (setq bn "lamp-off")(setq bn "lamp-on"))
  7. (if master.origin (command "._line" origin master.origin ""))
  8. ._INSERT !bn !ORIGIN 1 1 0
  9.  

The SELF.NAME declaration is opional. When it is set, CADCAL adds a xdata-marker to the object with the appname of this name. This enables a programmer to easily find and filter these objects in a dwg, or to filter communication data.

The import declaration has changed to a script command call, but the previous syntx
CAL import(power,0)
can also be used.
With "cc-import power,0" we declare an object argument "power" and give it a default value of 0 (= "off").
The "cc-overwrite power" declaration tells that when communication with a master object is established, the script variable "power" and the object variable self.power are replaced by the master.power. A declaration like that would have the same effect:
(if master.power (setq power master.power self.power master.power))
When more than one property should be overwritten by master properties, than add the other properties with a comma:
cc-overwrite power,layer
will ovewrite the layer property too and place the object on the same layer as the master object. This declaration would have the same effect:
(if master.layer (setq self.layer master.layer))

The script line "(if (zerop power) (setq bn "lamp-off")(setq bn "lamp-on"))" sets the block name BN for the insert according to the power property.
The line "(if master.origin (command "._line" origin master.origin "")) " draws a line from the master's insertionpoint to the object's insertionpoint.

Now open the switch-and-lampp.dwg, and CC-MODIFY a switch object. Since the CADCAL beta only supports numbers as arguments, 0 means off and 1 means on. Let there be light ...

The nickshouse-comm.dwg shows how the nickshouse object reflects communication. When connected with CC-CONNECT, the slave object will place itself at the right side of the master in the same angle as the master, and it will overwrite it's own self.layer and self.color with the data from the master.

You can build long communication chains between objects, and so you can model simple simulations. Just think of gear objects where on gear meshes with another, and they rotate at different speeds according to their sizes ...


Edit: the BricsCAD feature "separate namespace" is implemented in a very poor way and can't be used for CADCAL. So a modified CADCAL.DES which is working in the global namespace is integrated in the new CADCAL.ZIP.
18
AutoLISP (Vanilla / Visual) / Re: nxn matrices - challenge
« Last post by dgpuertas on July 12, 2024, 08:42:39 AM »
Thanks Ribarm, much calmer after your second post.

19
AutoLISP (Vanilla / Visual) / Re: Replace text with block Attribute
« Last post by mhy3sx on July 12, 2024, 06:56:18 AM »
Thanks BIGAL  :smitten:
20
AutoLISP (Vanilla / Visual) / Re: how to use CADCAL as a Lisp code generator
« Last post by d2010 on July 12, 2024, 03:28:33 AM »
You?10="the BricsCAD Lisp interpreter is very much faster than that of AutoCAD, at least 10 times ore more. So CADCAL under BricsCAD ist much faster than GeomCAL under AutoCAD. And while GeomCAL is available only for AutoCAD, CADCAL supports BricsCAD too."
I10answer=Yes, very good  news, thank/s  good news :smitten:
               I will test your vlx very soon.
Pages: 1 [2] 3 4 ... 10