The DataCAD Developer Network (DDN) is an online resource for information and support for DCAL® (DataCAD Applications Language) developers as well as anyone interested in creating fonts, toolbars, hatch patterns, or linetypes for use in DataCAD.
#79886 by dhs
Fri Jul 09, 2021 6:55 pm
Whilst I can use the standard Delphi open file dialog to accept a Symbol File name from the user, it does not display a preview window. It would be possible to write a custom component that displayed a preview, but it would be a relatively major effort as it would need to cater for every possible entity type .

I'm 99% certain the D4D does not provide an OpenSymbolFile type of dialog, but if it does then I would be grateful is somebody could point it out to me!

If there is no current function available to D4D, then is there an existing procedure in DataCAD to show a symbol file dialog, and could that procedure be exposed to D4D to provide this functionality to a macro?

Thanks,
David H.
#79911 by Mark F. Madura
Wed Jul 14, 2021 4:51 pm
DataCAD's Open Dialog w/ Preview class inherits the TJvOpenDialog class which inherits the TOpenDialog class. TJvOpenDialog is from the JEDI Visual Component Library, so exposing this dialog or some derivative is a rabbit hole I don't want to go down. That said, I've exported a 'SymbolPreviewOnPanel' procedure we use internally to draw a symbol on a TPanel.

procedure SymbolPreviewOnPanel(Panel: TPanel; symb: sym_type; ShowIsometric: Boolean); stdcall;

I haven't had a chance to test it in a D4D application yet, but you should be able to create a form with a TPanel and in the TPanel's OnPaint event pass the panel and symbol which would work for symbols that are already loaded in an open drawing.

For previewing external symbols on the hard drive, I might be able to export another function 'Convert2NewSymbol' which accepts a symbol filename and returns a sym_type which can then be passed to SymbolPreviewOnPanel. When I get some time, I'll look into it further.
#79914 by dhs
Thu Jul 15, 2021 7:29 am
Thanks for taking the time to reply Mark.
I have tried to use SymbolPreviewOnPanel but get an access violation. Possibly I am doing something wrong?
Based on the way other procedures are included in UInterfaces, I added the following lines to UInterfaces.pas (in appropriate sections):
Code: Select all  TPFSymbolPreviewOnPanel = procedure(Panel: TPanel; symb: sym_type; ShowIsometric: Boolean); stdcall;
  SymbolPreviewOnPanel: TPFSymbolPreviewOnPanel;
  @SymbolPreviewOnPanel := GetProcAddress(dllhandle, 'SymbolPreviewOnPanel');

The TPanel's onPaint event is protected so I think I would need to create a new component inherited from it to place logic there? This was meant to be a simple and quick test, so instead I added a couple of buttons to my form and called SymbolPreviewOnPanel from their onClick events. The first button tries to preview the first symbol in the drawing. The second tries to load a symbol from file and preview that. I was expecting the first to work, and 'hoping' the second might also work:
Code: Select allprocedure TForm1.Button1Click(Sender: TObject);
var
  adr : lgl_addr;
  sym : sym_type;
begin
  adr := sym_first;
  if sym_get (sym, adr) then
    SymbolPreviewOnPanel (Panel1, sym, false);
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  symname : symstr;
  sym: sym_type;
begin
  if OpenDialog1.execute then begin
    symname := symstr(OpenDialog1.FileName);
    delete (symname , length(symname )-3, 4);
    if symread (symname, symstr(TPath.GetFileNameWithoutExtension(OpenDialog1.FileName)), sym) = fl_ok then
      SymbolPreviewOnPanel (Panel1, sym, false);
  end;
end;


Clicking on either button produces an Access Violation error.
If there is something obvious that I have done wrong then please let me know, but the preview would be a 'nice to have' so it is not worth spending too much effort on (I was hoping there may be a complete dialog similar to GetFlName that you could expose, but that is obviously not the case) .

Rgds,
dh
#79916 by Mark F. Madura
Thu Jul 15, 2021 9:19 am
FYI, you can use Dependency Walker to get a complete list of exported functions from DCADWIN.exe:

Here's the export from DataCAD 22.01.01.14 BETA:
cvintst
cvlntst
cvrllst
menumove
menuCopy
menuRotate
menuEnlarge
menuMirror
menuStretch
menuIdentify
menuChange
menuErase
menuCleanup
menuGoodies
menuPolygons
menuCurves
menuLinetype
menuHatch
menuWindowin
menuToscale
menuGotoview
menuGrids
menuLayers
menuTemplate
menuSettings
menuMeasures
menuPlotter
menuDmension
menuDisplay
menuObjsnap
menuFreehand
menuLinkline
menuDirectry
menuMovedrag
menuArrayRect
menuArrayCirc
menuFillets
menuChamfer
menu1LnTrim
menu2LnTrim
menuWeldLine
menuTintsct
menuLintsct
menuTangents
menuSS
menuGeom
callgetlayer1
FnKeyConv
isFnKey
bitset
bitclear
bittest
bitfirst
cvdisst
f_open
f_create
f_close
f_rdint
f_rdreal
f_rdstrln
f_rdchar
f_rdbyte
f_rdln
f_wrint
f_wrreal
f_wrchar
f_wrln
f_seek
f_setrec
f_wrbool
f_rdbool
f_eof
f_wrstrln
GetSetRubbx
GetSetRubln
circ3pt
intr_linarc
intr_crccrc
intr_arcarc
intr_crcarc
intr_lincrc
angnormalize
menuViewer
menuDatacad3
menuElevation
menuControls
menuEditPlane
menuPlaneSnap
menuSetPersp
menuWalkThru
menuSetObliq
menuGotoView3d
menuClipCube
menuHide
menu3dLine
menuSettings3d
menuBlocks
menuCylnVert
menuCylnHori
menuCone
menuTruncCone
menuDome
menuTorus
menuMeshSurf
menuRevSurf
menuMarker
menuSlab
menuVoids
menuPartial
menuMove3d
menuCopy3d
menuRotate3d
menuEnlarge3d
menuErase3d
menuStretch3d
menuChange3d
menuExplode3d
menuEdit3d
menuEntity3d
void_add
void_del
void_delall
void_update
plvoid_init
plvoid_add
plvoid_del
plvoid_delall
plvoid_get
plvoid_update
SetLocalSize
pnt_in_poly
ent_incirc
menuText
tostr
todis
Str2ParserDis
view_calcpers
view_calcorth
view_calcpara
view_calcoblq
GetLoadedMaterials
material_first
material_get
Str2Ang
ang2str
Str2ParserAng
pline_centroid
menuDoorSwng
menuWindows
menuCutWall
getarc
getlyr
fgetlyr
shade
getpoly
cutout
menuSaveImage
getpoint
getpointp
getpoint3
menuPolygon
menuPolyHori
menuSlabHori
menuPolyRect
menuSlabRect
menuPolyVert
menuSlabVert
menuPolyIncl
menuSlabIncl
getdis
getint
getang
getclr
getesc
_addSkpMaterial
currwndw
drawcursor
extents
pixsize
pushview
popview
redraw
redrawall
regen
toview
vwptclear
windowin
cvstint
cvstlnt
cvstrll
strComp
strDel
strlen
strIns
strpos
draw_mode
ent_drawmode
ent_enlarge
ent_move
ent_rotate
ent_tran
ent_tranok
zbase
zhite
getlinecolor
setlinecolor
getlyrcurr
getlyrname
lyr_create
lyr_del
lyr_find
lyr_first
lyr_islocked
lyr_ison
lyr_lock
lyr_next
lyr_nil
lyr_read
lyr_set
lyr_seton
lyr_viewfile
lyr_write
setlayername
lyr_init
lyr_term
sym_create
sym_find
sym_get_atr
sym_purge
sym_read
sym_write
atr_add2ent
atr_delent
atr_add2lyr
atr_dellyr
atr_add2sym
atr_delsym
atr_add2sys
atr_delsys
atr_entfind
atr_entfirst
atr_lyrfind
atr_lyrfirst
atr_viewfind
atr_viewfirst
atr_symfind
atr_symfirst
atr_sysfind
atr_sysfirst
arc_to_bulge
bulge_to_arc
pline_area
pline_perim
polyvert_copy
void_init
void_get
void_get_di
order
addpnt
subpnt
mulpnt
meanpnt
polar
intr_linlin
pntscolinear
distance
catenlrel
setenlrel
catrotrel
setrotrel
invert
xformpt
detail_get
view_add
view_del
view_first
view_last
view_currmode
view_setmode
inmat_curr
scale_curr
scale_get
hatch_mode
addr2ints
ints2addr
calcdim
ssGetName
ssSetName
ClrGetName
ClrSetName
dwgname
envget
mode_box
mode_ents
ent_near
GetCurrLbl
getrefpnt
setrefpnt
getrubpnt
setrubpnt
pause
readclock
getpath
setpath
txtbox
stopgroup
mode_sym
ent_add
CurrentState
ent_updates
get_inpstyl
set_inpstyl
getLongLayerName
view_modedisp
ScreenSize
PaperSize
PaperWorkSize
PaperSymbolSize
topix
setworklyr
dodimscale
setgesclvl
clrGetPen
clrSetPen
msgSetLen
f_wrstr
f_rdstr
setclipactive
lyr_extents
cvangst
ent_draw
GetEntityMaterial
GetLayerMaterial
getNearestColorPalleteIndex
getDCALVersion
dwgpath
GetLoadedLines
GetLoadedWinLines
get_lineType_definition
get_loaded_lineType_definitions
f_wrpnt
f_wrmod
unhilite_all
hi_lite
hide
xref_name
clip
extents_mode
poly_fix
menuArc2pt
menuArc3pt
menuArcCentAng
menuArcCentArc
menuArcCentChrd
menuArcTan
menuEllipse
menuCrcRad
menuCrcDia
menuCrc3pt
callBezbsp
is_trial
get_license_type
get_license_id
get_customer_id
get_customer_company
get_customer_FirstName
get_customer_LastName
get_customer_name
get_customer_address1
get_customer_address2
get_customer_city
get_customer_state_province
get_customer_zip
get_customer_country
get_customer_email
get_customer_phone
get_customer_fax
get_latest_version_number
get_installation_name
trial_days_left_since_license_creation
ssAdd
ssClear
ssDel
ssLength
ssDelAll
ssMember
GetTextureUV
GetEntityTextureOrigin
sym_clearRef
sym_count
sym_first
sym_get
sym_next
sym_ref
sym_update
entWithinSym_has2DTag
entWithinSym_has3DTag
GetColorIndex
atr_init
atr_2str
atr_update
atr_get
atr_next
GetEntArticle
SetEntArticle
GetActArticle
SetActArticle
Sys_Add_AtrStruct_C
Sys_Update_AtrStruct_C
Get_AtrStruct_C
Sys_Add_AtrStruct
Hdr_AddPut_AtrStruct
Get_AtrStruct
UndoStartTransaction
UndoEndTransaction
ImgFileExists
wrtlyr
wrtscl
wrtss
wrtstat
wrtltype
view_get
view_init
view_update
view_getcurr
view_setcurr
view_display
list_get
InitSolidFillAttribute
InitBitmapAttribute
UpdateFillBmpEntityAttribute
DeleteFillBmpAttribute
RGBtoDCADRGB
DCADRGBtoRGB
GetPaletteColorName
DCADPenToRGB
ctrlRightClickEntAddr
MyBitBlast
Lblset
Lblseti
Lblsinit
lblson1
lblsinit1
lblson
Lblsett
lblsetti
lblsettf
LblMsg
wrtlvl
wrtlvli
SymbolPreviewOnPanel
poly3_ent
draw_ent
ent_copy
ent_init
keyForceExit
wrtmsgi
wrterri
disfrompolyvert
ent2polyvert
polyvert_add
polyvert_count
polyvert_del
polyvert_get
polyvert_init
polyvert_ins
polyvert_update
polyvert2ent
dis_from_arc
ent_extent
project
minmax_xyz
betweenang
drawline
drawline2
ent_first
ent_next
ent_del
ent_get
ent_update
ent_relink
ent_setunused
mode_init
mode_init1
mode_ignore
mode_lyr
mode_1lyr
mode_box_pt
mode_fence
mode_stp
mode_lyrlocked
mode_ss
mode_enttype
mode_atr
mode_1ent
mode_group
atr_find
lyr_get
numlayer
lyr_clear
calctext
ent_group
lyr_put
dragBar
drag2Pt
dragBoxMov
dragCrc3
dragDia
dragModeRot
dragRad
dragModeMove
dragPly
dragPlyRot
brkprss
keypress
Str2ParserInteger
Str2ParserReal
msgget
MakeFence
Plane_Wall_Fence
Round_Wall_Fence
boundary_search
drawlines
movemode
view_flread
view_flwrite
ent_explode
ExecProg
WinExecAndWait
SmartEntity2RegularEntities
SetArgs
callGetDis
callDGetDis
callGetang
callDGetang
callGetint
callDGetint
callGetclr
callGetesc
callAnswerA
callGlobalesc
callNone
callGetReal
callDGetReal
callGetchar
callDgetstr132
callDGetstr255
callGetTxtSiz
callGetPlin
callView
callGetflname80
callGetflname255
callgetflname1_255
callGetflname1_80
callGetscale
callDimLin
callDimAng
callDimDia
callDimRad
callDimXplode
menuDivide
menuIntrsect
strpad
strinc
strsub
strcat
strupcase
isnil
setnil
PGSavevar
PGSv
angle
settran
chkangs
between
crossprod
skalarProdukt
kreuzProdukt
mean
setident
dotprod
setscale
matmmat
setrotate
linelen3
cattran
settran
calcplane
setpoint
sincos
fixangs
catmat
transpose
samepnt2
catrotate
sphere_cart
SwapPnt
cylind_cart
catscale
crossz
unitvec
catobliq
catpers
proj_pnt
tan
swapaFloat
swapasInt
maximum3
samepnt3
cart_sphere
cart_cylind
interb
dis_from_line
dis_from_seg
degrees
radians
distance3
pipe_init
pipe_draw
ent_draw_2d
ent_draw_dl
gridCalc
gridsnapto
DataCAD_Version
eq_lgl_addr
wrtmsg
wrterr
wrtmsg_C
wrtMacroOutput_C
wrterr_C
Lblset_C
Lblsett_C
lblsettf_C
LblMsg_C
wrtlvl_C
getlyrname_C
lyr_create_C
lyr_find_C
lyr_read_C
lyr_viewfile_C
lyr_write_C
setlayername_C
getlyrcurr_C
lyr_first_C
lyr_next_C
sym_first_C
ent_first_C
ent_next_C
GetDcadwinIniFileName_C
atr_sysfirst_C
view_first_C
view_last_C
sym_create_C
symfind_C
sym_get_atr_C
sym_read_C
sym_write_C
ssGetName_C
ssSetName_C
tostr_C
todis_C
cvdisst_C
cvintst_C
cvlntst_C
cvrllst_C
cvstint_C
cvstlnt_C
cvstrll_C
Str2Ang_C
ang2str_C
cvangst_C
getpath_C
setpath_C
atr_2str_C
atr_find_C
atr_entfind_C
atr_lyrfind_C
atr_viewfind_C
atr_symfind_C
atr_sysfind_C
mode_atr_C
scale_get_C
hatch_mode_C
ClrGetName_C
ClrSetName_C
dwgname_C
dwgpath_C
envget_C
WinExecAndWait32_C
ExecProg_C
GetCurrLbl_C
ints2addr_C
Read_Ini_String_C
Write_Ini_String_C
Read_Ini_Bool_C
Write_Ini_Bool_C
Read_Ini_Integer_C
Write_Ini_Integer_C
Read_Ini_aFloat_C
Write_Ini_aFloat_C
InitSolidFillAttribute_C
InitBitmapAttribute_C
GetInfoText_C
atr_entfirst_C
atr_lyrfirst_C
atr_viewfirst_C
atr_next_C
atr_symfirst_C
xref_name_C
#79920 by dhs
Thu Jul 15, 2021 3:16 pm
Thanks Mark . When you mentioned SmartEntity2RegularEntities to me a few weeks back it was already there and worked (just not documented or included in UInterfaces), so I assumed this one may have been in the same category ... I'll give it another shot with the next build.
(For backward compatibility of my macro I'll use it in a try/except block with the exception handled appropriately in case the user does not have the latest build.)

Interesting list of exposed functions.
I assume that the ones with _C suffix are for the C++ version of DCAL. Most of those have equivalents without the _C suffix (but not all).
#79925 by dhs
Fri Jul 16, 2021 4:09 pm
Just tested in 22.01.01.15.
It is not throwing any exception, but appears not to do anything (nothing displayed on the panel). I will probably look into this further in the future, but probably not worth spending a significant amount of time on this at this stage from my point of view ....
#79926 by Mark F. Madura
Fri Jul 16, 2021 4:39 pm
dhs wrote:Thanks Mark . When you mentioned SmartEntity2RegularEntities to me a few weeks back it was already there and worked (just not documented or included in UInterfaces), so I assumed this one may have been in the same category ... I'll give it another shot with the next build.
(For backward compatibility of my macro I'll use it in a try/except block with the exception handled appropriately in case the user does not have the latest build.)

Interesting list of exposed functions.
I assume that the ones with _C suffix are for the C++ version of DCAL. Most of those have equivalents without the _C suffix (but not all).

Yes, the _C is for DCAL for C++ to handle differences between Delphi and C++ (string handling in particular).
#79927 by Mark F. Madura
Fri Jul 16, 2021 4:41 pm
dhs wrote:Just tested in 22.01.01.15.
It is not throwing any exception, but appears not to do anything (nothing displayed on the panel). I will probably look into this further in the future, but probably not worth spending a significant amount of time on this at this stage from my point of view ....

I was hoping to expose this at a top-level. If I get some free time, I'll look into it a bit further.
#79949 by dhs
Mon Jul 26, 2021 3:51 pm
A follow up for anybody else that may be interested in using this functionality ....

After some further off-forum discussion with Mark, it is obvious that the SymbolPreviewOnPanel does work if you compile your macro using Delphi 6 (version used to compile DataCAD). It does not work if compiling with Delphi 10.3 (which I am using). It appears that there is a compiler version issue when passing a TPanel parameter. Not sure at which version between 6 and 10 this became an issue.

Previous versions of Delphi are available to people with the latest paid version, but as I am using the Community Edition I don't think there is a way for me to get Delphi 6 even if I wanted to.

A note regarding Delphi 10.3 that I am using: In-line variable definitions were introduced in this version. This is a nice feature imho, but I am not using it as the editor highlights inline definitions (and some code following them) as errors. The code compiles fine, but I find the error indications in the editor too distracting.

Who is online

Users browsing this forum: No registered users and 6 guests

About DataCAD Forum

The DataCAD Forum is a FREE online community we provide to enhance your experience with DataCAD.

We hope you'll visit often to get answers, share ideas, and interact with other DataCAD users around the world.

DataCAD

Software for Architects Since 1984